𝐄𝐊𝐒 𝐊𝐮𝐛𝐞𝐫𝐧𝐞𝐭𝐞𝐬 𝐭𝐨 𝐝𝐞𝐩𝐥𝐨𝐲 𝐉𝐞𝐧𝐤𝐢𝐧𝐬 𝐂𝐈/𝐂𝐃 𝐭𝐨𝐨𝐥 𝐮𝐬𝐢𝐧𝐠 𝐀𝐮𝐭𝐨𝐦𝐚𝐭𝐞𝐝 𝐰𝐚𝐲 𝐎𝐩𝐞𝐫𝐚𝐭𝐨𝐫, 𝐚𝐧𝐝 𝐦𝐚𝐧𝐚𝐠𝐞 𝐉𝐞𝐧𝐤𝐢𝐧𝐬 𝐏𝐢𝐩𝐞𝐥𝐢𝐧𝐞 𝐚𝐬 𝐂𝐨𝐝𝐞 𝐛𝐲 𝐉𝐞𝐧𝐤𝐢𝐧𝐬 𝐊𝐮𝐛𝐞𝐫𝐧𝐞𝐭𝐞𝐬 𝐂𝐑𝐃 𝐚𝐧𝐝 𝐀𝐩𝐩𝐥𝐢𝐜𝐚𝐭𝐢𝐨𝐧 𝐣𝐨𝐛𝐬 𝐥𝐚𝐮𝐧𝐜𝐡𝐞𝐬 𝐢𝐧 𝐝𝐲𝐧𝐚𝐦𝐢𝐜 𝐩𝐫𝐨𝐯𝐢𝐬𝐢𝐨𝐧𝐢𝐧𝐠 𝐧𝐨𝐝𝐞 𝐨𝐮𝐫 𝐤𝐮𝐛𝐞𝐫𝐧𝐞𝐭𝐞𝐬 𝐝𝐞𝐩𝐥𝐨𝐲𝐦𝐞𝐧𝐭 𝐩𝐨𝐝𝐬 𝐚𝐧𝐝 𝐦𝐨𝐧𝐢𝐭𝐨𝐫𝐢𝐧𝐠 𝐨𝐟 𝐢𝐧𝐟𝐫𝐚𝐬𝐭𝐫𝐮𝐜𝐭𝐮𝐫𝐞 𝐥𝐨𝐠 𝐛𝐲 𝐆𝐫𝐚𝐟𝐚𝐧𝐚 𝐋𝐨𝐤𝐢 𝐚𝐧𝐝 𝐏𝐫𝐨𝐦𝐭𝐚𝐢𝐥 𝐚𝐧𝐝 𝐌𝐞𝐭𝐫𝐢𝐜𝐬 𝐛𝐲 𝐏𝐫𝐨𝐦𝐞𝐭𝐡𝐞𝐮𝐬 𝐌𝐨𝐧𝐢𝐭𝐨𝐫𝐢𝐧𝐠 𝐓𝐨𝐨𝐥𝐧𝐠 𝐓𝐨𝐨𝐥

𝐄𝐊𝐒 𝐊𝐮𝐛𝐞𝐫𝐧𝐞𝐭𝐞𝐬 𝐭𝐨 𝐝𝐞𝐩𝐥𝐨𝐲 𝐉𝐞𝐧𝐤𝐢𝐧𝐬 𝐂𝐈/𝐂𝐃 𝐭𝐨𝐨𝐥 𝐮𝐬𝐢𝐧𝐠 𝐀𝐮𝐭𝐨𝐦𝐚𝐭𝐞𝐝 𝐰𝐚𝐲 𝐎𝐩𝐞𝐫𝐚𝐭𝐨𝐫, 𝐚𝐧𝐝 𝐦𝐚𝐧𝐚𝐠𝐞 𝐉𝐞𝐧𝐤𝐢𝐧𝐬 𝐏𝐢𝐩𝐞𝐥𝐢𝐧𝐞 𝐚𝐬 𝐂𝐨𝐝𝐞 𝐛𝐲 𝐉𝐞𝐧𝐤𝐢𝐧𝐬 𝐊𝐮𝐛𝐞𝐫𝐧𝐞𝐭𝐞𝐬 𝐂𝐑𝐃 𝐚𝐧𝐝 𝐀𝐩𝐩𝐥𝐢𝐜𝐚𝐭𝐢𝐨𝐧 𝐣𝐨𝐛𝐬 𝐥𝐚𝐮𝐧𝐜𝐡𝐞𝐬 𝐢𝐧 𝐝𝐲𝐧𝐚𝐦𝐢𝐜 𝐩𝐫𝐨𝐯𝐢𝐬𝐢𝐨𝐧𝐢𝐧𝐠 𝐧𝐨𝐝𝐞 𝐨𝐮𝐫 𝐤𝐮𝐛𝐞𝐫𝐧𝐞𝐭𝐞𝐬 𝐝𝐞𝐩𝐥𝐨𝐲𝐦𝐞𝐧𝐭 𝐩𝐨𝐝𝐬 𝐚𝐧𝐝 𝐦𝐨𝐧𝐢𝐭𝐨𝐫𝐢𝐧𝐠 𝐨𝐟 𝐢𝐧𝐟𝐫𝐚𝐬𝐭𝐫𝐮𝐜𝐭𝐮𝐫𝐞 𝐥𝐨𝐠 𝐛𝐲 𝐆𝐫𝐚𝐟𝐚𝐧𝐚 𝐋𝐨𝐤𝐢 𝐚𝐧𝐝 𝐏𝐫𝐨𝐦𝐭𝐚𝐢𝐥 𝐚𝐧𝐝 𝐌𝐞𝐭𝐫𝐢𝐜𝐬 𝐛𝐲 𝐏𝐫𝐨𝐦𝐞𝐭𝐡𝐞𝐮𝐬 𝐌𝐨𝐧𝐢𝐭𝐨𝐫𝐢𝐧𝐠 𝐓𝐨𝐨𝐥𝐧𝐠 𝐓𝐨𝐨𝐥

Cloud Setup

  1. AWS cloud https://aws.amazon.com/
  2. New User / Account: IAM user -> power : policy: admin access
  3. password (key) access / secret key

CLI setup

  1. Aws CLI download for Windows:
https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html

2. login in CLI  #aws configure

3. eksctl tool: To install Kubernetes

https://github.com/eksctl-io/eksctl/releases/tag/v0.161.0

4: store files in this Folder

cd C:\Program Files\Kubernetes

💠PRACTICAL — Launch EKS Cluster

3 ways by which we can use AWS EKS service

  • WebUI

3rd Party tool🡪 Terraform

3rd Party tool🡪 eksctl tool, specifically for EKS service of AWS This tool was developed by Weaveworks.

  • Now create a user by using IAM.

An access key and secret key will be created. Now use this access key and secret key to configure AWS.

After configuring AWS, we will install eksctl

Now go to releases🡪 latest🡪eksctl_windows_amd64.zip

After downloading create a folder say aws ekstools and extract downloaded data into that folder.

Now extract that into the folder

Now go to environmental variables

Now check

Installation Succcesfull🎊

💠Helm Installation

Visit the official Helm Release page on GitHub.

https://github.com/helm/helm/releases

2. Locate the Windows amd64 download link from the Installation platform list and select it to download.

3. Extract the zip file. You will have these files inside the extracted folder.

4. Create a folder called kubernetes on the Desktop and copy the extracted helm.exe to that folder.

5. Now right-click on this file, More Options>Properties. Then copy the Location of this file.

6. Now search for environment in the search box and open the first result.

7. Now click on Environment Variables Again

8. Select the Path variable and click on EDIT.

9. Now click on NEW and paste the Location of helm.exe

10. Click OK>OK>Apply.

11. Now open the command prompt and you can run

$ helm

Installation of the helm is successfully done.🤩

💠Kubectl Installation

  1. Download the kubectl executable from below link

https://dl.k8s.io/release/v1.28.2/bin/windows/amd64/kubectl.exe

  1. Create a folder on your desktop called Kubernetes and move the download file to this folder.

Now right-click on this file, More Options>Properties. Then copy the Location of this file.

Now search for the environment in the search box

Open the first result

Now click on Environment Variables Again

  1. Select the Path variable and click on EDIT.
  1. Now click on NEW and paste the Location of kubectl.exe

Click OK>OK>Apply.

Now open the command prompt and you can run

$ kubectl version

The installation of Kubectl is successful.🤩

Now let’s do practical

For reference visit the GitHub

devops_workshop_eks_jenkins_loki_operator

Install Kubernetes over AWS cloud

eksctl create cluster - name mycluster1 - region=us-east-1

This command creates an Amazon Elastic Kubernetes Service (Amazon EKS) cluster named “mycluster1” in the “us-east-1” AWS region.

kubectl create namespace lwns

This command creates a new Kubernetes namespace named “lwns.”

helm repo add jenkins https://raw.githubusercontent.com/jenkinsci/kubernetes-operator/master/chart

This command adds a Helm repository named “Jenkins” to your Helm configuration. The repository is located at the specified URL, which contains Helm charts for deploying Jenkins using the Kubernetes Operator.

If this command does not work on your computer due to network restrictions or firewall issues, you may need to use a VPN to access the repository. Follow the steps below to use a VPN:

Download VPN from Here:

https://drive.google.com/file/d/1wyyPF_r9jRGwn5vK-184blDhwz1deRJu/view?usp=sharing

  • Search Australia and start a VPN.
  • Once connected to the VPN, retry the `helm repo add` command.
helm install my-jenkins-operator jenkins/jenkins-operator -n lwns - set jenkins.enabled=false

This command uses Helm to install a Kubernetes application named “my-jenkins-operator” from the “jenkins/jenkins-operator” Helm chart. The application is deployed in the “lwns” namespace.

Curl https://raw.githubusercontent.com/dilip8700/devops_workshop_eks_jenkins_loki_operator/main/jenkins_instance.yml >> jenkins_instance.yml

Use this command to create a Kubernetes YAML file.

kubectl apply -f jenkins_instance.yml
kubectl - namespace lwns get secret jenkins-operator-credentials-example -o 'jsonpath={.data.user}' | base64 -d

This is used to retrieve sensitive information such as usernames stored as secrets in a Kubernetes cluster.

kubectl - namespace lwns get secret jenkins-operator-credentials-example -o 'jsonpath={.data.password}' | base64 -d

This is used to retrieve sensitive information such as passwords stored as secrets in a Kubernetes cluster.

kubectl - namespace lwns port-forward jenkins-example 8080:8080

This command sets up a port-forwarding connection in the “lwns” namespace, forwarding local port 8080 to port 8080 on the Kubernetes pod named “Jenkins-example.” This enables you to access the Jenkins web interface running inside the “Jenkins-example” pod through your local machine’s web browser by opening http://localhost:8080.

helm repo add grafana https://grafana.github.io/helm-charts
  • This will add a repo in the helm chat for Grafana.
helm repo update

It will update the helm repo

helm.exe upgrade - install loki grafana/loki-stack - set grafana.enabled=true,prometheus.enabled=true,prometheus.alertmanager.persistentVolume.enabled=false,prometheus.server.persistentVolume.enabled=false

Use this command to install Loki, Grafana, and Prometheus.

kubectl patch svc loki-grafana -p '{"spec": {"type": "LoadBalancer"}}'

This command modifies a Kubernetes service named “loki-grafana” by changing its type to “LoadBalancer.” The LoadBalancer type allows external access to the service, typically by assigning it a public IP address for internet accessibility.

kubectl get svc loki-grafana -o jsonpath='{.status.loadBalancer.ingress[0].hostname}'

This command gives you the hostname of the load balancer which you can use to connect.

AWS Loadbalancer takes 2 min to set up so wait for 2 minutes.

kubectl get secret loki-grafana -o go-template='{{range $k,$v := .data}}{{printf "%s: " $k}}{{if not $v}}{{$v}}{{else}}{{$v | base64decode}}{{end}}{{"\n"}}{{end}}'

This command will give you a Grafana username and password.

Comments

Popular posts from this blog

how to deploy WordPress applications on an ec2 instance with Aws RDS

Adding Fun and Whimsy to Your Linux Terminal with Figlet, Cowsay, Nyancat, and More!

Leveraging Jenkins for Industry Use Cases: A Comprehensive Guide