Real application industry-based project on DevOps๐ŸŒป

Sachin Singh
7 min readOct 10, 2023

--

๐Ÿ”ฐ๐๐ซ๐จ๐ฃ๐ž๐œ๐ญ ๐“๐ข๐ญ๐ฅ๐ž :
๐„๐Š๐’ ๐Š๐ฎ๐›๐ž๐ซ๐ง๐ž๐ญ๐ž๐ฌ ๐ญ๐จ ๐๐ž๐ฉ๐ฅ๐จ๐ฒ ๐‰๐ž๐ง๐ค๐ข๐ง๐ฌ ๐‚๐ˆ/๐‚๐ƒ ๐ญ๐จ๐จ๐ฅ ๐ฎ๐ฌ๐ข๐ง๐  ๐€๐ฎ๐ญ๐จ๐ฆ๐š๐ญ๐ž๐ ๐ฐ๐š๐ฒ ๐Ž๐ฉ๐ž๐ซ๐š๐ญ๐จ๐ซ, ๐š๐ง๐ ๐ฆ๐š๐ง๐š๐ ๐ž ๐‰๐ž๐ง๐ค๐ข๐ง๐ฌ ๐๐ข๐ฉ๐ž๐ฅ๐ข๐ง๐ž ๐š๐ฌ ๐‚๐จ๐๐ž ๐›๐ฒ ๐‰๐ž๐ง๐ค๐ข๐ง๐ฌ ๐Š๐ฎ๐›๐ž๐ซ๐ง๐ž๐ญ๐ž๐ฌ ๐‚๐‘๐ƒ ๐š๐ง๐ ๐€๐ฉ๐ฉ๐ฅ๐ข๐œ๐š๐ญ๐ข๐จ๐ง ๐ฃ๐จ๐›๐ฌ ๐ฅ๐š๐ฎ๐ง๐œ๐ก๐ž๐ฌ ๐ข๐ง ๐๐ฒ๐ง๐š๐ฆ๐ข๐œ ๐ฉ๐ซ๐จ๐ฏ๐ข๐ฌ๐ข๐จ๐ง๐ข๐ง๐  ๐ง๐จ๐๐ž ๐จ๐ฎ๐ซ ๐ค๐ฎ๐›๐ž๐ซ๐ง๐ž๐ญ๐ž๐ฌ ๐๐ž๐ฉ๐ฅ๐จ๐ฒ๐ฆ๐ž๐ง๐ญ ๐ฉ๐จ๐๐ฌ ๐š๐ง๐ ๐ฆ๐จ๐ง๐ข๐ญ๐จ๐ซ๐ข๐ง๐  ๐จ๐Ÿ ๐ข๐ง๐Ÿ๐ซ๐š๐ฌ๐ญ๐ซ๐ฎ๐œ๐ญ๐ฎ๐ซ๐ž ๐ฅ๐จ๐  ๐›๐ฒ ๐†๐ซ๐š๐Ÿ๐š๐ง๐š ๐‹๐จ๐ค๐ข ๐š๐ง๐ ๐๐ซ๐จ๐ฆ๐ญ๐š๐ข๐ฅ ๐š๐ง๐ ๐Œ๐ž๐ญ๐ซ๐ข๐œ๐ฌ ๐›๐ฒ ๐๐ซ๐จ๐ฆ๐ž๐ญ๐ก๐ž๐ฎ๐ฌ ๐Œ๐จ๐ง๐ข๐ญ๐จ๐ซ๐ข๐ง๐  ๐“๐จ๐จ๐ฅ๐ง๐  ๐“๐จ๐จ๐ฅ

Letโ€™s start๐ŸŒ๏ธโ€โ™‚๏ธ

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 awsekstools 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.

๐Ÿ”ฅ Project Done ๐ŸŒŸ

๐Ÿ”ฐ Check out my Video on LinkedIn for the interesting performance on this project๐Ÿ”ฅ

Visit on Linkedihttps://www.linkedin.com/posts/sa-chin_devops-project-kubernetes-activity-7117743125770502144--A5A?utm_source=share&utm_medium=member_androidn

I really hope you liked my article and found it helpful. โ˜บ๏ธ

If this project was helpful, please do follow and click the clap ๐Ÿ‘ button below to show your support ๐Ÿ˜„

_Thank you for reading๐Ÿ’š

Follow for more content๐Ÿค

Linkedin , GitHub

keep learning keep sharing

stay tuned๐Ÿ””

--

--