Minikube: Primeiros Passos

From Wiki
Revision as of 19:00, 15 June 2020 by Ebasso (talk | contribs)

Para conectar-se ao cluster do Kubernetes, o kubectl precisa saber sobre o master-node e das credenciais para se conectar a ele.

Levantando o Minikube

Para levantar o minikube, basta executar o comando: "minikube start", mas no meu caso prefiro utilizar o virtualbox, então preciso invormar o driver

minikube start --vm-driver=virtualbox

Resultado:

😄  minikube v0.34.1 on darwin (amd64)
💡  Tip: Use 'minikube start -p <name>' to create a new cluster, or 'minikube delete' to delete this one.
🏃  Re-using the currently running virtualbox VM for "minikube" ...
⌛  Waiting for SSH access ...
📶  "minikube" IP address is 192.168.99.100
🐳  Configuring Docker as the container runtime ...
✨  Preparing Kubernetes environment ..
🚜  Pulling images required by Kubernetes v1.13.3 ...
🔄  Relaunching Kubernetes v1.13.3 using kubeadm ...
⌛  Waiting for kube-proxy to come back up ...
🤔  Verifying component health .....
💗  kubectl is now configured to use "minikube"
🏄  Done! Thank you for using minikube!

Para parar:

minikube stop

Para conectar via ssh

minikube ssh

Para saber o ip

minikube ip

Informações do cluser (kubectl cluster-info)

Para saber quais as informações do minikube

kubectl cluster-info

Resultado:

Kubernetes master is running at https://192.168.99.100:8443
KubeDNS is running at https://192.168.99.100:8443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy

To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.

Usando o Kubernetes Dashboard

Vamos habilitar o Kubernetes Dashboard no Minikube através do comando:

minikube dashboard

Resultado:

Enabling dashboard ...
🤔  Verifying dashboard health ... 
🚀  Launching proxy ...
🤔  Verifying proxy health ...
🎉  Opening http://127.0.0.1:55956/api/v1/namespaces/kube-system/services/http:kubernetes-dashboard:/proxy/ in your default browser...

Automaticamente é aberto o browser no dashboard do K8s.

Através do comando (kubectl proxy)

No passo anterior, se você executar um Ctrl+C, o dashboard é fechado.

Para evitarmos isso executamos o comando:

kubectl proxy

Basta acessar a url

http://127.0.0.1:8001/api/v1/namespaces/kube-system/services/http:kubernetes-dashboard:/proxy/#!/namespace?namespace=default

Ver também