Add a cluster to a team space#
Lens paid subscription feature
This page provides instructions on adding clusters to team spaces and removing them.
Prerequisites#
Make sure that the following requirements are met:
- You have connection to the cluster from your local machine
- You have the Admin or Owner role of the corresponding team space, and/or you have created the cluster on your local machine
Connect a cluster to a team space#
To connect a cluster to a team space:
-
In Navigator, click Add new cluster to space against the team space.
-
In the following dialog menu, specify the following parameters:
- Cluster name Name of the cluster
- Region The region that is geographically closest to the cluster
Click Generate Installation Command
-
In the following dialog menu, check the parameters and click Copy.
- Optional. Click Download YAML to get Kubernetes resources for the space agent installation.
- From your cluster, open the Terminal.
- Insert the command from the step 3.
The system starts displaying messages about completion of installation of Kubernetes resources for the space agent. After installation, the cluster appears in the team space section in Navigator. To connect to the cluster, right-click on the cluster and select Connect.
- In the Teamwork section of the Navigator, click against the team space name.
-
In the following dialog menu, set the following parameters:
-
Cluster Name
Type the cluster name.
-
Make sure that the cluster is visible in Catalog > Clusters, team space members can start working with the cluster.
Remove a cluster from a team space#
To remove a cluster from a team space:
- Right-click against the cluster in Navigator and select Remove from Space.
- In the Remove Cluster from Space dialog, click Copy Command to delete the agent deployment.
- Click Yes.
This action removes your cluster from the team space and it disappears from the corresponing section of Navigator. However, the agent continues to run in the cluster. Remove all associated Kubernetes resources manually.
- In the Navigator, right-click the team space cluster and select Remove from Space.
- In the following dialog, click Yes.
If successful, the Add Cluster to Space button is replaced with Remove Cluster from Space. Lens Desktop removes the cluster from the space. The agent deployment deletes from your cluster automatically with all associated Kubernetes resources.
An error might disrupt the deletion process and some resources may remain in the cluster. In this case, remove associated Kubernetes resources manually.
Delete the agent deployment#
- From your cluster, open the Terminal.
-
Insert the following command:
kubectl delete ns lens-platform kubectl get clusterrolebindings.rbac.authorization.k8s.io -o name | grep bored-agent | xargs kubectl delete kubectl get clusterrolebindings.rbac.authorization.k8s.io -o name | grep lens-platform | xargs kubectl delete kubectl get clusterrole -o name | grep bored-agent | xargs kubectl delete kubectl get clusterrole -o name | grep lens-spaces | xargs kubectl delete kubectl get clusterrole -o name | grep lens-cluster | xargs kubectl delete kubectl get priorityclass -o name | grep lens-cluster | xargs kubectl delete
Tip
You can find this command in the Remove Cluster from Space dialog.
kubectl delete ns lens-platform kubectl get clusterrolebindings.rbac.authorization.k8s.io -o name | Select-String "bored-agent" | ForEach-Object { kubectl delete $_.Line } kubectl get clusterrolebindings.rbac.authorization.k8s.io -o name | Select-String "lens-platform" | ForEach-Object { kubectl delete $_.Line } kubectl get clusterrole -o name | Select-String "bored-agent" | ForEach-Object { kubectl delete $_.Line } kubectl get clusterrole -o name | Select-String "lens-spaces" | ForEach-Object { kubectl delete $_.Line } kubectl get clusterrole -o name | Select-String "lens-cluster" | ForEach-Object { kubectl delete $_.Line } kubectl get priorityclass -o name | Select-String "lens-cluster" | ForEach-Object { kubectl delete $_.Line }
Execution of this command sequence deletes:
- The namespace where the agent is deployed along with related objects (secrets, service accounts, config maps, and others).
- All ClusterRoles required for the agent to work correctly.
- All ClusterRoleBindings associated with the agent.
- A PriorityClass linked to the agent.