Canonical guide: https://kubernetes.io/docs/reference/kubectl/quick-reference/
----------------------------------------------------------------------
Minikube Installation
----------------------------------------------------------------------
# from the minikube project page
curl -LO https://github.com/kubernetes/minikube/releases/latest/download/minikube-linux-amd64
sudo install minikube-linux-amd64 /usr/local/bin/minikube && rm minikube-linux-amd64
ll /usr/local/bin/minikube
alias kubectl='minikube kubectl --'
----------------------------------------------------------------------
Cluster Inspection
----------------------------------------------------------------------
kubectl get pods
kubectl get pods -A
kubectl get services
kubectl get services hello-minikube
kubectl describe pod headlamp-57fb76fcdb-f6bsl
kubectl describe pod headlamp-57fb76fcdb-f6bsl --namespace headlamp
# Show deployed container digests for all pods
kubectl get pods --namespace=mynmspc -o=jsonpath='{range .items[*]}{"\n"}{.metadata.namespace}{","}{.metadata.name}{","}{range .status.containerStatuses[*]}{.image}{", "}{.imageID}{", "}{end}{end}' | sort
# Locate pods for a service/deployment
kubectl get pods -n <namespace> |grep <name>
# Follow log for a pod
kubectl logs -f <podname> -n <namespace>
# Follow logs for multiple pods
kubectl logs -l app.kubernetes.io/<label>=<value> -n <namspace>
> e.g. follow all logs under the instance selector
kubectl logs -l app.kubernetes.io/instance=rke2-ingress-nginx -n kube-system
----------------------------------------------------------------------
Download Deployment descriptors
----------------------------------------------------------------------
----------------------------------------------------------------------
Minikube Control
----------------------------------------------------------------------
minikube [start|stop|pause|unpause]
Add-Ons and Services
----------------------------------------------------------------------
minikube addons list
# install
minikube addons enable headlamp
# run addon with name
minikube service headlamp -n headlamp
# run addon
minikube service hello-minikube
# open browser to endpoint, when available from addon
minikube addons open <name>
# run addon when mk starts
minikube start --addons <name1> --addons <name2>
----------------------------------------------------------------------
Deploy Service
----------------------------------------------------------------------
kubectl create deployment hello-minikube --image=kicbase/echo-server:1.0
kubectl expose deployment hello-minikube --type=NodePort --port=8080
kubectl get services hello-minikube
kubectl port-forward service/hello-minikube 7080:8080
----------------------------------------------------------------------
Headlamp Setup
----------------------------------------------------------------------
# install addon - see above
minikube addons enable headlamp
# run addon with name
minikube service headlamp -n headlamp
# get login token
kubectl create token headlamp-admin -n kube-system
# metrics-server helps w/admin
# uses image registry.k8s.io/metrics-server/metrics-server:v0.7.2
minikube addons enable metrics-server
# See for setup instructions
https://headlamp.dev/docs/latest/installation
~
No comments:
Post a Comment