# start up a cluster
KUBERNETES_PROVIDER=vagrant ./cluster/kube-up.sh
# start a simple vagrant cluster
NUM_NODES=1 KUBERNETES_PROVIDER=vagrant KUBE_ENABLE_CLUSTER_MONITORING=none KUBE_ENABLE_CLUSTER_UI=false ./cluster/kube-up.sh
# validate cluster
./cluster/validate-cluster.sh
kubectl cluster-info
# delete all rc & svc
kubectl delete svc,rc --all
kubectl delete $(kubectl get rc,svc -o name)
# watch for events
kubectl get ev -w
# schema / avaiable fields for rc/pods/svc ...
https://github.com/kubernetes/kubernetes/blob/master/pkg/api/types.go
# a simple service
https://github.com/kubernetes/kubernetes/blob/master/docs/user-guide/walkthrough/service.yaml
# available signals for a pod
https://github.com/luebken/httplog/blob/signals/rc.yml
# debug
kubectl logs --previous <pod>
# start a simple container
kubectl run busybox --image=busybox
# get system services
kubectl get svc --all-namespaces
# a debug container
kubectl run curlpod --image=radial/busyboxplus:curl --command -- /bin/sh -c "while true; do echo hi; sleep 10; done"
kubectl exec -it curlpod-5f0mh nslookup redis
# upload files
kubectl exec -i ghost-deployment-1955090760-zivlz -- /bin/bash -c 'cat > /tmp/testmail.msg' < testmail.msg
# more debug
http://kubernetes.io/v1.1/docs/user-guide/debugging-services.html
# create a new config
PROJECT_ID='mdl-k8s'
CLUSTER='cluster-4'
CLUSTER_ZONE='europe-west1-c'
gcloud config set project $PROJECT_ID
gcloud config set container/cluster $CLUSTER
gcloud config set compute/zone $CLUSTER_ZONE
gcloud container clusters get-credentials $CLUSTER
kubectl config use-context gke_${PROJECT_ID}_${CLUSTER_ZONE}_${CLUSTER}
-
-
Save nixMark/6786b224ce10e818ea3bf2933c40954f to your computer and use it in GitHub Desktop.
Kubectl Cheatsheet
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment