This is a work in progress and will be expanded and improved as I have time.
I started with the MicroK8s documentation at https://ubuntu.com/tutorials/install-a-local-kubernetes-with-microk8s#1-overview. I didn't choose the multipass route because I like yak-shaving my VMs manually and wanted to get as much understanding of what's going on as possible.
This PDF helped me set up Hyper-V on my windows desktop. My rig is:
- Ryzen 7 3700X
- 32GB RAM
so I have plenty of horsepower and memory to go around.
I used this GeekFlare page https://geekflare.com/ubuntu-on-windows/ to configure Hyper-V and create the Ubuntu 20.04.3 LTS VM for MicroK8s.
Follow the directions in it to:
- Enable Virtualization
- Enable Hyper-V
- Create a Virtual Switch for the VMs The Virtual Switch is needed to give the VM access to the external network. The default switch in Hyper-V is host-only. I find it easier to treat the VMs as normal servers on my network rather than having them all NATted behind a non-routable network.
- Create an Ubuntu 20.04.3 LTS VM using the 'Installing Manually' method.
Select Generation 1
After creating the VM, go into its Settings and make these changes:
- Adjust the virtual CPUs to 2
- Add a second NIC. I enabled VLAN 2 on my home network and configured the second NIC to use it, so that I can clearly see the different IP addresses on the two NICs
- Start the installation process
- When it asks for what snaps you want to install, select microk8s, then continue.
- Log into your VM
- Install kubectl using the apt-get as per: https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/#install-using-native-package-management
- Verify microk8s is up and running
microk8s status
- You should get something like this:
$ microk8s status
microk8s is running
high-availability: no
datastore master nodes: 127.0.0.1:19001
datastore standby nodes: none
addons:
enabled:
ha-cluster # Configure high availability on the current node
disabled:
ambassador # Ambassador API Gateway and Ingress
cilium # SDN, fast with full network policy
dashboard # The Kubernetes dashboard
dns # CoreDNS
fluentd # Elasticsearch-Fluentd-Kibana logging and monitoring
gpu # Automatic enablement of Nvidia CUDA
helm # Helm 2 - the package manager for Kubernetes
helm3 # Helm 3 - Kubernetes package manager
host-access # Allow Pods connecting to Host services smoothly
ingress # Ingress controller for external access
istio # Core Istio service mesh services
jaeger # Kubernetes Jaeger operator with its simple config
kata # Kata Containers is a secure runtime with lightweight VMS
keda # Kubernetes-based Event Driven Autoscaling
knative # The Knative framework on Kubernetes.
kubeflow # Kubeflow for easy ML deployments
linkerd # Linkerd is a service mesh for Kubernetes and other frameworks
metallb # Loadbalancer for your Kubernetes cluster
metrics-server # K8s Metrics Server for API access to service metrics
multus # Multus CNI enables attaching multiple network interfaces to pods
openebs # OpenEBS is the open-source storage solution for Kubernetes
openfaas # openfaas serverless framework
portainer # Portainer UI for your Kubernetes cluster
prometheus # Prometheus operator for monitoring and logging
rbac # Role-Based Access Control for authorisation
registry # Private image registry exposed on localhost:32000
storage # Storage class; allocates storage from host directory
traefik # traefik Ingress controller for external access
lance@kates:~/$
- Create a kubectl config for your microk8s
$ microk8s config > ~/.kube/config
- test with normal kubectl
lance@kates:~/.kube$ kubectl get nodes
NAME STATUS ROLES AGE VERSION
kates Ready <none> 32m v1.22.4-3+adc4115d990346
lance@kates:~/.kube$
- Enable some useful microk8s addons
$ sudo microk8s enable dns storage registry dashboard
This will take a while as microk8s pulls down all the images needed and fires up the deployments for each addon.
I used this example from kubernetes.io: https://kubernetes.io/docs/tutorials/stateful-application/mysql-wordpress-persistent-volume/
- Make a directory to work in
mkdir ~/wordpress
cd ~/wordpress
- Get the mysql-deployment.yaml
curl -LO https://k8s.io/examples/application/wordpress/mysql-deployment.yaml
- Get the wordpress-deployment.yaml
curl -LO https://k8s.io/examples/application/wordpress/wordpress-deployment.yaml
- Create the kustomization.yaml file. This adds a secretGenerator you use to specify the password for the mysql deployment. Replace YOUR_PASSWORD with the password you want to use
cat <<EOF >./kustomization.yaml
secretGenerator:
- name: mysql-pass
literals:
- password=YOUR_PASSWORD
resources:
- mysql-deployment.yaml
- wordpress-deployment.yaml
EOF
- Apply the configuration
$ kubens default
$ kubectl apply -k ./