Step 3: Configure Instance Details
Step 4: Add Storage
Step 5: Add Tags
Step 6: Configure Security Group
Step 7: Create a key pair
Step 8: Launch instance by using git bash terminal
sudo -i
Step 8: Set up Prometheus server in the cluster to run Kubernetes
apt-get update && apt-get install -y apt-transport-httpscurl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -cat <<EOF >/etc/apt/sources.list.d/kubernetes.listdeb http://apt.kubernetes.io/ kubernetes-xenial mainEOFapt-get updateapt-get install -y kubelet=1.15.4-00 kubeadm=1.15.4-00 kubectl=1.15.4-00 docker.io
Step 9: Setup the Kubernetes Master
kubeadm init
Step 10: To start using your cluster, you need to run the following as a regular user:
mkdir -p $HOME/.kubesudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/configsudo chown $(id -u):$(id -g) $HOME/.kube/config
Step 11: Update the yum package repositories.
sudo apt-get install yum*
Step 12: Create a Prometheus user, required directories, and make prometheus user as the owner of those directories.
sudo useradd --no-create-home --shell /bin/false prometheus
sudo mkdir /etc/prometheus
sudo mkdir /var/lib/prometheus
sudo chown prometheus:prometheus /etc/prometheus
sudo chown prometheus:prometheus /var/lib/prometheus
Step 13: Download the source using curl, untar it and rename the extracted folder to prometheus-files.
wget https://github.com/prometheus/prometh...
tar -xvf prometheus-2.20.1.linux-amd64.tar.gz
mv prometheus-2.20.1.linux-amd64 prometheus-files
Note: Get the latest download of Prometheus from Prometheus home page
Step 14: Copy prometheus and promtool binary from prometheus-files folder to /usr/local/bin and change the ownership to prometheus user.
sudo cp prometheus-files/prometheus /usr/local/bin/
sudo cp prometheus-files/promtool /usr/local/bin/
sudo chown prometheus:prometheus /usr/local/bin/prometheus
sudo chown prometheus:prometheus /usr/local/bin/promtool
Step 15: Move the consoles and console_libraries directories from prometheus-files to /etc/prometheus folder and change the ownership to prometheus user.
sudo cp -r prometheus-files/consoles /etc/prometheus
sudo cp -r prometheus-files/console_libraries /etc/prometheus
sudo chown -R prometheus:prometheus /etc/prometheus/consoles
sudo chown -R prometheus:prometheus /etc/prometheus/console_libraries
Setup Prometheus Configuration. All the prometheus configurations should be present in /etc/prometheus/prometheus.yml file.
Step 16: Create the prometheus.yml file.
sudo vi /etc/prometheus/prometheus.yml
Paste the following content in the prometheus.yml
global:
scrape_interval: 10sscrape_configs:
— job_name: ‘prometheus’
scrape_interval: 5s
static_configs:
— targets: [‘localhost:9090’]
Note: Replace localhost here with public ip of your system
Step 17: Change the ownership of the file to prometheus user.
sudo chown prometheus:prometheus /etc/prometheus/prometheus.yml
Step 18: Setup Prometheus Service File to start automatically
sudo vi /etc/systemd/system/prometheus.service
Copy the following content to the file.
[Unit]
Description=Prometheus
Wants=network-online.target
After=network-online.target[Service]
User=prometheus
Group=prometheus
Type=simple
ExecStart=/usr/local/bin/prometheus \
— config.file /etc/prometheus/prometheus.yml \
— storage.tsdb.path /var/lib/prometheus/ \
— web.console.templates=/etc/prometheus/consoles \
— web.console.libraries=/etc/prometheus/console_libraries[Install]
WantedBy=multi-user.target
Step 19: Reload the systemd service to register the prometheus service and start the prometheus service.
sudo systemctl daemon-reload sudo systemctl start prometheus
Check the status by using the following command
sudo systemctl status prometheus
Step 20: Before accessing the Web UI, you need to change the security group settings in the AWS by editing inbound rules and open the port 9090 where prometheus will be running
Step 21: Using your public ip and paste in the browser using the following command
http://localhost:9090/graph
Note: In the above local host is your public IP address