Skip to content

Instantly share code, notes, and snippets.

@Nairit11
Last active September 25, 2019 18:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Nairit11/f5342ab46f395ebdd71265d60bafd2fa to your computer and use it in GitHub Desktop.
Save Nairit11/f5342ab46f395ebdd71265d60bafd2fa to your computer and use it in GitHub Desktop.
A cheat sheet for Kubernetes

KUBERNETES CHEAT SHEET

Create a deployment for an image

kubectl run nginx --image=nginx:1.10.0

Get pods running some container

kubectl get pods

Expose the container generating a public IP which routes to the pods running behind the service

kubectl expose deployment nginx --port 80 --type LoadBalancer

List services which have been exposed

kubectl get services

Create a pod

kubectl create -f pods/nginx.yaml

Get more information about a pod

kubectl describe pods nginx

Port a local port to a port inside the pod

kubectl port-forward nginx LOCAL_PORT:PORT_IN_POD

View logs for a pod

kubectl logs -f nginx

Run an Interactive shell inside a pod to interact with a running container

kubectl exec nginx --stdin --tty -c nginx /bin/sh

Type exit to logout from the interactive shell

Create a sectret for configurations to be mounted onto a pod as a volume

kubectl create secret generic SECRET_NAME --from-file=DIRECTORY/

Get information about a secret

kubectl describe secret SECRET_NAME

Create a configmap from a configuration file

kubectl create configmap CONFIGMAP_NAME --from-file=DIRECTORY/FILE

Get information about a configmap

kubectl describe configmap CONFIGMAP_NAME

Add label to a pod

kubectl label pods POD_NAME "LABEL_NAME=VALUE"

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