How to install MicroK8s on Windows using Multipass

Configurare noua (How To)

Situatie

What is Kubernetes Kubernetes clusters host containerised applications in a reliable and scalable way. Having DevOps in mind, Kubernetes makes maintenance tasks such as upgrades dead simple. What is MicroK8s MicroK8s is a CNCF certified upstream Kubernetes deployment that runs entirely on your workstation or edge device. Being a snap it runs all Kubernetes services natively (i.e. no virtual machines) while packing the entire set of libraries and binaries needed. Installation is limited by how fast you can download a couple of hundred megabytes and the removal of MicroK8s leaves nothing behind. What is Multipass Multipass is a lightweight VM manager for Linux, Windows and macOS. It’s designed for developers who want a fresh Ubuntu environment with a single command. It uses KVM on Linux, Hyper-V on Windows and HyperKit on macOS to run the VM with minimal overhead. It can also use VirtualBox on Windows and macOS. Multipass will fetch images for you and keep them up to date. In this tutorial you’ll learn how to…

  • Setting up Multipass on Windows
  • Setting up MicroK8s on your Multipass VM
  • Enabling MicroK8s add-ons in Multipass

You will only need …

  • A Windows machine with at least 8GB of RAM
  • Multipass installed on your PC.

Solutie

Pasi de urmat
To install MicroK8s from the command prompt, use the following commands 
(make sure you have Multipass installed):
multipass launch --name microk8s-vm --mem 4G --disk 40G multipass exec microk8s-vm -- sudo snap install microk8s --classic
multipass exec microk8s-vm -- sudo iptables -P FORWARD ACCEPT

Make sure you reserve enough resources to host your deployments; above, 
we got 4GB of RAM and 40GB of hard disk. We also make sure packets to/from 
the pod network interface can be forwarded to/from the default interface.
The VM has an IP address that you can check with the command: multipass list:
Name                    State             IPv4           
microk8s-vm             RUNNING           10.72.145.216  
The services once enabled will be available at the IP address shown in your console. 
Before we move on, a few quick handy commands: 
Create a shell inside the VM multipass shell microk8s-vmShutdown the VM multipass stop microk8s-vm
Delete the VM and cleanup multipass delete microk8s-vm  multipass purge 
Open a shell in Multipass with a MicroK8s VM multipass shell microk8s-vm
To execute a command without getting a shell, you can use multipass exec as in the example below:
multipass exec microk8s-vm -- /snap/bin/microk8s.status
This will show us the status of our MicroK8s deployment and components.
While MicroK8s has a lot of useful add-ons, for simplicity's sake we'll 
enable and use the dns and dashboard addons. We can view the Grafana 
dashboard for our deployment.
Let's enable the add-ons. Use the follwoing command:
multipass exec microk8s-vm -- /snap/bin/microk8s.enable dns dashboardLet's access hosted services. 
The API server proxies our services, here is how to get to them: multipass exec microk8s-vm -- /snap/bin/microk8s.kubectl cluster-info
Kubernetes master is running at https://127.0.0.1:16443
Heapster is running at https://127.0.0.1:16443/api/v1/namespaces/kube-system
/services/heapster/proxy
CoreDNS is running at https://127.0.0.1:16443/api/v1/namespaces/kube-system
/services/kube-dns:dns/proxy
Grafana is running at https://127.0.0.1:16443/api/v1/namespaces/kube-system
/services/monitoring-grafana/proxy
InfluxDB is running at https://127.0.0.1:16443/api/v1/namespaces/kube-system
/services/monitoring-influxdb:http/proxy multipass exec microk8s-vm -- /snap/bin/microk8s.config 
Host your first service in Kubernetes
We start by creating a microbot deployment with two pods via the kubectl cli:
multipass exec microk8s-vm -- /snap/bin/microk8s.kubectl create deployment 
microbot --image=dontrebootme/microbot:v1
multipass exec microk8s-vm -- /snap/bin/microk8s.kubectl scale deployment 
microbot --replicas=2
To expose our deployment we need to create a service: multipass exec microk8s-vm -- /snap/bin/microk8s.kubectl expose deployment 
microbot --type=NodePort --port=80 --name=microbot-service After a few minutes our cluster looks like this: > multipass exec microk8s-vm -- /snap/bin/microk8s.kubectl get all 
--all-namespaces
NAMESPACE     NAME                                     
default       pod/microbot-7dd47b8fd6-4rzt6            
 default       pod/microbot-7dd47b8fd6-xr49r           
kube-system   pod/coredns-f7867546d-zb9t5              
kube-system   pod/heapster-v1.5.2-844b564688-5bpzs     
kube-system   pod/kubernetes-dashboard-7d75c474bb-jcglw
kube-system   pod/monitoring-influxdb-grafana-v4-6b6954


NAMESPACE     NAME                           TYPE        CLUSTER-IP    
default       service/kubernetes             ClusterIP   10.152.183.1  
 default       service/microbot-service       NodePort    10.152.183.69
kube-system   service/heapster               ClusterIP   10.152.183.7  
kube-system   service/kube-dns               ClusterIP   10.152.183.10 
kube-system   service/kubernetes-dashboard   ClusterIP   10.152.183.64 
kube-system   service/monitoring-grafana     ClusterIP   10.152.183.3  
kube-system   service/monitoring-influxdb    ClusterIP   10.152.183.203


NAMESPACE     NAME                                             
default       deployment.apps/microbot                         
kube-system   deployment.apps/coredns                          
kube-system   deployment.apps/heapster-v1.5.2                  
kube-system   deployment.apps/kubernetes-dashboard             
kube-system   deployment.apps/monitoring-influxdb-grafana-v4   

 At the very top we have the microbot pods, service/microbot
-service is the second in the services list. Our service has a ClusterIP through which we can access it.
Notice, however, that our service is of type NodePort. This means that our deployment is also available on a port on the host machine;
that port is randomly selected and in this case it happens to be 32648. 
All we need to do is to point our browser to http://localhost:32648.

Tip solutie

Permanent

Voteaza

(17 din 32 persoane apreciaza acest articol)

Despre Autor

Leave A Comment?