Portainer with Docker & K8s

What is Portainer

Portainer is a open-source tool for managing containerized application . It works with k8s , Docker , Docker Swarm and Azure ACI

Portainer removes the complexities of using the cli , write YAML or understand manifests and gives you a visual view into your container environment , with a single command you can install portainer as a container and start administrating your environment.

Installation (Install Portainer with Docker on WSL / Docker Desktop)

d1.jpg

This section explains how to install portainer , we are going to install the community edition

Install Portainer

Step 1 : Setup a new Portainer server installation . Portainer consists of two elements, the Portainer Server, and the Portainer Agent. Both elements run as lightweight Docker containers on a Docker engine.

Step 2 : Lets create a volume that portainer server will use a database

docker volume create portainer_data

Then, download and install the Portainer Server container:

docker run -d -p 8000:8000 -p 9443:9443 --name portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:latest

Portainer server has now been Installed you can check by using

Docker ps

in your cmd

Step 3: Logging in You can access the portainer server by opening a web browser and going into

https://localhost:9443

by default it listens on port 9443

Lets now Dive into the server Instance we just installed using Docker container

The below section describes how to manage docker environment using menu options avilabe in the portainer server

Dashboard

The Docker dashboard summarizes your Docker Standalone environment and shows the components that make up the environment.

Environment Info

In this section you can see the environment names its URL , You can also see the number of CPU cores , the Docker version, and whether or not the Portainer Agent is installed.

Summary Tiles

Next thing we have on the dashboard is tiles showing the number of stacks , services , containers , images , volumes and networks .

If you have created your application using docker compose you can see the stack

Containers In the container sections you can see all the container running and it gives you all the information you would want to know about the containers and its very handy and easy to implement through the UI provided by portainer without running any commands you can even interact with them .

Images If you want to download image or do any image management , you can build a new image , remove a image , import or export them you can also search docker hub and pull the images . Again all this can be done with the help of UI provided by portainer without remembering any commands and using them in cli

Networks In the Networks tab you can Add/Remove the network , you can see three networks which is by default for the system

Volumes In the volumes section you can see all the information you need to know about volumes you can go ahead and Add/Remove them

Events Events shows you all the events that happen in your docker system just another way to visulaize them , you can search for specific events as well

Host overview section gives you the information about the host that portainer is managing

Portainer with k8s

k1.png

Deploying with Helm

Ensure you're using at least helm v3.2, which includes support for the --create-namespace argument.

Install the repository:

helm repo add portainer https://portainer.github.io/k8s/
helm repo update

you can install the community edition using Nodeport

helm install --create-namespace -n portainer portainer portainer/portainer

or Loadbalancer

helm install --create-namespace -n portainer portainer portainer/portainer \
--set service.type=LoadBalancer

or ClusterIP with an ingress

helm install --create-namespace -n portainer portainer portainer/portainer \
--set service.type=ClusterIP

In the home section we can see the local cluster where the portainer is installed it has 5 namespaces but you can only see one as the system resources are hidden

The dashboard section contains the Namespaces , configurations, applications and volume

namespaces we can also create a own namespace from the given form

applications You can add an application with an form, fill out the details you want for your application and tadaa! Apart from that you can also use the manifest and select the options based on your applications .

You can also the run the Kubectl shell directly from portainer

Helm In the helm section you can use any helm repository , select a chart and deploy that on to a cluster.

Templates Custom templates allows deploying any kind of k8s resource you can either copy or paste some pods defifnition file or we can write on our own

Config map and secrets you can not only just create application and deployments but also config map and secrets

Volumes you can create the volumes as well you can see the storage classes (local host which comes by default

This was all for your local cluster

moving ahead by creating your own cluster

Creating another cluster is made easy by portainer, you can deploy the cluster within a few steps
and can group the clusters and deploy your application there using the environment section from the dashboard. You can add an Agent, Edge cluster, Docker, and k8s Local cluster and easily switch between the clusters.

Conclusion

Portainer is the best tool to assist you in learning docker and k8s. It's very convenient for advanced users as well. It is helping us in connecting the clusters, docker swarm environment, and Azure ACI with the help of the Dashboard it provides

Now we have understood the concept of Portainer and how it is used along with Docker and K8s, I hope you have gotten the knowledge and why it is easy to use. Here are a few links to their official page, and Github page, Do check it out

Portainer

github.com/portainer/k8s

Go ahead and get your hands dirty , Explore and Learn .