Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Story of a kubectl command

Story of a kubectl command

A lot goes on under the hood with every kubectl command that is run against a Kubernetes cluster. In this talk I spoke about the various steps involved.

Indradhanush Gupta

August 04, 2018
Tweet

More Decks by Indradhanush Gupta

Other Decks in Technology

Transcript

  1. The Deep-stack Kubernetes Experts Engineering services and products for Kubernetes,

    containers, process management and Linux user-space + kernel Blog: kinvolk.io/blog Github: kinvolk Twitter: kinvolkio Email: [email protected] Kinvolk
  2. What we will talk about? 1. What is Kubernetes? 2.

    What are the different components of Kubernetes? 3. What goes on behind the scenes of a kubectl command?
  3. What we will talk about? 1. What is Kubernetes? 2.

    What are the different components of Kubernetes? 3. What goes on behind the scenes of a kubectl command?
  4. What we will talk about? 1. What is Kubernetes? 2.

    What are the different components of Kubernetes? 3. What goes on behind the scenes of a kubectl command?
  5. What we will talk about? 1. What is Kubernetes? 2.

    What are the different components of Kubernetes? 3. What goes on behind the scenes of a kubectl command?
  6. Generators $ kubectl run nginx --image=nginx deployment.apps "nginx" created $

    kubectl run nginx --image=nginx --generator run-pod/v1 pod "nginx" created
  7. $ kubectl get pods -v 6 I0802 16:04:15.085956 9383 loader.go:357]

    Config loaded from file /home/dhanush/.kube/config
  8. $ kubectl get pods -v 6 I0802 16:04:15.085956 9383 loader.go:357]

    Config loaded from file /home/dhanush/.kube/config I0802 16:04:15.102658 9383 round_trippers.go:405] GET https://192.168.99.102:8443/api/v1/namespaces/default/pods?limit=50 0 200 OK in 9 milliseconds
  9. $ kubectl get pods -v 6 I0802 16:04:15.085956 9383 loader.go:357]

    Config loaded from file /home/dhanush/.kube/config I0802 16:04:15.102658 9383 round_trippers.go:405] GET https://192.168.99.102:8443/api/v1/namespaces/default/pods?limit=50 0 200 OK in 9 milliseconds I0802 16:04:15.109898 9383 round_trippers.go:405] GET https://192.168.99.102:8443/openapi/v2 200 OK in 6 milliseconds
  10. $ kubectl get pods -v 6 I0802 16:04:15.085956 9383 loader.go:357]

    Config loaded from file /home/dhanush/.kube/config I0802 16:04:15.102658 9383 round_trippers.go:405] GET https://192.168.99.102:8443/api/v1/namespaces/default/pods?limit=50 0 200 OK in 9 milliseconds I0802 16:04:15.109898 9383 round_trippers.go:405] GET https://192.168.99.102:8443/openapi/v2 200 OK in 6 milliseconds NAME READY STATUS RESTARTS AGE nginx-65899c769f-ndt2k 1/1 Running 0 9m
  11. Admission controllers ❏ Not a chain ❏ Modify or reject

    requests ❏ No role in read requests
  12. Scheduler ❏ Filters pods with empty NodeName ❏ Filter worker

    nodes based on resources and affinity ❏ Prioritizes filtered worker nodes ❏ Choose node with highest priority ❏ Creates Binding resource
  13. Kubelet ❏ Runs on worker node ❏ Manages Pods (containers,

    volume mounts etc) kubelet Worker 1 kubelet kubelet Worker 3 Worker 2
  14. Kubelet ❏ Queries API server for Bindings with matching NodeName

    ❏ Creates pods not already created on the node ❏ Launches pause container
  15. Pause container (almost there!) $ docker ps CONTAINER ID IMAGE

    COMMAND … fccc6b7a99a k8s.gcr.io/pause-amd64:3.1 "/pause" …
  16. Pause container ❏ Holds namespace for all containers of the

    pod ❏ All application container share the same namespaces ❏ Simplified intra pod networking ❏ Reap zombies if PID namespace sharing is enabled
  17. Summary ❏ Client side ❏ Validation and Authentication ❏ Server

    side ❏ Authentication ❏ Authorization ❏ Admission controllers ❏ Write to etcd!
  18. Summary ❏ Wait for Initializers ❏ Deployments controller ❏ Create

    ReplicaSet ❏ ReplicaSets controller ❏ Create Pod