Deployment
- Deployment is a k8s object which can help in rolling out and rolling back updates
- Deployment controls replica set and replica set controls pods
- Lets create a manifest with some application deployment
- apply deployment and service. Access the application
- Lets get deployment information
- lets explore rollout command
- Refer Here for the manifests used to create revision 1
- Lets update the specs to change image from nginx to httpd Refer Here for changes in manifests
- Now to rollback to previous versions and update multiple versions
kubectl rollout undo
- The change-cause is showning as none which is not good. What can be done to have a valid change cause.
Annotations
- Refer Here for official docs
- Refer Here for the manifest with change cause annotation
- Refer Here for some annotations specific to azure aks ingress
- Refer Here for some annotations specific to aws eks ingress
DaemonSet
- DaemonSet is a controller which creates pod on every/selected nodes in k8s cluster
- Use cases:
- log collectors
- agents etc
- Refer Here for official docs
- Refer Here for the manifests for daemonsets
Scheduling Pods
-
possible ways
- Refer Here for assigning pods to nodes
Node Selectors
- We have added manifests with pod and service. Refer Here for manifests
-
Now lets select node by its name Refer Here
-
We have two nodes lets attach the following labels
- node 0:
purpose: poc - node 1:
purpose: testing
- node 0:
- When we have tried to create a pod with nodeSelector matching purpose: poc it was created on node 0 and when we created a pod with purpose: testing it created in node 1 and when created a pod with purpose: development it was in pending state (not created)
---
apiVersion: v1
kind: Pod
metadata:
name: nodeselector
labels:
app: nginx
purpose: nodeselector
spec:
nodeSelector:
purpose: testing
containers:
- name: jenkins
image: jenkins/jenkins:jdk11
ports:
- containerPort: 8080
Affinity/Anti Affinity Based
- Refer Here for official docs
Taints and Tolerations
- Refer Here for official docs
Headless Service
- Refer Here
- Headless service will not have cluster ip
- headless service spec
---
apiVersion: v1
kind: Service
metadata:
name: nginx-svc
spec:
selector:
app: nginx
type: ClusterIP
clusterIP: None
ports:
- name: nginx-svc
port: 80
targetPort: 80
protocol: TCP
- Headless service returns the ips of the pods returned by selector.
- This is used in stateful sets
