0% found this document useful (0 votes)
9 views

kubernetes project 3 1

The document outlines a Kubernetes project focused on application lifecycle management, detailing various labs that cover rolling updates, deployment strategies, rollbacks, scaling, job creation, config maps, secrets, and environment variable configuration. Each lab provides step-by-step commands and YAML configurations for implementing the tasks. The project aims to enhance understanding and practical skills in managing Kubernetes deployments and resources.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

kubernetes project 3 1

The document outlines a Kubernetes project focused on application lifecycle management, detailing various labs that cover rolling updates, deployment strategies, rollbacks, scaling, job creation, config maps, secrets, and environment variable configuration. Each lab provides step-by-step commands and YAML configurations for implementing the tasks. The project aims to enhance understanding and practical skills in managing Kubernetes deployments and resources.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Kubernetes Project 3 prepared by H.V.

Kalyan Sampath (Foxtel) (2182940)

PROJECT TITLE

APPLICATION LIFESTYLE MANAGEMENT

LAB 1

Perform roling updates on a deployment

• First, apply the deployment YAML file from the URL.

Kubectl apply – f http://raw.githubusercontent.com/David-


VTUK/CKAFSauleYami/master/nginx-ave-and-deployment.yaml

• For Checking = kubectl get deployments


• Performing rolling update

Kubectl set image deployment/nginx-deployment nginx=nginx:1.7.11 –record=true

• Check for status

Kubectl rollout status deployment/nginx-deployment

These steps will perform a rolling update on your deployment, updating the nginx container
to version 1.7.11,

LAB 2

We need to update strategy in the yaml file to following changes and deploy it.

Updated yaml file:

apiVersion: apps/v1

kind: Deployment

metadata:

name: nginx-deployment

labels:

app: nginx

spec:
replicas: 3

selector:

matchLabels:

app: nginx

strategy:

type: RollingUpdate

rollingUpdate:

maxSurge: 1

maxUnavailable: 1

template:

metadata:

labels:

app: nginx

spec:

containers:

- Name: nginx

Image: nginx:1.7.9

Ports:

- containerPort: 80
• For applying the changes

Kubectl apply -f nginx-ave-and-deployment.yaml

• Verifying

Kubectl describe deployment nginx-deployment

LAB 3
Perform a rollback on a deployment Rollback the changes that were implemented
from Lab 1

• Checking rollback History

Kubectl rollout history deployment/nginx-deployment

• Rollback

Kubectl rollout undo deployment/nginx-deployment

• Checking

Kubectl rollout status deployment/nginx-deployment

LAB 4

Scale a deployment Scale the deployment from the first lab exercise to leverage &
pods

• Command to scale the deployment to 6 replicas :

Kubectl scale deployment <deployment-name> --replicas=6

• Checking deployment

Kubectl get deployment nginx-deployment

• Verifying

Kubectl get pods

LAB 5

Create and run a Job

• Create job yaml file

apiVersion: batch/v1

kind: Job

metadata:

name: pi-calculator
spec:

template:

spec:

containers:

- Name: pi-calculator

Image: perl

Command: [“perl”, “-Mbignum=bpi”, “-wle”, “print bpi(2000)”]

restartPolicy: Never

backoffLimit: 4

• Apply the Job Manifest

Kubectl apply -f pi-calculator-job.yaml

• View the Logs

Kubectl get pods –selector=job-name=pi-calculator

Kubectl logs pi-calculator

LAB 6

Create and use a Config Map

• Create text files

Echo “database host” > /tmp/db_h.txt

Echo “database_port” > /tmp/db_p.txt

Kubectl create configmap db-connection –from-file=/tmp/db_h.txt –from-


file=/tmp/db_p.txt

Kubectl get configmap db-connection -o yaml

• Create pod yaml

apiVersion: v1
kind: Pod

metadata:

name: nginx-pod

spec:

containers:

- Name: nginx

Image: nginx

Env:

- Name: db_h

valueFrom:

configMapKeyRef:

name: db-connection

key: db_h.txt

- Name: db_p

valueFrom:

configMapKeyRef:

name: db-connection

key: db_p.txt

restartPolicy: Never

• Apply pod yaml

Kubectl apply -f nginx-pod.yaml

• Verification

Kubectl get pods

Kubectl exec -it nginx-pod -- /bin/bash

Echo $db_h

Echo $db_p
• Output

Database host

Database_port

LAB 7

Create and use Secrets

• Create secrets

Kubectl create secret generic db-credentials \

--from-literal=db-username=dbuser \

--from-literal=db-password=dbpassword

• Verification

Kubectl get secrets db-credentials -o yaml

• Pod creation for using secrets

apiVersion: v1

kind: Pod

metadata:

name: secret-pod

spec:

containers:

- Name: app-container

Image: nginx

Env:

- Name: DB_USERNAME

valueFrom:

secretKeyRef:

name: db-credentials
key: db-username

- Name: DB_PASSWORD

valueFrom:

secretKeyRef:

name: db-credentials

key: db-password

restartPolicy: Never

• Apply pod

Kubectl apply -f secret-pod.yaml

Kubectl exec -it secret-pod -- /bin/bash

Echo $DB_USERNAME

Echo $DB_PASSWORD

LAB 8

Configure a pod with specific environment variables

• Creating pod yaml

apiVersion: v1

kind: Pod

metadata:

name: env-pod

spec:

containers:

- Name: app-container

Image: nginx

Env:

- Name: Variable1
Value: “somevalue”

- Name: Variable2

Value: “someothervalue”

restartPolicy: Never

• Applying

Kubectl apply -f env-pod.yaml

• Verifying

Kubectl get pods

Kubectl exec -it env-pod -- /bin/bash

Echo $Variable1

Echo $Variable2

Output:

Somevalue

Someothervalue

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy