Import an existing Kubernetes environment
With Portainer you can import your existing Kubernetes environment through the use of a kubeconfig file. Portainer will use the information in the kubeconfig file to connect to your environment then deploy and configure the Portainer Agent for you.
While we have tried to support as many configurations as possible, there are a few requirements in order to fully support the import process:
- Your cluster must have a load balancer configured and enabled.
- Your kubeconfig file must specify
- Your kubeconfig file must be self-contained (i.e., consist of only the one file with no external references).
- Your kubeconfig file must provide cluster admin level credentials, in order for Portainer to deploy the agent on your cluster.
Depending on your environment, there may be different methods for creating a supported kubeconfig file. The following environment types are currently supported:
For an on-premise cluster, you can use the following kubectl command to generate a supported kubeconfig file:
kubectl config view --flatten=true --minify=true > kubeconfig.yml
To create a kubeconfig file from a Civo cluster, log into the Civo dashboard and go to Kubernetes. Select the cluster to import and click on Click to Download next to the Kubeconfig label.
To create a kubeconfig file from a Linode cluster, log into the Linode dashboard and click on Kubernetes in the left hand menu. Select the cluster to import, and in the top right of the page select Actions then Download Config.
To create a kubeconfig file from a DigitalOcean cluster, log into the DigitalOcean dashboard and in the left hand menu select Manage then Kubernetes. Alternatively, go to Projects, select the project containing your cluster, then look in the Clusters panel. Select the cluster to import, then click the Kubeconfig option to download the kubeconfig file.
To create a kubeconfig file from an Azure cluster, download and install the Azure CLI from Microsoft. Start a shell session on Linux or an administrator PowerShell session on Windows, and run the following:
This command can take a couple of minutes to complete the first time it is used, and involves a browser window opening in order to authenticate you with Azure.
Once this completes and you are authenticated, run the following command:
az aks get-credentials --resource-group [resource-group-name] --name [cluster-name] --file ./kubeconfig-azure.yml
[resource-group-name]with the resource group containing your cluster. Replace
[cluster-name]with your cluster.
Once you have your kubeconfig file created, click on Environments then Add environment.
Select the Kubernetes option and click Start Wizard. Then select the Import option.
Enter a name for cluster then click Select a file to browse for your kubeconfig file.
As an optional step you can expand the More settings section to customize the deployment further.
When you're ready, click the Connect button. If you have other environments to configure click Next to proceed, otherwise click Close to return to the list of environments where you will see the progress of your provision.