Wednesday, February 5, 2025

Kubectl Cheat Sheet

Using kubectl within 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 --' 

----------------------------------------------------------------------
Minikube Control
----------------------------------------------------------------------

minikube [start|stop|pause|unpause]

----------------------------------------------------------------------
Minikube 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

----------------------------------------------------------------------
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