Skip to content

Instantly share code, notes, and snippets.

@whitneygriffith
Last active October 20, 2020 18:13
Show Gist options
  • Save whitneygriffith/049205dd939ba325e2d335e4124297e3 to your computer and use it in GitHub Desktop.
Save whitneygriffith/049205dd939ba325e2d335e4124297e3 to your computer and use it in GitHub Desktop.
Learn K8s
#Basic Deployment Declaration with Liveness Probe
apiVersion: apps/v1
kind: Deployment
metadata:
name: frontend
labels:
app: my-nginx
tier: frontend
spec:
selector:
matchLabels:
tier: frontend
template:
metadata:
labels:
tier: frontend
spec:
containers:
- name: my-nginx
image: nginx:alpine
livenessProbe:
httpGet:
path: /index.html
port: 80
initialDelaySeconds: 15
timeoutSeconds: 2
periodSeconds: 5
failureThreshold: 1
# K8s Commands
# Gets token to enable Web UI Dashboard locally: https://kubernetes.io/docs/tasks/access-application-cluster/web-ui-dashboard/
kubectl describe secret -n kube-system
# Pods
kubectl create -f [pod.name].pod.yml --dry-run --validate=true
kubectl create -f [pod.name].pod.yml --save-config
kubectl apply -f [pod.name].pod.yml
kubectl describe pod [pod.name]
kubectl exec [pod.name] -it sh
kubectl edit -f [pod.name].pod.yml
kubectl get pod [pod.name]
kubectl delete -f [pod.name].pod.yml
# Deployments
kubectl create -f [deployment.name].deployment.yml --save-config
kubectl apply -f [deployment.name].deployment.yml
kubectl get deployments
kubectl get deployments --show-labels
kubectl get deployments -l tier=frontend
kubectl delete deployment [deployment.name]
kubectl delete -f [deployment.name].deployment.yml
kubectl scale deployment [deployment.name] --replicas=5
kubectl scale -f [deployment.name].deployment.yml --replicas=5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment