How To Handle Minikube(Cheatsheet)-3? K8s – Part: 9

0
112
views
How To Handle Minikube(Cheatsheet)-3? K8s - Part: 9

Missed the previous cheatsheets? Here are the links:
Cheatsheet-1
Cheatsheet-2

This is last but the least Cheatsheet – 3

COMMAND 25: To Get the URL for any service

Syntax: minikube service –url SERVICE_NAME

[[email protected] ~]# minikube service --url=true nginx-test
http://192.168.99.100:30184

This is actually <nodeip:port>

COMMAND 26: Get Cluster IP and port

[[email protected] ~]# kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 1h
nginx-test NodePort 10.108.249.9 <none> 80:30184/TCP 2m

COMMAND 27: To Get Access deployed service

Syntax: minikube service <srv-name>

[[email protected] ~]# minikube service nginx-test
Opening kubernetes service default/nginx-test in default browser...

It will pop up in your browser is this case as we have deployed Nginx




COMMAND 28: To get the number of running pods

[[email protected] ~]# kubectl get pods
NAME READY STATUS RESTARTS AGE
nginx-test-55494f998-r42s6 1/1 Running 0 11m

COMMAND 29: To scale any Running deployment

[[email protected] ~]# kubectl scale --replicas=3 deployment/nginx-test
deployment.extensions/nginx-test scaled
[[email protected] ~]# kubectl get pods
NAME READY STATUS RESTARTS AGE
nginx-test-55494f998-ctrfm 0/1 ContainerCreating 0 4s
nginx-test-55494f998-r42s6 1/1 Running 0 13m
nginx-test-55494f998-vhzp4 0/1 ContainerCreating 0 4s
previously there were 1 pod running now its have three pods

COMMAND 30: To get attach and get inside any pod

[[email protected] ~]# kubectl exec -it nginx-test-55494f998-vhzp4 -- /bin/bash
[email protected]:/#

Section 3: Clean Up

In this section, we will learn about clean up your deployments.

COMMAND 31: To Delete And Deployment

[[email protected] ~]# kubectl delete deployment nginx-test
deployment.extensions "nginx-test" deleted

COMMAND 32: To Delete Service

[[email protected] ~]# kubectl delete service nginx-test
service "nginx-test" deleted




Section 4: Minikube Troubleshoot

This section is related to basic troubleshooting of the minikube setup.

ISSUE 1: Sometimes IP of Minikube get changed so if somehow it’s not working then check by running below command.

[[email protected] ~]# minikube status
minikube: Running
localkube: Running
kubectl: Misconfigured: pointing to stale minikube-vm.
Solution

The above command says that kubectl: Misconfigured: pointing to stale minikube-vm

Solution: 
[[email protected] ~]# minikube update-context
Kubeconfig IP correctly configured, pointing at 192.168.99.100

ISSUE 2: When it says there is network issue while start Minikube like below issue

Error : E0830 11:44:45.720895 51788 start.go:180] Error starting host: Error starting stopped host: Error creating VM: virError(Code=55, Domain=19, Message=’Requested operation is not valid: network ‘minikube-net’ is not active’)

Solution:

[[email protected] ~]# virsh
virsh #
virsh # net-list --all 
Name State Autostart Persistent
----------------------------------------------------------
default active yes yes
minikube-net inactive no yes

– Should see that minikube-net is inactive. Now run below command on virsh shell

virsh # net-start minikube-net 
virsh # exit

If got successful then exit virsh and start minikube

[[email protected] ~]# start minikube

If you get an error message about “Network is already in use by interface virbr1” or something similar then

[[email protected] ~]# ifconfig virbr1 down
[[email protected] ~]# brctl delbr virbr1
[[email protected] ~]# virsh
virsh # net-start minikube-net 
virsh # net-list --all 
Name State Autostart Persistent
----------------------------------------------------------
default active yes yes
minikube-net active yes yes
virsh # exit
[[email protected] ~]#




Should now start-up

[[email protected] ~]# minikube start

ISSUE 3: When Minikube is not starting and get hang on getting started

[[email protected] ~]# minikube start
Starting local Kubernetes v1.10.0 cluster...
Starting VM...

Solution: 

[[email protected] ~]# minikube stop
[[email protected] ~]# minkube delete
[[email protected] ~]# rm -rf ~/.minikube
[[email protected] ~]# minikube start

Suggestion: You can also use cluster dump this really helpful in troubleshooting for Minikube
To Dump All the Cluster Info

[[email protected] ~]# kubectl cluster-info dump > 1.txt

You may use cat command to see all the information.

Section 5: Important File Directory Information

Critical minikube folder /var/lib/localkube, /var/lib/docker
Check minikube config in your host OS desktop ~/.minikube/machines/minikube/config.json

This bring us the end of the minikube and minikube command cheat sheet.

Kubernetes Series Links:

Understanding Kubernetes Concepts RHEL/CentOs K8s Part-1
Understanding Kubernetes Concepts RHEL/CentOs k8s: Part-2
How to Install Kubernetes on CentOS/RHEL k8s?: Part-3
How to Install Kubernetes on CentOS/RHEL k8s?: Part-4
How To Bring Up The Kubernetes Dashboard? K8s-Part: 5
How to Run Kubernetes Cluster locally (minikube)? K8s – Part: 6
How To Handle Minikube(Cheatsheet)-3? K8s – Part: 7
How To Handle Minikube(Cheatsheet)-3? K8s – Part: 8
How To Handle Minikube(Cheatsheet)-3? K8s – Part: 9