VOOZH about

URL: https://thenewstack.io/portainer-how-to-add-a-kubernetes-environment/

⇱ Portainer: How to add a Kubernetes Environment - The New Stack


TNS
SUBSCRIBE
Join our community of software engineering leaders and aspirational developers. Always stay in-the-know by getting the most important news and exclusive content delivered fresh to your inbox to learn more about at-scale software development.
REQUIRED
It seems that you've previously unsubscribed from our newsletter in the past. Click the button below to open the re-subscribe form in a new tab. When you're done, simply close that tab and continue with this form to complete your subscription.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.
Welcome and thank you for joining The New Stack community!
Please answer a few simple questions to help us deliver the news and resources you are interested in.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Great to meet you!
Tell us a bit about your job so we can cover the topics you find most relevant.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Welcome!

We’re so glad you’re here. You can expect all the best TNS content to arrive Monday through Friday to keep you on top of the news and at the top of your game.

What’s next?

Check your inbox for a confirmation email where you can adjust your preferences and even join additional groups.

Follow TNS on your favorite social media networks.

Become a TNS follower on LinkedIn.

Check out the latest featured and trending stories while you wait for your first TNS newsletter.

PREV
1 of 2
NEXT
VOXPOP
As a JavaScript developer, what non-React tools do you use most often?
Angular
0%
Astro
0%
Svelte
0%
Vue.js
0%
Other
0%
I only use React
0%
I don't use JavaScript
0%
Thanks for your opinion! Subscribe below to get the final results, published exclusively in our TNS Update newsletter:
NEW! Try Stackie AI
From clobbered drafts to real-time sync
Apr 14th 2026 10:00am, by David Moore
TypeScript 6.0 RC arrives as a bridge to a faster future
Mar 14th 2026 9:00am, by Darryl K. Taft
Mastra empowers web devs to build AI agents in TypeScript
Jan 28th 2026 11:00am, by Loraine Lawson
2022-06-12 04:00:30
Portainer: How to add a Kubernetes Environment
tutorial,
Containers / Kubernetes

Portainer: How to add a Kubernetes Environment

This tutorial walks you through how to connect Portainer to a remote Kubernetes cluster, which will either need to be on the same LAN or accessible via an accessible FDQN.
Jun 12th, 2022 4:00am by Jack Wallen
👁 Featued image for: Portainer: How to add a Kubernetes Environment

Let’s talk Portainer again, shall we?

One of the brilliant aspects of Portainer container management system is that it allows you to add multiple environments, which can then be assigned to different teams. With that setup, you might have one team given access to the local environment for development, one team might have access to an Azure environment for deployment, and yet another team might have access to an Edge agent.

One other type of Environment you can add is for Kubernetes. With this environment added, you can then manage your Kubernetes, which makes it possible to manage:

  • Namespaces
  • Helm
  • Applications
  • ConfigMaps & Secrets
  • Cluster

When you create an application in a Portainer Kubernetes environment, you can do so from a manifest or using the Portainer form GUI (which is similar to adding a full stack or container deployment within a Docker environment).

For anyone who manages Kubernetes, and has been looking for a solid web-based GUI, adding a Kubernetes environment to Portainer is a great way to go.

The method I’m going to walk you through allows you to connect Portainer to a remote Kubernetes cluster, which will either need to be on the same LAN or accessible via an accessible FDQN.

Let me show you how this is done. I’m going to assume all you have up and running is a Linux server (I’ll demonstrate on Ubuntu Server 22.04, from start to finish).

How to Install Docker

The first thing we’re going to do is install Docker. Log into your Ubuntu Server instance and install the necessary dependencies with:

sudo apt-get install ca-certificates curl gnupg lsb-release wget apt-transport-https  -y

Next, add the official Docker GPG key with the command:

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

We can now add the Docker stable repository:

echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

Finally, install Docker Engine with the following two commands:

sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io -y

Start and enable the Docker service with:

sudo systemctl enable --now docker

Next, you must add your user to the docker group with the command:

sudo usermod -aG docker $USER

Make the system aware of the new group with:

newgrp docker

How to Install kubectl and Minikube

We’re going to need both the kubectl command and Minikube installed. First, install kubectl with:

curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"

Install Kubectl with:

sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl

Next, we need to download the Minikube binary with:

wget https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64

Copy the binary to /usr/local/bin with:

sudo cp minikube-linux-amd64 /usr/local/bin/minikube

Give the binary executable permission with:

sudo chmod +x /usr/local/bin/minikube

How to Deploy Portainer

Next, we’ll deploy Portainer. First, create a volume (for persistent data) with:

docker volume create portainer_data

Deploy Portainer with Docker, using the command:

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

Give the container a bit of time to spin up and then point your browser to http://SERVER:9443 (Where SERVER is the IP address of the hosting server). You will then need to create an account for Portainer and log in.

How to Add the Kubernetes Environment

We can now add our Kubernetes environment to Portainer. Click on Environments (in the left sidebar) and then (in the resulting page), click Add Environment (Figure 1).

👁 Figure 1: I already have several environments configured in Portainer.

Figure 1: I already have several environments configured in Portainer.

In the next window (Figure 2), click the Agent tab.

👁 Figure 2: The Environments creation page in Portainer.

Figure 2: The Environments creation page in Portainer.

In the resulting window (Figure 3), click Kubernetes via node port to reveal the command you must run on your Kubernetes host. That command is:

curl -L https://downloads.portainer.io/portainer-agent-ce211-k8s-nodeport.yaml -o portainer-agent-k8s.yaml; kubectl apply -f portainer-agent-k8s.yaml

Once the command completes, go back to Portainer and fill out the information for the Environment. You’ll need to give the new environment a name (such as kube, k8s, minikube, etc.). Next, type the address of the Kubernetes server, as in:

https://192.168.1.13:9001
👁 Figure 3: Adding a new Kubernetes environment as an Agent.

Figure 3: Adding a new Kubernetes environment as an Agent.

If you want to assign the environment to a group, click the Group drop-down and select any group you’ve already created. Select any tags you’ve created and then click Add Environment. Click Add Environment and Portainer will connect to your Kubernetes cluster. Go back to the Portainer main window and you’ll see your new Kubernetes Environment listed (Figure 4).

👁 Figure 4: Our new Kubernetes environment has been successfully added.

Figure 4: Our new Kubernetes environment has been successfully added.

Congratulations, you’ve added Kubernetes into the Portainer mix. Enjoy that added power and flexibility.

TRENDING STORIES
Jack Wallen is what happens when a Gen Xer mind-melds with present-day snark. Jack is a seeker of truth and a writer of words with a quantum mechanical pencil and a disjointed beat of sound and soul. Although he resides...
Read more from Jack Wallen
SHARE THIS STORY
TRENDING STORIES
TNS owner Insight Partners is an investor in: Docker.
SHARE THIS STORY
TRENDING STORIES
TNS DAILY NEWSLETTER Receive a free roundup of the most recent TNS articles in your inbox each day.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.