[CKA] 006. Application Lifecycle Management
Rolling Update, Commands and Arguments, Env, ConfigMap, Secrets, Multi-Container Pod, HPA, VPA

- hpyYh
- 2 min read

Rolling Update
- update application without downtime
- default deployment strategy
- enable rollback
kubectl rollout undo deployment [deployment-name]
Commands and Arguments
- specify commands and arguments for containers
spec:
containers:
- command: ["./start.sh"]
args: ["--config", "/etc/myapp/config.yaml"]
Env
spec:
containers:
- env:
- name: ENV_VAR_NAME
value: "value1"
ConfigMap
- store configuration data
apiVersion: v1
kind: ConfigMap
metadata:
name: my-configmap
data:
CONFIG_KEY: "config_value"
spec:
containers:
- envFrom:
- configMapRef:
name: my-configmap
Secrets
- store sensitive data
apiVersion: v1 kind: Secret metadata: name: my-secret data: SECRET: "c2VjcmV0X3ZhbHVl" # base64 encoded - how to base64 encode
echo -n 'secret_value' c2VjcmV0X3ZhbHVl - how to apply
spec: containers: - envFrom: - secretRef: name: my-secret
Muntli-Container Pod
- co-located containers
apiVersion: v1 kind: Pod metadata: name: multi-container-pod spec: containers: - name: app-container image: myapp:latest - name: sidecar-container image: log-collector:latest - init containers
apiVersion: v1 kind: Pod metadata: name: multi-container-pod spec: containers: - name: app-container image: myapp:latest initContainers: - name: init-app-container image: myapp:latest - sidecar containers
apiVersion: v1 kind: Pod metadata: name: multi-container-pod spec: containers: - name: app-container image: myapp:latest initContainers: - name: init-app-container image: myapp:latest restartPolicy: Always
HPA
- automatically scale the number of pods
apiVersion: autoscaling/v2 kind: HorizontalPodAutoscaler metadata: name: myapp-hpa spec: scaleTargetRef: apiVersion: apps/v1 kind: Deployment name: myapp-deployment minReplicas: 2 maxReplicas: 10 metrics: - type: Resource resource: name: cpu target: type: Utilization averageUtilization: 50
VPA
- pre-install before VPA start
kubectl apply -f https://raw.githubusercontent.com/kubernetes/autoscaler/vpa-release-1.0/vertical-pod-autoscaler/deploy/vpa-v1-crd-gen.yaml
kubectl apply -f https://raw.githubusercontent.com/kubernetes/autoscaler/vpa-release-1.0/vertical-pod-autoscaler/deploy/vpa-rbac.yaml
- any container in the pod can be configured
apiVersion: autoscaling.k8s.io/v1
kind: VerticalPodAutoscaler
metadata:
name: my-app-vpa
spec:
targetRef:
apiVersion: "apps/v1"
kind: Deployment
name: my-app
updatePolicy:
updateMode: "Recreate" # Off, Initial, Recreate, InPlaceOrRecreate
resourcePolicy:
containerPolicies:
- containerName: "application"
minAllowed:
cpu: 100m
memory: 128Mi
maxAllowed:
cpu: 2
memory: 2Gi
controlledResources:
- cpu
- memory
controlledValues: RequestsAndLimits
- tags :
- Cka