Kubernetes Deployments with Portainer: 
A Guide to GitOps Integration

Kubernetes Deployments with Portainer: A Guide to GitOps Integration


5 min read


In the age of containerized applications, managing deployments across Kubernetes clusters can be a complex and time-consuming task. Enter GitOps, the revolutionary approach that brings the power of Git version control to your Kubernetes deployments. But what if you could simplify GitOps even further? That's where Portainer comes in.

Portainer is a popular open-source container management platform that provides a user-friendly web interface for working with Docker and Kubernetes. With Portainer, you can smoothly control your Kubernetes clusters, handle deployments, and manage services—all from one easy-to-use dashboard.

While GitOps efficiently streamlines deployments, navigating command-line tools and complex YAML files can still be hurdles. Portainer offers a visual and user-friendly interface to tackle these challenges and simplify your GitOps workflow. It empowers you to seamlessly deploy applications directly from your Git repository, eliminating the need for manual YAML editing or intricate kubectl commands in most cases.

Getting started with Portainer


  • Pre-installed Kubernetes environment to install Portainer. Here we’ll be using Minikube (minikube.sigs.k8s.io/docs/start)

  • An application image published on a container registry (Dockerhub)

  • Git repository ready with the manifest files

  • Git Personal Access Token (PAT) generated

You can deploy Portainer on your Kubernetes cluster using various methods, including Helm charts, manifests, and the Portainer Agent. Here, we’ll be using Helm charts as it’s one of the most straightforward and simple ways of installing Portainer on your Kubernetes cluster.

Install Portainer on Kubernetes

Primarily, check if you have a storage class in your Kubernetes cluster (minikube in this case). Having a storage class allows you to store data in persistent volumes. To do that run the following command.

kubectl get sc

The output would look something like this.

standard (default)   k8s.io/minikube-hostpath   Delete          Immediate           false                  92d

Now run the following commands to add Portainer to Helm repo and update it. If it’s not updated, you would not be using the latest version of Helm charts.

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

Access the Portainer Web UI

To access the Portainer web UI, the method you choose will depend on how you wish to expose the Portainer service i.e., expose via NodePort, via Ingress or via LoadBalancer. Here, I’ll be using the LoadBalancer.

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

This command deploys or upgrades Portainer, a container management tool, within a Kubernetes cluster. It leverages Helm, a package manager for Kubernetes, to streamline the process. A brief break down of its components is as follows:

  • helm upgrade --install: This instructs Helm to either upgrade an existing Portainer installation or create a new one if it doesn't exist.

  • --create-namespace -n portainer: This directs Helm to create a dedicated namespace named "portainer" to isolate Portainer's resources within the cluster.

  • portainer portainer/portainer: The first "portainer" specifies a release name for tracking the deployment, while the second one refers to the Helm chart repository containing Portainer's installation package.

  • --set service.type=LoadBalancer: This configuration sets the Kubernetes service type for Portainer to "LoadBalancer." This enables external access to Portainer's web interface through a publicly accessible IP address provided by the cloud provider's load balancer.

kubectl get svc -n portainer

Will list out all the services within the portainer namespace. Now, finally to access the Web UI from the browser, run the following command.

kubectl port-forward service/portainer -n portainer 5500:9443

Using the above command, Portainer will be available at an assigned Load Balancer IP on port 9000 for HTTP and 9443 for HTTPS. By default, Portainer generates and uses a self-signed SSL certificate to secure port 9443. Alternatively you can provide your own SSL certificate during installation or via the Portainer UI after installation is complete. Now, you’ll be able to access the Portainer dashboard from https://localhost:5500. (You can change the port 5500 to any other port as per your requirements)

GitOps using Portainer

On the landing page, choose the “Local Environment” setup to continue setting up your Portainer dashboard to access the Kubernetes clusters running locally in minikube.

Under the namespaces tab, create a namespace. Here in this example, I’ll be going with the name portainer-app-gitops. Next, create an application by going to the “Applications” tab from the left panel menu and choose the option “create from manifests”.

Choose the namespace previously created and give it a name (here in my case it’s myapp-portainer-application.) Set the build method to “Git Repository” and deployment type to “Kubernetes.” Finally, add the repository URL, repository reference as per your repository structure. In my repository, I have added all my manifests to the main branch.

In my repository, I have two manifest files, deployment.yaml and service.yaml thus, I have two manifest paths. Therefore, under the “manifest path” option, I’ve added deployment.yaml and selected the “additional path” option and added service.yaml file. (Your paths can be different)

Finally, enable “Authentication” by adding your Github username and Personal Access Token (PAT). Also enable “GitOps Updates”, set the Mechanism to “Polling” and the “Fetch Interval” to something like 2m or 5m (minutes). This can be adjusted as per your requirements. Here's a long screenshot of my configuration.

Now, you’re good to go. Whenever you make a change to your Git repository, you can see that the cluster gets updated within the “Fetch Interval”. You can see the number of pods changing as per the edits made on the Git repository.

Beyond Deployments

Portainer's capabilities extend beyond simply deploying applications. You can leverage it to manage various aspects of your Kubernetes environment, including:

  • Namespaces and workload resources: Create and manage namespaces, deployments, pods, services, and other Kubernetes resources.

  • Storage and networking: Configure persistent storage volumes and network policies for your applications.

  • Security and access control: Implement security best practices and manage user access through RBAC (Role-Based Access Control.)


In the world of Kubernetes and GitOps, Portainer is like a superhero. It makes things super easy for developers and operations teams by giving them a friendly interface. With Portainer, you can smoothly handle GitOps workflows, make deployments simpler, and take full control of your Kubernetes setup. It doesn't matter if you're a pro at Kubernetes or just getting started with containers—Portainer helps you make sense of GitOps and get the most out of your Kubernetes projects.

Did you find this article valuable?

Support Aftab S by becoming a sponsor. Any amount is appreciated!