Deploy Portainer in Linux environments
Deploy Portainer in Kubernetes
To deploy Portainer within a Kubernetes cluster, you can either use our HELM chart, or our provided manifests.
Pre-Req Note:
Portainer requires data persistence, and as a result needs at least one storage-class available to use. Portainer will attempt to use the "default" storage class during deployment. If you do NOT have a storage class tagged as "default" the deployment will likely fail.
You can check if you have a default storage class by running:
> kubectl get sc
and looking for a storage class with (default) after its name:
If you want to make a storage class the default, you can type the command:
>kubectl patch storageclass -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'
and replace
Alternatively, if you are using HELM you can use:
--set persistence.storageClass=
Using Helm
First, add the Portainer helm repo running the following:
helm repo add portainer https://portainer.github.io/k8s/
helm repo update
Then, create the Portainer namespace in your cluster
kubectl create namespace portainer
For NodePort
Using the following command, Portainer will run in the port 30777
helm install -n portainer portainer portainer/portainer
For Load Balancer
Using the following command, Portainer will run in the port 9000.
helm install -n portainer portainer portainer/portainer --set service.type=LoadBalancer
For Ingress
helm install -n portainer portainer portainer/portainer --set service.type=ClusterIP
Using YAML Manifest
First create the Portainer namespace in your cluster
kubectl create namespace portainer
For NodePort
Using the following command, Portainer will run in the port 30777
kubectl apply -n portainer -f https://raw.githubusercontent.com/portainer/k8s/master/deploy/manifests/portainer/portainer.yaml
For Load Balancer
kubectl apply -n portainer -f https://raw.githubusercontent.com/portainer/k8s/master/deploy/manifests/portainer/portainer-lb.yaml
Deploy Portainer in Docker
Portainer is comprised of two elements, the Portainer Server, and the Portainer Agent. Both elements run as lightweight Docker containers on a Docker engine or within a Swarm cluster. Due to the nature of Docker, there are many possible deployment scenarios, however, we have detailed the most common below. Please use the scenario that matches your configuration.
Note that the recommended deployment mode when using Swarm is using the Portainer Agent.
By default, Portainer will expose the UI over the port 9000 and expose a TCP tunnel server over the port 8000. The latter is optional and is only required if you plan to use the Edge compute features with Edge agents.
To see the requirements, please, visit the page of requirements.
Docker Standalone
Use the following Docker commands to deploy the Portainer Server; note the agent is not needed on standalone hosts, however it does provide additional functionality if used (see Portainer and agent scenario below):
docker volume create portainer_data
docker run -d -p 8000:8000 -p 9000:9000 --name=portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce
Docker Swarm
Deploying Portainer and the Portainer Agent to manage a Swarm cluster is easy! You can directly deploy Portainer as a service in your Docker cluster. Note that this method will automatically deploy a single instance of the Portainer Server, and deploy the Portainer Agent as a global service on every node in your cluster.
curl -L https://downloads.portainer.io/portainer-agent-stack.yml -o portainer-agent-stack.yml
docker stack deploy -c portainer-agent-stack.yml portainer
Note: By default this stack doesn't enable Host Management Features, you need to enable from the UI of Portainer.
Portainer Agent Deployments Only
Docker Standalone
Run the following command to deploy the Agent in your Docker host.
docker run -d -p 9001:9001 --name portainer_agent --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/docker/volumes:/var/lib/docker/volumes portainer/agent
Note: --tlsskipverify
has to be present when deploying an agent, since injecting valid, signed certs in the agent is not a supported scenario at present.
Docker Swarm
Deploy Portainer Agent on a remote LINUX Swarm Cluster as a Swarm Service, run this command on a manager node in the remote cluster.
First create the network:
docker network create portainer_agent_network
The following step is deploy the Agent:
docker service create --name portainer_agent --network portainer_agent_network --publish mode=host,target=9001,published=9001 -e AGENT_CLUSTER_ADDR=tasks.portainer_agent --mode global --mount type=bind,src=//var/run/docker.sock,dst=/var/run/docker.sock --mount type=bind,src=//var/lib/docker/volumes,dst=/var/lib/docker/volumes --mount type=bind,src=/,dst=/host portainer/agent
Note: --tlsskipverify
has to be present when deploy an agent and the certs in the agent is not a supported scenario at this moment.