Dev Sec Ops
Dev Sec Ops
Project Architecture:
Phase 2: Security
10. Then Simply add the Docker image building and pushing it to the dockerhub steps too in the
JenkinsFile.
After all build steps get successful the Jenkins Job will run and looks like:
And the dependency checker as:
And when u access the <instance ip>:8081 on browser the following page will be displayed
Phase 4: Monitoring
Installing Prometheus:
• First, create a dedicated Linux user for Prometheus and download Prometheus:
sudo useradd --system --no-create-home --shell /bin/false Prometheus
wget
https://github.com/prometheus/prometheus/releases/download/v2.47.1/prometheus-
2.47.1.linux-amd64.tar.gz
• Extract Prometheus files, move them, and create directories:
tar -xvf prometheus-2.47.1.linux-amd64.tar.gz
cd prometheus-2.47.1.linux-amd64/
sudo mkdir -p /data /etc/Prometheus
sudo mv prometheus promtool /usr/local/bin/
sudo mv consoles/ console_libraries/ /etc/prometheus/
sudo mv prometheus.yml /etc/prometheus/prometheus.yml
Set ownership for directories:
• sudo chown -R prometheus:prometheus /etc/prometheus/ /data/
Create a systemd unit configuration file for Prometheus:
• sudo nano /etc/systemd/system/prometheus.service
Add the following content to the prometheus.service file:
• Enable and start Prometheus:
sudo systemctl enable Prometheus
sudo systemctl start prometheus
• Verify Prometheus's status:
sudo systemctl status Prometheus
• You can access Prometheus in a web browser using your server's IP and port 9090:
http://<your-server-ip>:9090
• Create a system user for Node Exporter and download Node Exporter:
sudo useradd --system --no-create-home --shell /bin/false node_exporter
wget
https://github.com/prometheus/node_exporter/releases/download/v1.6.1/node_exporte
r-1.6.1.linux-amd64.tar.gz
• Extract Node Exporter files, move the binary, and clean up:
tar -xvf node_exporter-1.6.1.linux-amd64.tar.gz
sudo mv node_exporter-1.6.1.linux-amd64/node_exporter /usr/local/bin/
rm -rf node_exporter*
• Create a systemd unit configuration file for Node Exporter:
sudo nano /etc/systemd/system/node_exporter.service
• Add the following content to the node_exporter.service file:
• Enable and start Node Exporter:
sudo systemctl enable node_exporter
sudo systemctl start node_exporter
• Verify the Node Exporter's status:
sudo systemctl status node_exporter
• You can access Node Exporter metrics in Prometheus.
Grafana
Install Grafana on Ubuntu 22.04 and Set it up to Work with Prometheus
Step 1: Install Dependencies:
• Verify the status of the Grafana service to ensure it's running correctly:
sudo systemctl status grafana-server
Step 7: Access Grafana Web Interface:
• Open a web browser and navigate to Grafana using your server's IP address. The
default port for Grafana is 3000. For example:
http://<your-server-ip>:3000
• You'll be prompted to log in to Grafana. The default username is "admin," and the
default password is also "admin."
• To visualize metrics, you need to add a data source. Follow these steps:
1. Click on the gear icon (⚙️) in the left sidebar to open the "Configuration"
menu.
2. Select "Data Sources."
3. Click on the "Add data source" button.
4. Choose "Prometheus" as the data source type.
5. In the "HTTP" section:
Set the "URL" to http://localhost:9090 (assuming Prometheus is running
on the same server).
6. Click the "Save & Test" button to ensure the data source is working.
Step 10: Import a Dashboard:
• To make it easier to view metrics, you can import a pre-configured dashboard. Follow
these steps:
• Click on the "+" (plus) icon in the left sidebar to open the "Create" menu.
• Select "Dashboard."
• Click on the "Import" dashboard option.
• Enter the dashboard code you want to import (e.g., code 1860).
• Click the "Load" button.
• Select the data source you added (Prometheus) from the dropdown.
• Click on the "Import" button.
You should now have a Grafana dashboard set up to visualize metrics from Prometheus.
• Grafana is a powerful tool for creating visualizations and dashboards, and you can further
customize it to suit your specific monitoring needs.
That's it! You've successfully installed and set up Grafana to work with Prometheus for monitoring
and visualization.
Step 11: Configure Prometheus Plugin Integration:
Phase 5: Notification
Implement Notification Services:
• If any Job Got Success or Failed You will get an email as this:
Phase 6: Kubernetes
Create Kubernetes Cluster with Nodegroups
• In this phase, you'll set up a Kubernetes cluster with node groups. This will provide a scalable
environment to deploy and manage your applications.
• Prometheus is a powerful monitoring and alerting toolkit, and you'll use it to monitor your
Kubernetes cluster. Additionally, you'll install the node exporter using Helm to collect metrics
from your cluster nodes.
Install Node Exporter using Helm
• To begin monitoring your Kubernetes cluster, you'll install the Prometheus Node Exporter.
This component allows you to collect system-level metrics from your cluster nodes. Here are
the steps to install the Node Exporter using Helm:
• Update your Prometheus configuration (prometheus.yml) to add a new job for scraping
metrics from nodeip:9001/metrics. You can do this by adding the following configuration to
your prometheus.yml file:
- job_name: 'Netflix'
metrics_path: '/metrics'
static_configs:
- targets: ['node1Ip:9100']
• Replace 'your-job-name' with a descriptive name for your job. The static_configs section
specifies the targets to scrape metrics from, and in this case, it's set to nodeip:9001.
• Don't forget to reload or restart Prometheus to apply these changes to your configuration.
To deploy an application with ArgoCD, you can follow these steps, which I'll outline in Markdown
format:
Deploy Application with ArgoCD
1.Install ArgoCD:
• You can install ArgoCD on your Kubernetes cluster by following the instructions provided in
the EKS Workshop documentation.
2.Set Your GitHub Repository as a Source:
• After installing ArgoCD, you need to set up your GitHub repository as a source for your
application deployment. This typically involves configuring the connection to your repository
and defining the source for your ArgoCD application. The specific steps will depend on your
setup and requirements.
3.Create an ArgoCD Application:
• To Access the app make sure port 30007 is open in your security group and then open a new
tab paste your NodeIP:30007, your app should be running.
If you see the page as above:
Phase 7: Cleanup
Happy Learning