Pod

PODS

  • is an abstraction of a server

    • can run multiple container within single namespace, exposed by single IP

  • only started through Deployment

Init container is an additional container in POD that completes a task before the regular container is started.

only if (init_container.started()) {
    regular_contaner.start();
}

Jobs

kubectl create cronjob sleep-job --image=busybox --schedule"*/2 * * * *" --dry-run -o yaml > job.yaml

Namespace

Namespace implements kernel level resource isolation. Kubernetes supports multiple virtual clusters backed by the same physical cluster. These virtual clusters are called namespaces. Read more about namespaces at Kubernetes reference

Deployment

  • replicas - how many copies

  • strategy - how Pods should be updated

    • recreate - all pods killed and new created => temporary unavailability

    • 👍 rollingUpdate

  • selector - how labels are matched agains the Pod

  • template - Pod specification to create it

kubectl run httpd-run --image=httpd --replicas
kubectl get deployments.apps [name]
kubectl get rs
kubectl scale deployments/[DEPLOYMENT_NAME] --replicas=4

labels / selectors / annotations

  • label -> key/value pair to identify K8s resource

  • annotation is used to provide additional metadata in object (licenses, maintainer...)

ℹī¸ 👎 kubectl label deployment [name] [key]=[value] ℹī¸ kubectl get deployments.apps --show-labels ℹī¸ kubectl get deployments.apps --selector [key]=[value]

History

kubectl rollout history deployment [name] kubectl rollout undo deployment [name] --to-revision=1

Patterns

  • Ambassador

  • Adapter

Last updated