guest@backslash:~/posts/containers/k8s-operations$

k8s operations

~1 min

k8s operations

Everyday kubectl commands for a running cluster: shell into a pod, scale, export, stop and debug.

Interactive shell

sh
kubectl exec -it <pod-name> -- bash

Scale

sh
kubectl scale deployment nginx-test --replicas=3

Export

sh
kubectl get pod <pod-name> -o yaml > pod-config.yaml

Stop pod

sh
kubectl delete pod <pod-name>

Create a debug pod

yaml
apiVersion: v1
kind: Pod
metadata:
  name: toolbelt
  labels:
    purpose: debug
spec:
  containers:
    - name: debian-tooling
      image: debian:latest
      command: ["/bin/bash", "-c", "--"]
      args: ["while true; do sleep 30; done;"]
      volumeMounts:
        - name: app-data
          mountPath: /mnt/data
  volumes:
    - name: app-data
      persistentVolumeClaim:
        claimName: app-data

BACKSLASH(1)                  User Commands

NAME
       backslash - keyboard navigation

KEYS
       j / k      scroll down / up
       n / p      next / previous post
       gg / G     top / bottom of the page
       /          filter posts
       ?          this help
       Esc        close