Minikube Ubuntu 18.04

O minikube é uma ferramenta muito útil para rodar o Kubernetes localmente, ele xecuta em um simples nó um “cluster” kubernetes, é bem útil para testes e estudos.

O Minikube suporta as seguintes features do Kubernetes:DNS, NodePorts, ConfigMaps and Secrets, Dashboard, Container Runtime: Docker, rkt, Enabling CNI (Container Network Interface), Ingress.

Sua instalação no Ubuntu é muito simples:

sudo apt-get update && sudo apt-get install apt-transport-https

# curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -

# echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee -a /etc/apt/sources.list.d/kubernetes.list 

# apt-get install -y kubectl

# curl -Lo minikube https://storage.googleapis.com/minikube/releases/v0.30.0/minikube-linux-amd64 && chmod +x minikube && sudo cp minikube /usr/local/bin/ && rm minikube 

Agora estartamos nosso cluster:

# minikube start
Starting local Kubernetes v1.10.0 cluster...
Starting VM...
Downloading Minikube ISO
 170.78 MB / 170.78 MB [============================================] 100.00% 0s
Getting VM IP address...
Moving files into cluster...
Downloading kubeadm v1.10.0
Downloading kubelet v1.10.0
Finished Downloading kubelet v1.10.0
Finished Downloading kubeadm v1.10.0
Setting up certs...
Connecting to cluster...
Setting up kubeconfig...
Starting cluster components...
Kubectl is now configured to use the cluster.
Loading cached images from config file.

Para subir os Pods com o mini-kube é só utilizar o kubectl:

# kubectl create -f zabbix-all-in-one.yaml
service/zabbix-web created
service/zabbix-db created
service/zabbix-server created
replicationcontroller/zabbix-web created
replicationcontroller/zabbix-db created
replicationcontroller/zabbix-server created

Para este exemplo utilizei o .yaml de um outro tutorial, usando as images do https://github.com/monitoringartist.

Para acessarmos a nossa aplicação precisamos verificar o IP que o minikube criou:

# minikube ip
192.168.99.100

Agora fazemos o expose do service:

# kubectl get svc
NAME            TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)               AGE
kubernetes      ClusterIP   10.96.0.1                443/TCP               2h
zabbix-db       ClusterIP   10.104.144.139           3306/TCP              11s
zabbix-server   ClusterIP   10.102.140.241           10051/TCP,10052/TCP   11s
zabbix-web      ClusterIP   10.110.167.148           80/TCP                11s

# kubectl expose service zabbix-web --type=LoadBalancer --name=zabbix 
service/zabbix exposed

# kubectl get svc | grep Load  
zabbix          LoadBalancer   10.106.115.57         80:32411/TCP          8m

Como o IP do minikube e a porta exposta acessamos nossa app no endereço no Browser em 192.168.99.100:32411.

Referências:
https://kubernetes.io/docs/setup/minikube/
https://kubernetes.io/docs/tasks/tools/install-kubectl/#install-kubectl
https://kubernetes.io/docs/tasks/tools/install-minikube/#install-minikube
https://www.zabbix.com/documentation/3.4/manual/quickstart/login
https://www.zabbix.com/documentation/3.4/manual/installation/containers

Minikube Ubuntu 18.04
Tagged on: