|
| 1 | +# Uninstall CloudPilot |
| 2 | +This document provides a step-by-step guide to uninstall CloudPilot from your Kubernetes cluster, including resolving issues caused by improper removal. Follow these instructions carefully to ensure a complete and clean uninstallation. |
| 3 | + |
| 4 | +--- |
| 5 | + |
| 6 | +## Prerequisites |
| 7 | +Before proceeding, ensure the following: |
| 8 | +1. You have initiated the **"Remove"** operation for the cluster in the CloudPilot **Cost Overview** page. |
| 9 | +2. You have: |
| 10 | + - `kubectl` configured with cluster access. |
| 11 | + - `curl` and `jq` installed. |
| 12 | + - The CloudPilot API key for your cluster. |
| 13 | + - AWS or AlibabaCloud credentials (if applicable) for cluster modifications. |
| 14 | + |
| 15 | +--- |
| 16 | + |
| 17 | +## Step 1: Disable CloudPilot AI Rebalance |
| 18 | +Disable the CloudPilot AI Rebalance feature to prevent automated node adjustments during uninstallation. This ensures cluster stability while removing components. |
| 19 | + |
| 20 | +--- |
| 21 | + |
| 22 | +## Step 2: Restore Node Group Configurations |
| 23 | +Run the script below to revert any node group scaling adjustments made by CloudPilot. Replace `xxx` with your cluster name and region. |
| 24 | +```bash |
| 25 | +export CLUSTER_NAME=xxx |
| 26 | +export CLUSTER_REGION=us-east-2 |
| 27 | +curl --silent "https://onboard.cloudpilot.ai/common/eks/restore.sh" | bash |
| 28 | +``` |
| 29 | + |
| 30 | +--- |
| 31 | + |
| 32 | +## Step 3: Drain and Remove Optimized Nodes |
| 33 | +Drain and delete all CloudPilot-managed nodes from the cluster. |
| 34 | + |
| 35 | +1. **Drain nodes**: |
| 36 | + ```bash |
| 37 | + for node in $(kubectl get node -l node.cloudpilot.ai/managed=true 2> /dev/null | grep -v 'No resources found' | tail -n +2 | awk '{print $1}'); do kubectl drain $node --ignore-daemonsets --delete-emptydir-data --force; done |
| 38 | + ``` |
| 39 | + |
| 40 | +2. **Verify removal**: |
| 41 | + ```bash |
| 42 | + while [[ $(kubectl get nodes -l node.cloudpilot.ai/managed=true -o json | jq -r '.items | length') -ne 0 ]]; do echo "Waiting for CloudPilot AI nodes to be removed..."; sleep 3; done |
| 43 | + ``` |
| 44 | + |
| 45 | +--- |
| 46 | + |
| 47 | +## Step 4: Run the Uninstallation Script |
| 48 | +Execute the uninstall script to remove CloudPilot components. Replace `xxx` with your cluster-specific values. |
| 49 | +```bash |
| 50 | +export CLOUDPILOT_API_KEY=xxx |
| 51 | +export CLOUD_PROVIDER=aws |
| 52 | +export CLUSTER_ID=xxx |
| 53 | +export CLUSTER_NAME=xxx |
| 54 | +export CLUSTER_REGION=us-east-2 |
| 55 | +export AWS_PARTITION=aws |
| 56 | +curl --silent "https://onboard.cloudpilot.ai/manifest/v1.10.0/eks/uninstall.sh" | bash |
| 57 | +``` |
| 58 | + |
| 59 | +--- |
| 60 | + |
| 61 | +## Step 5: Finalize Cluster Removal |
| 62 | +In the CloudPilot console, click **`I have ran the script, finish removing cluster`** to complete the process. |
| 63 | + |
| 64 | +**Expected time**: 5–10 minutes. Monitor cluster status before performing further actions. |
| 65 | + |
| 66 | +--- |
| 67 | + |
| 68 | +## More |
| 69 | + |
| 70 | +### Troubleshooting Improper Uninstallation |
| 71 | +**Symptoms**: |
| 72 | +- Pod creation failures. |
| 73 | +- NodeClaim operations suspended (nodes cannot be created/deleted). |
| 74 | + |
| 75 | +**Cause**: Direct deletion of the `cloudpilot` namespace without following proper procedures. |
| 76 | + |
| 77 | +**Resolution**: |
| 78 | +1. Remove the orphaned webhook configuration: |
| 79 | + ```bash |
| 80 | + kubectl delete mutatingwebhookconfigurations.admissionregistration.k8s.io cloudpilot-webhook |
| 81 | + ``` |
| 82 | +2. Reinstall the CloudPilot agent using the script from the **Add cluster** button: |
| 83 | + ```bash |
| 84 | + export CLOUDPILOT_API_KEY=xxx |
| 85 | + export CLOUD_PROVIDER=aws |
| 86 | + curl --silent "https://onboard.cloudpilot.ai/manifest/v1.10.0/phase1/cloudpilot-agent.yaml" | envsubst | kubectl apply -f - |
| 87 | + ``` |
| 88 | +3. Reinstall CloudPilot fully using the **Start Saving** button script. |
| 89 | + ```bash |
| 90 | + export CLOUDPILOT_API_KEY=xxx |
| 91 | + export CLOUD_PROVIDER=aws |
| 92 | + export CLUSTER_ID=xxx |
| 93 | + export CLUSTER_NAME=xxx |
| 94 | + export CLUSTER_REGION=us-east-2 |
| 95 | + export AWS_PARTITION=aws |
| 96 | + curl --silent "https://onboard.cloudpilot.ai/manifest/v1.10.0/eks/phase2/install.sh" | bash |
| 97 | + ``` |
| 98 | +4. Re-run the normal uninstallation process. |
| 99 | + |
| 100 | +--- |
| 101 | + |
| 102 | +If issues persist, contact CloudPilot Technical Support immediately for assistance. |
0 commit comments