0% found this document useful (0 votes)
40 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)
40 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
You are on page 1/ 4

(terrafrom installation)

https://developer.hashicorp.com/terraform/downloads

github link:

https://github.com/intellipaat2/website.git
-------------------------------------------------------
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 = "t2.medium"
key_name = "hrithik"
tags = {
Name = "kub-s"
}
}
resource "aws_instance" "main" {
ami = "ami-0283a57753b18025b"
count = 1
instance_type = "t2.medium"
key_name = "hrithik"
tags = {
Name = "kub1-master"
}
}
-------------------------------------------------------------------------
(Kubernetes cluster)
(On master node and worker node both)

(sudo nano install.sh)


sudo apt update -y
sudo apt install docker.io -y

sudo systemctl start docker


sudo systemctl enable docker

sudo curl -fsSLo /usr/share/keyrings/kubernetes-archive-keyring.gpg


https://packages.cloud.google.com/apt/doc/apt-key.gpg

echo "deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg]


https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee
/etc/apt/sources.list.d/kubernetes.list

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 install.sh
-------------------------------------------------------------------------------

(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/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
-----------------------------------------------------------------------------------
--------------------
(CNI)
kubectl apply -f
https://github.com/weaveworks/weave/releases/download/v2.8.1/weave-daemonset-
k8s.yaml

kubectl get nodes


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

https://www.jenkins.io/doc/book/installing/linux/#debianubuntu

-----------------------------------------------------------------------------------
---------------
(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'https://github.com/intellipaat2/website.git'
}
}
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 deploy.yml'


sh 'sudo kubectl create -f svc.yml'
}
}

}
}

1 clear
2 sudo apt update
3 sudo apt docker.io -y
4 sudo apt install docker.io -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/kubernetes-archive-keyring.gpg
https://packages.cloud.google.com/apt/doc/apt-key.gpg
10 echo "deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg]
https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee
/etc/apt/sources.list.d/kubernetes.list
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 https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo gpg
--dearmor -o /etc/apt/keyrings/kubernetes-archive-keyring.gpg
16 echo "deb [signed-by=/etc/apt/keyrings/kubernetes-archive-keyring.gpg]
https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee
/etc/apt/sources.list.d/kubernetes.list
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