Setting up Kubernetes with Minikube on a Elastic Metal Server
- compute
- Kubernetes
- Minikube
- server
- Elastic-Metal-server
Kubernetes is an open-source platform for managing containerized workloads and services with a rapidly growing ecosystem. Kubernetes orchestrates computing, networking, and storage infrastructure on behalf of user workloads. The tool facilitates both: declarative configuration and automation and was released to the public by Google in 2014.
Kubernetes has several features. It can be thought of as:
- a container platform
- a microservices platform
- a portable cloud platform and a lot more.
Minikube runs a single-node Kubernetes cluster inside a VM on your computer or cloud server for developing and testing applications.
Minikube supports Kubernetes features such as:
- DNS
- NodePorts
- ConfigMaps and Secrets
- Dashboards
- Container Runtime: Docker, rkt, CRI-O and containerd
- Enabling CNI (Container Network Interface)
- Ingress
You may need certain IAM permissions to carry out some actions described on this page. This means:
- you are the Owner of the Scaleway Organization in which the actions will be carried out, or
- you are an IAM user of the Organization, with a policy granting you the necessary permission sets
- You have an account and are logged into the Scaleway console
- You have configured your SSH key
- You have created a Elastic Metal server which is running Ubuntu Bionic Beaver (18.04).
Downloading and Installing Minikube
- Check if the CPU of your server supports hardware virtualization. The output of the following command shall not be empty:
egrep --color 'vmx|svm' /proc/cpuinfo
- Minikube relies on a Hypervisor to run the Kubernetes VM. This tutorial uses KVM (Kernel Virtual Machine), but it is also possible to run Minikube on VirtualBox.
apt-get install qemu qemu-kvm libvirt-bin virtinst curl
- Download the Minikube binary and make it executable:
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 && sudo install minikube-linux-amd64 /usr/local/bin/minikube
- Download and install the KVM driver for Minikube:
curl -LO https://storage.googleapis.com/minikube/releases/latest/docker-machine-driver-kvm2 && chmod +x docker-machine-driver-kvm2
- Copy the binary file to
/usrlocal/bin/
to make it available system-wide, then remove the downloaded binary:cp docker-machine-driver-kvm2 /usr/local/bin/ && rm docker-machine-driver-kvm2 - Download and install
kubectl
, a CLI tool to manage Kubernetes:curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl && chmod +x kubectl - Copy the binary file to
/usrlocal/bin/
to make it available system-wide, then remove the downloaded binary:cp kubectl /usr/local/bin && rm kubectl
Using Minikube
-
Start Minikube:
minikube start --vm-driver=kvm2An output informs you about the status of Minikube:
😄 minikube v1.1.0 on linux (amd64)2019/05/27 15:11:47 No matching credentials were found, falling back on anonymous🔥 Creating kvm2 VM (CPUs=2, Memory=2048MB, Disk=20000MB) ...🐳 Configuring environment for Kubernetes v1.14.2 on Docker 18.09.6💾 Downloading kubeadm v1.14.2💾 Downloading kubelet v1.14.2🚜 Pulling images ...🚀 Launching Kubernetes ...⌛ Verifying: apiserver proxy etcd scheduler controller dns🏄 Done! kubectl is now configured to use "minikube" -
Check the health status of
minikube
:minikube statushost: Runningkubelet: Runningapiserver: Runningkubectl: Correctly Configured: pointing to minikube-vm at 192.168.39.101 -
Start an Echoserver deployment:
kubectl run hello-minikube --image=k8s.gcr.io/echoserver:1.14 --port=8080Once the deployment is created, a message confirms the step:
deployment.apps/hello-minikube created -
Check the running pods and configured deployments:
kubectl get podsNAME READY STATUS RESTARTS AGEhello-minikube-56cdb79778-qj7sd 1/1 Running 0 3m47skubectl get deploymentsNAME READY UP-TO-DATE AVAILABLE AGEhello-minikube 1/1 1 1 5m59sExpose an echoserver deployment with NodePort
kubectl expose deployment hello-minikube --type=NodePort -
curl
the service created by running the following command:curl $(minikube service hello-minikube --url)A response similar to this example is shown:
Hostname: hello-minikube-56cdb79778-qj7sdPod Information:-no pod information available-Server values:server_version=nginx: 1.13.3 - lua: 10008Request Information:client_address=172.17.0.1method=GETreal path=/query=request_version=1.1request_scheme=httprequest_uri=http://192.168.39.101:8080/Request Headers:accept=*/*host=192.168.39.101:30090user-agent=curl/7.58.0Request Body:-no body in request- -
Delete the
hello-minikube
service:kubectl delete services hello-minikube -
Delete the deployment:
kubectl delete deployment hello-minikubeA confirmation displays:
deployment.extensions "hello-minikube" deleted -
Stop Minikube:
minikube stopA confirmation displays:
✋ Stopping "minikube" in kvm2 ...🛑 "minikube" stopped.
For more information regarding Minikube and Kubernetes, check out the official documentation and the Minikube GitHub repository.