Skip to content

Kubernetes: Nodes, scheduling & access control

11 Kubernetes commands: Nodes, scheduling & access control. Click a command to see what each part does.

Index
11 items
Click a command to see what each part does.

Nodes, scheduling & access control11

  • kubectl cordon <node>Stop new pods landing on a node

    What each part does

    1. cordonmark unschedulable; running pods stay (drain to evict them, uncordon to undo)
  • kubectl taint nodes <node> <key>=<value>:NoSchedule; kubectl taint nodes <node> <key>:NoSchedule-Taint a node / remove a taint

    What each part does

    1. <key>=<value>:NoScheduleonly pods tolerating this taint can schedule here (NoExecute also evicts)
    2. <key>:NoSchedule-trailing minus removes it
  • kubectl label node <node> <key>=<value>Label a node

    What each part does

    1. label nodeused by nodeSelector / affinity, e.g. disktype=ssd
  • kubectl get nodes --show-labels; kubectl describe node <node> | grep -A3 TaintsNode labels and taints

    What each part does

    1. --show-labelsall labels (zone, instance type, OS, arch)
    2. grep -A3 Taintstaints on the node
  • kubectl describe node <node> | grep -A8 'Allocated resources'How full is a node? (requests vs capacity)

    What each part does

    1. Allocated resourcessum of CPU/memory requests and limits vs allocatable: why pods are Pending even if usage is low
  • kubectl auth can-i <verb> <resource> -n <namespace> --as=<user-or-sa>Can I (or someone) do this?

    What each part does

    1. auth can-iyes/no for an action, e.g. can-i delete pods
    2. --as=<user-or-sa>impersonate, e.g. system:serviceaccount:<ns>:<sa>
  • kubectl auth can-i --list -n <namespace>Everything I am allowed to do

    What each part does

    1. --listall verbs per resource for the current user in that namespace
  • kubectl auth whoamiWho am I logged in as?

    What each part does

    1. auth whoamiuser name and groups the API server sees for your credentials
  • kubectl create token <serviceaccount> -n <namespace> --duration=1hCreate a short-lived token for a service account

    What each part does

    1. create tokenrequest a bound token (no long-lived secret)
    2. --duration=1hlifetime
  • kubectl get csr; kubectl certificate approve <csr>Approve a certificate signing requestCaution

    What each part does

    1. get csrpending node / user certificate requests
    2. certificate approvesign it
  • kubectl versionClient and server versions

    What each part does

    1. kubectl versionclient and API server versions; keep kubectl within one minor version of the server

My DevOps Playbook by Angelo John Calleja

New runbook

GitHub not connected

Saving is handled by the site: the GitHub token is stored in Cloudflare, not in your browser. Enter the editor password (the EDITOR_PASSWORD secret) to unlock saving in this browser.

Saving commits to gelogrammer/My_DevOps_Playbook. Create a fine-grained token with access to only this repo andContents: Read and write, then paste it here. It is stored only in this browser.

src/content/docs/…