Skip to content

Instantly share code, notes, and snippets.

@moisesnarvaez
Last active February 8, 2021 01:19
Show Gist options
  • Save moisesnarvaez/f364262f2ac3f83d7948315af688224b to your computer and use it in GitHub Desktop.
Save moisesnarvaez/f364262f2ac3f83d7948315af688224b to your computer and use it in GitHub Desktop.

Kubernetes

CRUD Deployments

kubectl create deployment [name] --image=[Image from Docker] = Creates a deployment, with the default Blueprint

kubectl edit deployment [name] = Edits the deployment blueprint

kubectl get all = Lists all the components in the Cluster

kubectl get deployment = Lists the deployments statuses

kubectl get pod = Lists the pods statuses (-o wide=get more information)

kubectl get service = Lists the services statuses

kubectl delete deployment [name] = Deletes a deployment

kubectl get deployment [name] -o yaml = Gets the YAML with current status of a deployment (including status)

Logs

kubectl describe pod [podname] = Gets pot state changes history

kubectl describe service [service name] = Gets service information: Ip, Ports, selector, etc.

kubectl logs [podname] = Shows logs output

kubectl exec -it [podname] -- bin/bash = Access to the terminal of the container (for Debug)

File Config

kubectl apply -f [filename.yaml] = Uses the configuration file to create/update deployments/services/secrets

kubectl delete -f [filename.yaml] = Deletes the deployments/services/secrets specified in the configuration file

External Services

minikube service [service name] = Assiings an external IP and loads the service in the browser

Namespaces

kubectl create namespace [namespace name] = Creates a namespaces

kubectl get namespaces = Get info for namespaces

kubectl apply -f [filename.yaml] --namespace=[namespace name] = Uses the configuration file to create/update deployments/services/secrets inside the specified namespace (It can be included in the yaml as well)

Helm Charts

helm install --values=[valyes.yaml] [chartname] = Help setup using values provided in the yaml

helm upgrade <chartname> = Changes are applited to existing deployment instead of creating new one

helm rollback <chartname> = = Rollback to the last chartname

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