Kubernetes for beginner
Photo by Markus Spiske on Unsplash
Kubernetes for beginner
Kubernetes for beginner
Geting start with the kubernetes on MACOS
- Install Minikube:
brew install minikube
- Install kubectl:
brew install kubectl
- Start minikube cluster:
minikube start
Some basic command for kubectl
kubectl get nodes
orkubectl get no -o yaml
: get all nodes in the clusterkubectl get pods
orkubectl get po -o yaml
: get all pods in the clusterkubectl get services
orkubectl get svc -o yaml
: get all services in the clusterkubectl get deployments
orkubectl get deploy -o yaml
: get all deployments in the clusterkubectl describe pod <pod-name>
: get detail of a podkubectl describe node <node-name>
: get detail of a node
##Run an app Make sure you have the docker image of the app you want to run on the cluster. If not, you can build it by yourself or pull it from the docker hub. My app was listen on the port 8180.
11. kubectl create deployment orovn-kube101 --image=orovn/kube101-go22. kubectl expose deployment orovn-kube101 --type=NodePort --port=818033. minikube service orovn-kube101
Scaling the app
kubectl scale deployment orovn-kube101 --replicas=3
or kubectl edit deployment orovn-kube101
and Modify the replicas line, and set
it to 3
Tail all logs from all the pods in the deployment
kubectl logs -f -l app=hello-go --prefix=true
Update the app
11. kubectl set image deployment/orovn-kube101 orovn-kube101=orovn/kube101-go:v222. kubectl rollout status deployment/orovn-kube10133. kubectl rollout history deployment/orovn-kube10144. kubectl rollout undo deployment/orovn-kube101
Clean up
11. kubectl delete service orovn-kube10122. kubectl delete deployment orovn-kube101