Skip to content

Instantly share code, notes, and snippets.

@nbrandaleone
Last active January 6, 2020 18:55
Show Gist options
  • Select an option

  • Save nbrandaleone/ce81036c45633d09a832b2c9e144411f to your computer and use it in GitHub Desktop.

Select an option

Save nbrandaleone/ce81036c45633d09a832b2c9e144411f to your computer and use it in GitHub Desktop.
[Start a pod using kubectl run] #kubernetes

https://kubernetes.io/docs/reference/kubectl/conventions/

Version 1.4 1.3 1.2 1.1
Pod --restart=Never --restart=Never --generator=run-pod/v1 --restart=OnFailure OR --restart=Never
Replication Controller --generator=run/v1 --generator=run/v1 --generator=run/v1 --restart=Always
Deployment --restart=Always --restart=Always --restart=Always N/A
Job --restart=OnFailure --restart=OnFailure --restart=OnFailure OR --restart=Never N/A
Cron Job --schedule=

Note: These flags use a default generator only when you have not specified any flag. This means that when you combine --generator with other flags the generator that you specified later does not change. For example, in a cluster v1.4, if you initially specify --restart=Always, a Deployment is created; if you later specify --restart=Always and --generator=run/v1, a Replication Controller is created. This enables you to pin to a specific behavior with the generator, even when the default generator is changed later.

kubectl run tmp-shell-host
--generator=run-pod/v1 --rm -it --overrides='{"spec": {"hostNetwork": true}}' \ --image nicolaka/netshoot -- /bin/bash

kubectl run tmp-shell-no-host-net
--generator=run-pod/v1 --rm -it --image nicolaka/netshoot -- /bin/bash

kubectl --namespace kube-system scale --current-replicas=2 --replicas=10 deployment/coredns

kubectl --namespace kube-system edit deployment/coredns ... spec: affinity: nodeAffinity: requiredDuringSchedulingIgnoredDuringExecution: nodeSelectorTerms:

  • matchExpressions:
  • key: beta.kubernetes.io/os operator: In values:
  • linux
  • key: beta.kubernetes.io/arch operator: In values:
  • amd64
  • key: nodegroup operator: In values:
  • stable containers:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment