Skip to content

Instantly share code, notes, and snippets.

@lalitkale
Last active July 13, 2018 11:08
Show Gist options
  • Save lalitkale/e2faf8783376eb0bdd1c738d97fd2223 to your computer and use it in GitHub Desktop.
Save lalitkale/e2faf8783376eb0bdd1c738d97fd2223 to your computer and use it in GitHub Desktop.
Kubectl Tips and Tricks

set the context to minikube running locally

kubectl config set-cluster minikube

create deployment yaml

kubectl run hello-world --image=myapp-container-image/k8s:1.0 --port=80 --dry-run -o yaml > myapp-deployment.yaml

create deployment yaml from existing deployment

kubectl get deployment hello-world -o yaml > my-existing-deployment.yaml

create servie yaml

you may want to decide on your service to run headless and change type argument below.

kubectl expose deployment hello-world --port=80 --type=LoadBalancer --dry-run -o yaml > myapp-service.yaml

copy remote file locally

kubectl cp pod:/remote-file /local/file

verbose kubectl

kubectl --v=8 version

see all options which are applied to all kubectl commands

kubectl options

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