diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d1cca33..a317118 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -51,11 +51,10 @@ jobs: - name: Check links run: | - liche -r docs -d $(pwd) -c 10 -p -h -l -s -i '^README\.md$' -x '^(.*golang.org.*|.*github.com.*|.*api.slack.com.*|.*twitter.com.*|.*linode.com.*|.*helm.sh.*|.*k8s.io.*|.*percona.com.*|.*kubernetes.io.*|.*search-guard.com.*|.*hub.docker.com.*|.*appscode.com.*|.*mongodb.com.*|.*community.arm.com.*|.*cluster.com.*|.*proxysql.com.*|.*postgresql.org.*|.*kafka.com.*|.*stackoverflow.com.*|.*redis.io.*|.*elastic.co.*|.*mysql.*|.*developer.hashicorp.com.*|.*pgpool.net.*|.*clickhouse.com.*|.*portal.azure.com.*|.*vultr.com.*|.*youtube.com.*)$' max_retries=5 retry_count=0 while [ $retry_count -lt $max_retries ]; do - if liche -r docs -d $(pwd) -c 10 -p -h -l -s -i '^README\.md$' -x '^(.*golang.org.*|.*github.com.*|.*api.slack.com.*|.*twitter.com.*|.*linode.com.*|.*helm.sh.*|.*k8s.io.*|.*percona.com.*|.*kubernetes.io.*|.*search-guard.com.*|.*hub.docker.com.*|.*appscode.com.*|.*mongodb.com.*|.*community.arm.com.*|.*cluster.com.*|.*proxysql.com.*|.*postgresql.org.*|.*kafka.com.*|.*stackoverflow.com.*|.*redis.io.*|.*elastic.co.*|.*mysql.*|.*developer.hashicorp.com.*|.*pgpool.net.*|.*clickhouse.com.*|.*portal.azure.com.*|.*vultr.com.*|.*youtube.com.*)$'; then + if liche -r docs -d $(pwd) -c 10 -p -h -l -s -i '^README\.md$' -x '^(.*golang.org.*|.*github.com.*|.*api.slack.com.*|.*twitter.com.*|.*linode.com.*|.*helm.sh.*|.*k8s.io.*|.*percona.com.*|.*kubernetes.io.*|.*search-guard.com.*|.*hub.docker.com.*|.*appscode.com.*|.*mongodb.com.*|.*community.arm.com.*|.*cluster.com.*|.*proxysql.com.*|.*postgresql.org.*|.*kafka.com.*|.*stackoverflow.com.*|.*redis.io.*|.*elastic.co.*|.*mysql.*|.*developer.hashicorp.com.*|.*pgpool.net.*|.*clickhouse.com.*|.*portal.azure.com.*|.*vultr.com.*|.*youtube.com.*|.*scaleway.com.*)$'; then echo "Link check passed" exit 0 fi diff --git a/docs/platform/guides/cluster-management/cluster-upgrade.md b/docs/platform/guides/cluster-management/cluster-upgrade.md index 2029835..065df93 100644 --- a/docs/platform/guides/cluster-management/cluster-upgrade.md +++ b/docs/platform/guides/cluster-management/cluster-upgrade.md @@ -41,18 +41,38 @@ Each tier is upgraded separately; the order matters. ## Pre-checks -Before starting, verify your current installer version and target release. - -1. Log in to [appscode.com](https://appscode.com) and switch to your organization. -2. Navigate to your installer and click **View Details**. -3. Note the **current version** (e.g., `2025.5.16`) and confirm the **target version** - (e.g., `2025.6.x`). +Complete every item before starting. Do not upgrade while any item fails — an upgrade on top +of an unhealthy cluster is much harder to troubleshoot. + +- [ ] **Versions known.** Log in to [appscode.com](https://appscode.com), switch to your + organization, open your installer, click **View Details**, and note the **current** and + **target** versions. Read the target release's CHANGELOG. +- [ ] **Tested on non-prod.** The same upgrade was applied to a QA / non-prod environment and + passed the [Post-checks](#post-checks). +- [ ] **AppsCode notified.** At least 72 hours ahead, with the maintenance window and the + clusters involved. +- [ ] **All HelmReleases Ready** on the management cluster and every spoke / imported cluster: + ```bash + # Prints nothing when every HelmRelease is Ready + kubectl get helmreleases -A --no-headers | grep -v True + ``` +- [ ] **Flux controllers running:** + ```bash + kubectl get pods -n flux-system + ``` +- [ ] **All spokes connected.** On the hub, every `ManagedCluster` shows `JOINED=True` and + `AVAILABLE=True`: + ```bash + kubectl get managedclusters + ``` + Remove or fix inactive clusters first (see + [Removing an Inactive Cluster](../troubleshooting.md#removing-an-inactive-cluster)). +- [ ] **No cluster import or removal in progress.** Every cluster reports phase `Active` + through the API (see [Using the API](#using-the-api)). + +Keep a watch open during the upgrade: ```bash -# Confirm current Helm release versions on the management cluster -helm list -A | grep opscenter-features - -# Watch releases during upgrade kubectl get helmreleases -A -w ``` @@ -157,18 +177,75 @@ kubectl get clusterset -A ### Step 6 — Verify +Run the [Post-checks](#post-checks). + +--- + +## Post-checks + +Run on the management cluster and on every spoke / imported cluster. The upgrade is complete +only when every item passes. + +- [ ] **All HelmReleases Ready:** + ```bash + # Prints nothing when every HelmRelease is Ready + kubectl get helmreleases -A --no-headers | grep -v True + ``` +- [ ] **All HelmReleases on the target chart version:** + ```bash + kubectl get helmreleases -A \ + -o custom-columns=NAMESPACE:.metadata.namespace,NAME:.metadata.name,REVISION:.status.lastAttemptedRevision + ``` +- [ ] **No Helm release stuck in a pending state:** + ```bash + # Prints nothing when every release is deployed + helm list -A --all --no-headers | grep -v deployed + ``` +- [ ] **All pods healthy:** + ```bash + kubectl get pods -A --no-headers | grep -vE 'Running|Completed' + ``` +- [ ] **All spokes connected.** On the hub, every `ManagedCluster` shows `JOINED=True` and + `AVAILABLE=True`: + ```bash + kubectl get managedclusters + ``` +- [ ] **Cluster set updated** (Step 5) and no longer shown as unaligned. +- [ ] **Every cluster `Active`** through the API (see [Using the API](#using-the-api)). + +If any check fails, see [Troubleshooting](../troubleshooting.md). + +--- + +## Using the API + +The same checks can be scripted against the +[Clusters (v2) API](../../../api/cluster-management-v2/clusters.md). Paths are relative to +`https:///api/v1`; send `Authorization: token `. + +| Purpose | Call | +|---|---| +| List clusters | `GET /clustersv2/{owner}` | +| Status of one cluster | `GET /clustersv2/{owner}/{cluster}/status` | +| Import a cluster | `POST /clustersv2/{owner}/import` | +| Remove a cluster | `POST /clustersv2/{owner}/{cluster}/remove` | +| Force a reconcile of a feature's HelmReleases | `GET /clustersv2/{owner}/{cluster}/reconcile?features=` | + +Check the phase of every cluster: + ```bash -# Check every Helm release is at the new version across all clusters -for ctx in management spoke imported; do - echo "=== $ctx ===" - helm list -A --kube-context $ctx | grep -v DEPLOYED +api=https:///api/v1/clustersv2/ +for c in $(curl -s -H "Authorization: token $TOKEN" "$api" | jq -r '.[].name'); do + curl -s -H "Authorization: token $TOKEN" "$api/$c/status" \ + | jq -r '"\(.name)\t\(.status.response.phase)"' done - -# Spot-check the search manager (may self-update from the cluster side) -kubectl get deployment search-manager -n ace -o jsonpath='{.spec.template.spec.containers[0].image}' ``` -All clusters should report version `6.6.16` (or your target release). +`Active` means healthy. `Inactive` means the platform cannot reach the cluster (see +[Removing an Inactive Cluster](../troubleshooting.md#removing-an-inactive-cluster)). + +`remove` is asynchronous: call it once and poll `status`. See +[Removing through the API](../troubleshooting.md#removing-through-the-api). --- diff --git a/docs/platform/guides/cluster-management/remove-cluster.md b/docs/platform/guides/cluster-management/remove-cluster.md index 8459332..d931fd4 100644 --- a/docs/platform/guides/cluster-management/remove-cluster.md +++ b/docs/platform/guides/cluster-management/remove-cluster.md @@ -53,3 +53,6 @@ From the cluster list, click the **⋮** (three-dot) menu on any cluster card to |---|---|---| | **Remove** | Unregisters cluster from Cluster UI | No | | **Delete** | Destroys cluster + infrastructure | Yes | + +To remove a cluster through the API, or to remove an inactive cluster, see +[Troubleshooting](../troubleshooting.md#removing-a-cluster). diff --git a/docs/platform/guides/cluster-management/troubleshooting.md b/docs/platform/guides/cluster-management/troubleshooting.md new file mode 100644 index 0000000..6966654 --- /dev/null +++ b/docs/platform/guides/cluster-management/troubleshooting.md @@ -0,0 +1,197 @@ +--- +layout: docs +menu: + docsplatform_{{.version}}: + identifier: cluster-management-troubleshooting + name: Troubleshooting + parent: cluster-management + weight: 90 +menu_name: docsplatform_{{.version}} +section_menu_id: guides +--- + +# Troubleshooting Clusters + +This page covers the most common problems seen while upgrading, reconciling, and removing +clusters managed by the KubeDB Platform. Each section follows the same pattern: +**Symptom → Check → Fix**. + +Terms used below: + +- **Hub cluster** — the cluster running the Open Cluster Management (OCM) hub. It holds one + `ManagedCluster` object per spoke. +- **Spoke cluster** — a cluster joined to the hub. It runs the `klusterlet` agent, installed + by the `cluster-manager-spoke` Helm chart. +- **HelmRelease (HR)** — the FluxCD resource through which every platform feature is + installed (see [Feature Reference](../feature-reference.md)). + +--- + +## Before You Start + +Collect the current state first. Run these against the cluster that shows the problem. + +```bash +# All HelmReleases and their Ready status +kubectl get helmreleases -A + +# Only the ones that are not Ready +kubectl get helmreleases -A | grep -v True + +# Flux controllers must be running +kubectl get pods -n flux-system +``` + +On the hub cluster, check the spoke's connection state: + +```bash +kubectl get managedclusters +``` + +``` +NAME HUB ACCEPTED MANAGED CLUSTER URLS JOINED AVAILABLE AGE +monitoring-1 true https://10.2.1.87:6443 True Unknown 12d +``` + +`AVAILABLE=Unknown` means the spoke's agent stopped reporting to the hub (the cluster is +**inactive**). See [Removing an Inactive Cluster](#removing-an-inactive-cluster). + +Through the API, the same information is available from +[`GET /clustersv2/{owner}/{cluster}/status`](../../../api/cluster-management-v2/clusters.md). + +--- + +## Stuck Reconciliation + +### Symptom + +A HelmRelease stays `Ready=Unknown` with the message `Reconciliation in progress`, or the +version shown in the UI does not change after an upgrade. + +### Check + +```bash +kubectl describe helmrelease -n +``` + +Look at the `Conditions` and `Events` sections. The common causes: + +| What you see | Cause | +|---|---| +| `spec.suspend: true` | The HelmRelease is suspended and will not reconcile. | +| `HelmChart ... is not ready` / `source not found` | The chart source (HelmRepository / HelmChart) is failing. | +| `dependency ... is not ready` | A HelmRelease listed in `spec.dependsOn` is not Ready yet. | +| No new events for a long time | The Flux controllers are not running or are crash-looping. | + +### Fix + +1. **Suspended** — resume it: + ```bash + kubectl patch helmrelease -n --type merge -p '{"spec":{"suspend":false}}' + ``` +2. **Source not ready** — check the source object and the source-controller logs: + ```bash + kubectl get helmrepositories,helmcharts -A | grep -v True + kubectl logs -n flux-system deploy/source-controller --tail=100 + ``` +3. **Dependency not ready** — fix the HelmRelease it depends on first; this one follows. +4. **Controllers not running** — check `kubectl get pods -n flux-system` and the + `helm-controller` logs: + ```bash + kubectl logs -n flux-system deploy/helm-controller --tail=100 + ``` +5. **Force a reconcile** once the cause is fixed: + ```bash + kubectl annotate helmrelease -n \ + reconcile.fluxcd.io/requestedAt="$(date +%s)" --overwrite + ``` + From the API, [`GET /clustersv2/{owner}/{cluster}/reconcile?features=`](../../../api/cluster-management-v2/clusters.md) + does the same for the HelmReleases of the given features. + +--- + +## HelmRelease Progress Issues + +### Symptom + +A HelmRelease shows `Ready=False` with a reason such as `InstallFailed`, `UpgradeFailed`, or +`RetriesExceeded`, and the upgrade does not move forward. + +### Check + +```bash +kubectl get helmrelease -n \ + -o jsonpath='{range .status.conditions[*]}{.type}={.status} {.reason}: {.message}{"\n"}{end}' + +# Helm's own history of the release +helm history -n +``` + +### Fix + +| Situation | Fix | +|---|---| +| A pod in the release does not become Ready (image pull, resources, probe) | Fix the workload (`kubectl describe pod`, `kubectl logs`). Then force a reconcile (see above). | +| `RetriesExceeded` | Fix the cause, then suspend and resume the HelmRelease to reset the retry counter. | +| `helm history` shows the last revision as `pending-install`, `pending-upgrade`, or `pending-rollback` | A previous Helm operation was interrupted and holds the release lock. Roll back to the last `deployed` revision with `helm rollback -n `, then force a reconcile. | + +Suspend and resume: + +```bash +kubectl patch helmrelease -n --type merge -p '{"spec":{"suspend":true}}' +kubectl patch helmrelease -n --type merge -p '{"spec":{"suspend":false}}' +``` + +--- + +## Removing a Cluster + +### Removing through the API + +[`POST /clustersv2/{owner}/{cluster}/remove`](../../../api/cluster-management-v2/clusters.md) +is **asynchronous**: `200` means the removal task was accepted, not that it finished. + +- Call it **once**. +- Poll [`GET /clustersv2/{owner}/{cluster}/status`](../../../api/cluster-management-v2/clusters.md) + to follow progress. The cluster is removed when it no longer appears in the cluster list. +- Do not call `remove` again while the first removal is running. A second call returns + `409 Conflict` with `cluster removal already in progress`. + +### Removing an Inactive Cluster + +When a spoke is inactive (`AVAILABLE=Unknown` on the hub), the platform cannot reach it, so +removal skips the spoke-side cleanup. The spoke's `ManagedCluster` object stays on the hub +and must be removed manually. + +**On the hub cluster:** + +1. Delete the `ManagedCluster`. This is the only hub object you need to remove; OCM cleans up + the cluster's namespace, ManifestWorks, and add-ons. + ```bash + kubectl delete managedcluster --wait=false + kubectl get managedcluster + ``` +2. If it stays in `Terminating`, the finalizers are waiting for an agent that no longer + responds. Remove them: + ```bash + kubectl patch managedcluster --type merge -p '{"metadata":{"finalizers":null}}' + ``` + +**On the spoke cluster** (if you can still reach it): + +1. Check whether the OCM agent is still installed: + ```bash + kubectl get klusterlet + helm ls -A --all | grep cluster-manager-spoke + ``` +2. If either returns a result, the spoke still thinks it belongs to the hub. Uninstall the + chart using the namespace shown by `helm ls`: + ```bash + helm uninstall cluster-manager-spoke -n + ``` +3. If the `klusterlet` object stays in `Terminating`, remove its finalizers: + ```bash + kubectl patch klusterlet klusterlet --type merge -p '{"metadata":{"finalizers":null}}' + ``` + +See also [Remove / Delete Cluster](../remove-cluster.md) for removing a cluster from the UI.