kubernetes project 3 1
kubernetes project 3 1
PROJECT TITLE
LAB 1
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.
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
• Verifying
LAB 3
Perform a rollback on a deployment Rollback the changes that were implemented
from Lab 1
• Rollback
• Checking
LAB 4
Scale a deployment Scale the deployment from the first lab exercise to leverage &
pods
• Checking deployment
• Verifying
LAB 5
apiVersion: batch/v1
kind: Job
metadata:
name: pi-calculator
spec:
template:
spec:
containers:
- Name: pi-calculator
Image: perl
restartPolicy: Never
backoffLimit: 4
LAB 6
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
• Verification
Echo $db_h
Echo $db_p
• Output
Database host
Database_port
LAB 7
• Create secrets
--from-literal=db-username=dbuser \
--from-literal=db-password=dbpassword
• Verification
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
Echo $DB_USERNAME
Echo $DB_PASSWORD
LAB 8
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
• Verifying
Echo $Variable1
Echo $Variable2
Output:
Somevalue
Someothervalue