0% found this document useful (0 votes)
43 views4 pages

7 May Project2

The document discusses setting up Kubernetes and installing related tools on Ubuntu systems. It describes downloading and installing Terraform, Docker, kubeadm, kubectl, kubelet and configuring the Kubernetes master and worker nodes. It also discusses deploying a sample Jenkins pipeline that builds a Docker image and deploys it to Kubernetes.

Uploaded by

suresh chaudhary
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views4 pages

7 May Project2

The document discusses setting up Kubernetes and installing related tools on Ubuntu systems. It describes downloading and installing Terraform, Docker, kubeadm, kubectl, kubelet and configuring the Kubernetes master and worker nodes. It also discusses deploying a sample Jenkins pipeline that builds a Docker image and deploys it to Kubernetes.

Uploaded by

suresh chaudhary
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

(terrafrom installation)

[Link]

github link:

[Link]
-------------------------------------------------------
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
}
}
}

provider "aws" {
region = "us-east-2"
access_key = ""
secret_key = ""
}

resource "aws_instance" "example" {


ami = "ami-0283a57753b18025b"
count = 2
instance_type = "[Link]"
key_name = "hrithik"
tags = {
Name = "kub-s"
}
}
resource "aws_instance" "main" {
ami = "ami-0283a57753b18025b"
count = 1
instance_type = "[Link]"
key_name = "hrithik"
tags = {
Name = "kub1-master"
}
}
-------------------------------------------------------------------------
(Kubernetes cluster)
(On master node and worker node both)

(sudo nano [Link])


sudo apt update -y
sudo apt install [Link] -y

sudo systemctl start docker


sudo systemctl enable docker

sudo curl -fsSLo /usr/share/keyrings/[Link]


[Link]

echo "deb [signed-by=/usr/share/keyrings/[Link]]


[Link] kubernetes-xenial main" | sudo tee
/etc/apt/[Link].d/[Link]

sudo apt update -y


sudo apt install kubeadm=1.20.0-00 kubectl=1.20.0-00 kubelet=1.20.0-00 -y
----------------------------------------------------------------------------
sudo bash [Link]
-------------------------------------------------------------------------------

(master node)
sudo su
kubeadm init (this will generate the join token command which needs to be
pasted on the worker nodes)

(Master node)

mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/[Link] $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
-----------------------------------------------------------------------------------
--------------------
(CNI)
kubectl apply -f
[Link]
[Link]

kubectl get nodes


--------------------------------------------------------------
(Jenkins installation)

[Link]

-----------------------------------------------------------------------------------
---------------
(script for jenkins)

pipeline{
agent none
environment {
DOCKERHUB_CREDENTIALS=credentials('e814f99d-8cc0-425d-840e-0c10c489f570')
}

stages{
stage('Hello'){
agent{
label 'Kub-master'
}
steps{
echo 'Hello World'
}
}
stage('git'){
agent{
label 'Kub-master'
}

steps{
git'[Link]
}
}
stage('docker') {
agent {
label 'Kub-master'
}

steps {

sh 'sudo docker build /home/ubuntu/jenkins/workspace/pipeline -t


ritikdevoper123/demo1'
sh 'sudo echo $DOCKERHUB_CREDENTIALS_PSW | sudo docker login -u
$DOCKERHUB_CREDENTIALS_USR --password-stdin'
sh 'sudo docker push ritikdevoper123/demo1'

}
}
stage('Kuberneets') {
agent {
label 'Kub-master'
}

steps {

sh 'sudo kubectl create -f [Link]'


sh 'sudo kubectl create -f [Link]'
}
}

}
}

1 clear
2 sudo apt update
3 sudo apt [Link] -y
4 sudo apt install [Link] -y
5 clear
6 sudo systemctl start docker
7 sudo systemctl enable docker
8 sudo systemctl status docker
9 sudo curl -fsSLo /usr/share/keyrings/[Link]
[Link]
10 echo "deb [signed-by=/usr/share/keyrings/[Link]]
[Link] kubernetes-xenial main" | sudo tee
/etc/apt/[Link].d/[Link]
11 sudo apt update -y
12 sudo apt-get update
13 sudo apt-get install -y ca-certificates curl
14 sudo apt-get install -y apt-transport-https
15 curl -fsSL [Link] | sudo gpg
--dearmor -o /etc/apt/keyrings/[Link]
16 echo "deb [signed-by=/etc/apt/keyrings/[Link]]
[Link] kubernetes-xenial main" | sudo tee
/etc/apt/[Link].d/[Link]
17 sudo apt update
18 sudo apt install kubeadm=1.20.0-00 kubectl=1.20.0-00 kubelet=1.20.0-00 -y

You might also like