Deploy Kubernetes using Minikube - caprivm/virtualization GitHub Wiki
caprivm ([email protected])
This page shows how to install a Kubernetes Cluster, using the open source tool Minikube. The purpose is to deploy the Kubernetes cluster in a single-machine for experimental purposes only. The sizing used for this single-machine is:
Feature | Value |
---|---|
OS Used | Ubuntu 20.04 LTS |
vCPU | 8 |
RAM (GB) | 16 |
Disk (GB) | 140 |
Home user | ubuntu |
The contents of the page are:
Before starting this guide, you should have installed the following tools. You can check the adjacent links if you haven't already:
The list of environment variables used for this implementation are summarized in the following exports
:
export HOST_IP=$(hostname -I | tr " " "\n" | head -n 1)
export MINIKUBE_IP=$(cat ~/.kube/config | grep server | tr "\/" "\n" | tail -n 1 | tr ":" "\n" | head -n 1)
You can use this dynamic guide to install Minikube on different operating systems and processor types. To install the latest minikube stable release on x86-64 Linux using binary download:
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
sudo install minikube-linux-amd64 /usr/local/bin/minikube
# Start Minikube using the Docker driver
minikube start --driver=docker
minikube config set driver docker # <-- Make docker the default driver
If you already have kubectl installed, you can now use it to access your shiny new cluster:
kubectl get po -A
# NAMESPACE NAME READY STATUS RESTARTS AGE
# kube-system coredns-558bd4d5db-2whdk 1/1 Running 4 54d
# kube-system etcd-minikube 1/1 Running 4 54d
# kube-system kube-apiserver-minikube 1/1 Running 4 54d
# kube-system kube-controller-manager-minikube 1/1 Running 4 54d
# kube-system kube-proxy-gc2sl 1/1 Running 4 54d
# kube-system kube-scheduler-minikube 1/1 Running 4 54d
# kube-system storage-provisioner 1/1 Running 8 54d
# kube-system tiller-deploy-867946c76c-4shmg 1/1 Running 0 5d13h
# kubernetes-dashboard dashboard-metrics-scraper-7976b667d4-vqmjp 1/1 Running 4 53d
# kubernetes-dashboard kubernetes-dashboard-6fcdf4f6d-hw2qm 1/1 Running 6 53d
# metallb-system controller-66bc445b99-68w6m 1/1 Running 3 53d
# metallb-system speaker-lrcw7 1/1 Running 3 53d
To manage the cluster, you can use the following commands:
# Pause Kubernetes without impacting deployed applications
minikube pause
minikube unpause
# Halt the cluster
minikube stop
# Increase the default memory limit (requires a restart)
minikube config set memory 16384
# Enable the easily Kubernetes services
minikube addons list
minikube addons enable storage-provisioner # <-- Enable a addons easily
minikube addons enable efk # <-- Enable a addons easily
# Create a second cluster running an older Kubernetes release
minikube start -p aged --kubernetes-version=v1.16.1
# Delete all of the minikube clusters
minikube delete --all
To access the cluster remotely, it is suggested to install a reverse Proxy and make the authentication against the kube-API insecure. Follow the steps below:
NOTE: Perform this for testing purposes only. This is not suggested for a productive environment.
# In the same VM that Minikube was installed
sudo apt update
sudo apt install nginx
Edit the nginx
configuration (/etc/nginx/nginx.conf
) file:
# listen localhost:143;
# protocol imap;
# proxy on;
# }
#}
+
+stream {
+ server {
+ listen $HOST_IP:51999;
+ #TCP traffic will be forwarded to the specified server
+ proxy_pass $MINIKUBE_IP:8443;
+ }
+}
Before we do anything, let’s test the new nginx
settings:
sudo nginx -t
# nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
# nginx: configuration file /etc/nginx/nginx.conf test is successful
Restart the nginx
service:
sudo service nginx restart
Edit the configuration file generated by Minikube (it is in the path ~/.kube/config
) and use it for the remote access:
apiVersion: v1
clusters:
- cluster:
- certificate-authority: /home/ubuntu/.minikube/ca.crt
+ insecure-skip-tls-verify: true
extensions:
- extension:
last-update: Wed, 13 Oct 2021 19:47:47 UTC
provider: minikube.sigs.k8s.io
version: v1.22.0
name: cluster_info
- server: https://$MINIKUBE_IP:8443
+ server: https://$HOST_IP:51999
name: minikube
contexts:
- context:
cluster: minikube
extensions:
- extension:
last-update: Wed, 13 Oct 2021 19:47:47 UTC
provider: minikube.sigs.k8s.io
version: v1.22.0
name: context_info
namespace: default
user: minikube
name: minikube
current-context: minikube
kind: Config
preferences: {}
users:
- name: minikube
user:
- client-certificate: /home/ubuntu/.minikube/profiles/minikube/client.crt
+ client-certificate-data: "LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURJVENDQ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2bjRTZFFQYytLUmlHOERBanVIYVdnNlB0cnNEb3dtCk44YUd3azhaNFZtdEszUEpTZ3VUNmNEOUFvR0FiS1c1WTlSMTRBbFZJMUpTa05YcitVTFhQRWVDUkZBU1ozUkcKTjNoZ0VwdEVLRXNEYm51b1JHV0NHeWRkaHBpVE1SczNxQVJaYytlR1lGYitodWZlYVJ0bm1ESmE1eWZxNXNHcQo1UUNuUHJJMUk3TnBJclN1Mmx0blg0Q0hmRkFsNWpjK2N6MjBCTVVFTi9KOGpwSGJzUmFCUnc0UTR4VnF4RFJDCm95bXV0MjhDZ1lFQXh4OGg5R2JlMVlJYmYvTjE1ZzdjUWhSd3FuWUdsYVVseGVNSXN6OGIweWlFTzhuL2lHVmoKZlI0aFhyVkNEczFqU3pkb3EvUkJCRkd1VEs1eDZ1NVBpVGlwc2RHRk94QUgwTy94QnBjakNqT1RBRGpXWDNDRwp4VFN5ejc3bjhJdTQzbHlTZzJhaStGZDBiOHMxc296TEJ6SXJ1cnhZcEo2L2N2WWdzNlQvSzMwPQotLS0tLUVORCBSU0EgUFJJVkFURSBLRVktLS0tLQo="
The information in the client-certificate-data
and the client-key-data
can be obtained using:
cat /home/ubuntu/.minikube/profiles/minikube/client.crt | base64 | tr "\n" " " | sed 's/ //g'
cat /home/ubuntu/.minikube/profiles/minikube/client.key | base64 | tr "\n" " " | sed 's/ //g'
Save this file and pass it for remote access to the Kubernetes cluster. For example, if the file was saved with the name minikube_admin.conf
you may use:
kubectl --kubeconfig minikube_admin.conf get pods -A
# NAMESPACE NAME READY STATUS RESTARTS AGE
# kube-system coredns-558bd4d5db-2whdk 1/1 Running 4 54d
# kube-system etcd-minikube 1/1 Running 4 54d
# kube-system kube-apiserver-minikube 1/1 Running 4 54d
# kube-system kube-controller-manager-minikube 1/1 Running 4 54d
# kube-system kube-proxy-gc2sl 1/1 Running 4 54d
# kube-system kube-scheduler-minikube 1/1 Running 4 54d
# kube-system storage-provisioner 1/1 Running 8 54d
# kube-system tiller-deploy-867946c76c-4shmg 1/1 Running 0 5d13h
# kubernetes-dashboard dashboard-metrics-scraper-7976b667d4-vqmjp 1/1 Running 4 53d
# kubernetes-dashboard kubernetes-dashboard-6fcdf4f6d-hw2qm 1/1 Running 6 53d
# metallb-system controller-66bc445b99-68w6m 1/1 Running 3 53d
# metallb-system speaker-lrcw7 1/1 Running 3 53d