brew install kubernetes-cli minikube
minikube start # --memory=8192 --cpus=4
kubectl get -A deployment
kubectl get -A pod -w
minikube addons list
minikube addons enable metrics-server
minikube addons enable dashboard
kubectl proxy
open http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy
kuebctl top node
kuebctl top pod
Let's create a deployment!
Copy/paste into hello-node.yaml
:
apiVersion: apps/v1
kind: Deployment
metadata:
name: hello-node
namespace: default
labels:
app: hello-node
spec:
replicas: 1
selector:
matchLabels:
app: hello-node
template:
metadata:
labels:
app: hello-node
spec:
containers:
- image: k8s.gcr.io/echoserver:1.4
name: echoserver
Watch pods: kubectl get po -w
Now deploy to cluster:
kubectl apply -f hello-node.yaml
kubectl get all -A
Scale up/down:
kubectl scale deploy/hello-node --replicas=5
kubectl scale deploy/hello-node --replicas=1
kubectl get namespaces
kubectl get deploy
kubectl get -n ingress-nginx deploy
kubectl get -n kube-system deploy
kubectl get --all-namespaces deploy
kubectl get pods -w
kubectl get pods -o wide
kubectl get events
kubectl create -f foobar.yml
kubectl explain services
kubectl get pods,svc,deploy
kubectl describe deploy push-service
kubectl delete deploy push-service
kubectl cluster-info
kubectl api-resources
kubectl top node
kubectl top pods
kubectl logs -f deploy/ghost
kubectl logs -f deploy/ghost -c ghost
kubectl logs --previous ghost-97d8bf485-p25r2
kubectl exec -it ghost-97d8bf485-p25r2 -- tail /var/log/apt/history.log