Skip to content

Instantly share code, notes, and snippets.

@eh-am
Last active October 7, 2019 22:15
Show Gist options
  • Save eh-am/67045adbd7f80eca598bfca440bc855b to your computer and use it in GitHub Desktop.
Save eh-am/67045adbd7f80eca598bfca440bc855b to your computer and use it in GitHub Desktop.
ckad preparation

pods

Check how many containers there are

kubectl get pods webapp -o json | jq '.["spec"]["containers"]' | jq length

check what are their names

kubectl get pods webapp -o json | jq '.["spec"]["containers"][]["image"]'

check status of container

container name agentx pod name webapp kubectl get pods webapp -o json | jq '.["status"]["containerStatuses"][] | select(.name == "agentx") | .["state"]'

minimum pod yaml

apiVersion: v1
kind: Pod
metadata:
  name: redis
spec:
  containers:
    - name: redis
      image: redis

create pod without deployment

kubectl run nginx --image=nginx --restart=Never

create namespace idempotently

kubectl create namespace my-ns --dry-run -o yaml | kubectl apply -f -

docker

Build, run image and don't store in local cache :DD bash -c 'docker run --rm -it $(docker build -q .)'

cmds/args

docker k8s
entrypoint command
cmd args

env from configmap

kind: Pod 
apiVersion: v1 
metadata:
  name: pod-env-var 
spec:
  containers:
    - name: env-var-configmap
      image: nginx:1.7.9 
      envFrom:
        - configMapRef:
            name: example-configmap

https://matthewpalmer.net/kubernetes-app-developer/articles/ultimate-configmap-guide-kubernetes.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment