Annotations
- Annotations are also key value pairs but meant for usage with additional or external tools by attaching metadata Refer Here
- Well known labels and annotations Refer Here
Health Checks
- Refer Here for health checkness
- We have 3 major health probes
- Startup
- Readiness
- Liveness
- We can perform these checks by
- running commands inside container
- Sending a tcp request
- sending a http request
- sending a grpc request
| Probe | What it checks | What happens if it fails |
|---|---|---|
| startup | checks if the container is started successfully | container will be killed and restarted |
| Liveness | Is the container live | container will be killed and restarted |
| Readiness | Is container ready to serve traffic | Pod will be served by service |
- First probe is startup and till it suceeds no further checks are done
Deployments
- Deployments
- Lets write a k8s manifest for Deploying applications
-
Deployment create Replicaset which creates pods Refer Here for changes
- look out for
kubectl rollout --help - Lets rollout a new version
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: web-deploy
annotations:
kubernetes.io/change-cause: v2 deployment to slim version
spec:
minReadySeconds: 5
replicas: 4
selector:
matchExpressions:
- key: app
operator: In
values:
- web
- nginx
- apache
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: web
image: httpd:2-alpine
resources:
requests:
cpu: 100m
memory: 64Mi
limits:
cpu: 500m
memory: 256Mi
ports:
- name: http
protocol: TCP
containerPort: 80
startupProbe:
initialDelaySeconds: 1
periodSeconds: 2
successThreshold: 1
failureThreshold: 2
tcpSocket:
port: 80
livenessProbe:
initialDelaySeconds: 2
periodSeconds: 5
successThreshold: 1
failureThreshold: 2
httpGet:
path: /
port: 80
readinessProbe:
initialDelaySeconds: 2
periodSeconds: 5
successThreshold: 1
failureThreshold: 2
timeoutSeconds: 5
httpGet:
path: /
port: 80
