Portainer is a powerhouse container administration platform that isn’t solely completely at dwelling with Docker deployments however with Kubernetes environments as properly. Nonetheless, as anybody who’s ever handled Kubernetes will inform you…it’s laborious. Given what number of transferring items are available with a Kubernetes cluster, until you actually know what you’re doing, you’ll discover managing such an surroundings could be an absolute nightmare.
Fortunately, there are GUIs like Portainer that go a really lengthy solution to simplify your Kubernetes expertise. Sure, you continue to must have an understanding of how Kubernetes works — you must find out about namespaces, pods, networks, purposes, ingresses, and way more. Think about having a web-based GUI to clear away a few of that confusion so you may really get to the necessary half…deploying your purposes and providers.
That’s what Portainer does and with the assist of MicroK8s, you may deploy Portainer in such a method as to make managing Kubernetes exponentially simpler.
Let me present you ways.
Necessities
To make this work, you’ll want not less than three machines operating Ubuntu Server 22.04 (as a result of that’s my go-to server distribution). Sure, you are able to do this on one other Linux distribution, however you’ll want to switch the set up process. The steps for deploying MicroK8s and Portainer are the identical, so when you get past the MicroK8s set up, every little thing right here will work because it stands.
Step 1: Set up MircoK8s
The very first thing we should do is set up MicroK8s. There may be, nevertheless, a trick. Portainer is not going to work with any model of MicroK8s sooner than 1.24. So as to add to that subject, I’ve discovered variations later than 1.24 don’t reliably cluster. Due to that, we’ll set up model 1.24 of MicroK8s. Listed here are the steps.
Edit the Hosts Recordsdata
The very first thing you’ll wish to do is edit the host information on all three machines. To open the file for enhancing, subject the command:
On the backside of that file, add the next (ensuring to make use of your IP addresses and hostnames):
192.168.1.70 k8s1 192.168.1.71 k8s2 192.168.1.72 k8s3 |
Save and shut the file. Be sure you edit the hosts file the identical method on all three machines.
Change the Hostnames
You’ll additionally want to vary the hostname for every machine. We’ll follow our conference above. On every machine, you’ll run a command like this:
sudo hostnamectl set–hostname k8s1 |
Do the identical factor on every machine, utilizing k8s2, and k8s3 as the opposite hostnames. When you’ve achieved that, sign off of every machine and log again in.
Set the Appropriate Timezone
Additionally, you will want to ensure all machines are on the identical (appropriate) timezone. For this, you’ll run a command like this:
sudo timedatectl set–timezone America/Kentucky/Louisville |
Ensure to substitute America/Kentucky/Louisville on your timezone, which could be discovered with the command:
sudo timedatectl listing–timezones |
Set up MicroK8s
MicroK8s could be simply put in on Ubuntu Server with snap. On every machine, you’ll subject the command:
sudo snap set up microk8s —channel=1.24/secure —traditional |
Subsequent, add your person to the MicroK8s group with:
sudo usermod –aG microk8s $USER |
Sign off and log again in.
Lastly, change the possession of the .kube folder with:
chown –f –R $USER ~/.kube |
With MicroK8s put in on all three machines, you’re able to create the cluster.
Cluster Your Machines
On the controller (k8s1), subject the command:
The output will embody the be part of command that you’ll run on all of your nodes. The command will look one thing like this:
microk8s be part of 192.168.1.70:25000/5c4af12af72cef10c631e5db00e3b3c5/5786c9b07835 |
Again on the controller, confirm the nodes have efficiently joined with the command:
microk8s kubectl get nodes |
The output ought to look one thing like this:
k8s1 Prepared <none> 9d v1.24.8–2+1dda18a15eea38 k8s2 Prepared <none> 9d v1.24.8–2+1dda18a15eea38 k8s3 Prepared <none> 9d v1.24.8–2+1dda18a15eea38 |
You’re now able to deploy Portainer to the cluster.
Deploying Portainer to the MicroK8s
On the controller you should first allow a number of add-ons, which could be achieved with the next instructions:
microk8s allow dns microk8s allow ha–cluster microk8s allow ingress microk8s allow metrics–server microk8s allow rbac microk8s allow hostpath–storage |
Subsequent, you should allow the MicroK8s group repository with the command:
microk8s allow group |
Lastly, you may allow Portainer with:
microk8s allow portainer |
Give Portainer a minute or so to complete deploying. To test on the standing of Portainer, subject the next command:
microk8s kubectl get pods –n portainer |
As soon as Portainer is listed in a operating state, open your default internet browser and level it to both http://SERVER:30777 or https://SERVER:30799 (the place SERVER is the IP tackle or area of the internet hosting server).
Portainer will immediate you to create a brand new admin person. When you’ve achieved that, make certain to pick the native surroundings and also you’ll then be greeted by the Portainer Dashboard (Determine 1), clearly displaying you could have a Kubernetes surroundings to work with.
And that’s all there may be to deploying the Portainer administration platform for a Kubernetes surroundings. Due to MicroK8s, it is a nice solution to stand up to hurry with Kubernetes with out being overwhelmed by too many instructions or the nightmare that may be deploying Kubernetes itself.