enhancement(monitoring): replace import options with protect
The import options fail on a fresh cluster, where the namespace and Helm release do not exist yet. Protect both resources instead, and update the rebuild runbook because clearing protected state requires --force.
This commit is contained in:
1 parent
c6aa571a5c
commit
b1aff90ffd
3 files changed
+6
-7
No files matched your search
@@ -1,3 +1,3 @@
|
||||
# monitoring
|
||||
|
||||
- The `monitoring` namespace and the `kube-prometheus-stack` Helm release were adopted from existing cluster resources via the Pulumi `import` option. Be careful with renames or changes that would force a replace.
|
||||
- The `monitoring` namespace and the `kube-prometheus-stack` Helm release were originally adopted from existing cluster resources and are now `protected`. Be careful with renames or changes that would force a replace.
|
||||
@@ -29,7 +29,7 @@ const k8sProvider = new k8s.Provider("k3s", {
|
||||
const monitoringNs = new k8s.core.v1.Namespace(
|
||||
"monitoring",
|
||||
{ metadata: { name: "monitoring" } },
|
||||
{ provider: k8sProvider, import: "monitoring" },
|
||||
{ provider: k8sProvider, protect: true },
|
||||
);
|
||||
|
||||
const grafanaHost = pulumi.interpolate`grafana.${domain}`;
|
||||
@@ -101,5 +101,5 @@ new k8s.helm.v3.Release(
|
||||
alertmanager: { enabled: false },
|
||||
},
|
||||
},
|
||||
{ provider: k8sProvider, import: "monitoring/kube-prometheus-stack" },
|
||||
{ provider: k8sProvider, protect: true },
|
||||
);
|
||||
@@ -8,7 +8,6 @@ Use this to rebuild the k3s cluster from new VMs. **It destroys everything store
|
||||
|
||||
- **`02-k8s-bootstrap` commands run once.** They are recorded as done in state, so after new VMs appear, `pulumi up` would report them unchanged and install nothing.
|
||||
- **`03`–`05` state describes the old cluster.** The fixed `clusterIdentifier` tells Pulumi it is still the same cluster, so it would try to update resources that no longer exist.
|
||||
- **`05-monitoring` adopts existing resources.** Its two `import` options fail on a fresh cluster, where those resources don't exist yet.
|
||||
|
||||
## Before you start
|
||||
|
||||
@@ -60,11 +59,11 @@ Use this to rebuild the k3s cluster from new VMs. **It destroys everything store
|
||||
|
||||
## 2. Clear the state of `02`–`05`
|
||||
|
||||
Only do this after the old VMs are gone. It removes Pulumi's records and doesn't touch real resources or `Pulumi.dev.yaml`.
|
||||
Only do this after the old VMs are gone. It removes Pulumi's records and doesn't touch real resources or `Pulumi.dev.yaml`. `--force` is needed because `05-monitoring` protects its namespace and Helm release, so check that the old cluster is really gone before running it.
|
||||
|
||||
```bash
|
||||
for S in 05-monitoring 04-k8s-apps 03-k8s-infra 02-k8s-bootstrap; do
|
||||
pulumi state delete --all --yes --stack dev --cwd "$S"
|
||||
pulumi state delete --all --force --yes --stack dev --cwd "$S"
|
||||
done
|
||||
```
|
||||
|
||||
@@ -94,7 +93,7 @@ Deploy these through Gitea, because the runners have the `helm` CLI that `03` ne
|
||||
|
||||
1. Run the **Deploy k8s Infra** workflow manually.
|
||||
2. Run the **Deploy k8s Apps** workflow manually.
|
||||
3. Open a PR that removes both `import` options from `05-monitoring/index.ts`, unless they are already gone. Re-enable the **Deploy Monitoring** workflow and merge the PR, which deploys `05`. If the options were already gone, run the workflow manually instead.
|
||||
3. Run the **Deploy Monitoring** workflow manually.
|
||||
|
||||
## 5. Verify
|
||||
|
||||
|
||||
Reference in new issue
Block a user