Skip to content

Instantly share code, notes, and snippets.

@rafi
Created August 4, 2020 13:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rafi/e3ae759a8c1c28aa0825f3569005ead0 to your computer and use it in GitHub Desktop.
Save rafi/e3ae759a8c1c28aa0825f3569005ead0 to your computer and use it in GitHub Desktop.
Workshop material for K8s 101 hands-on.

Kubernetes 101: Hands-on

brew install kubernetes-cli minikube

minikube start # --memory=8192 --cpus=4
kubectl get -A deployment
kubectl get -A pod -w

Minikube Addons

minikube addons list
minikube addons enable metrics-server
minikube addons enable dashboard

kubectl proxy
open http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy

kuebctl top node
kuebctl top pod

Create Deployment

Let's create a deployment!

Copy/paste into hello-node.yaml:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: hello-node
  namespace: default
  labels:
    app: hello-node
spec:
  replicas: 1
  selector:
    matchLabels:
      app: hello-node
  template:
    metadata:
      labels:
        app: hello-node
    spec:
      containers:
      - image: k8s.gcr.io/echoserver:1.4
        name: echoserver

Watch pods: kubectl get po -w

Now deploy to cluster:

kubectl apply -f hello-node.yaml

kubectl get all -A

Scale up/down:

kubectl scale deploy/hello-node --replicas=5

kubectl scale deploy/hello-node --replicas=1

kubectl Cheat-sheet

kubectl get namespaces
kubectl get deploy
kubectl get -n ingress-nginx deploy
kubectl get -n kube-system deploy
kubectl get --all-namespaces deploy
kubectl get pods -w
kubectl get pods -o wide
kubectl get events

kubectl create -f foobar.yml
kubectl explain services
kubectl get pods,svc,deploy
kubectl describe deploy push-service
kubectl delete deploy push-service
kubectl cluster-info
kubectl api-resources
kubectl top node
kubectl top pods
kubectl logs -f deploy/ghost
kubectl logs -f deploy/ghost -c ghost
kubectl logs --previous ghost-97d8bf485-p25r2
kubectl exec -it ghost-97d8bf485-p25r2 -- tail /var/log/apt/history.log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment