constellation/cli/internal/helm
Moritz Sanft 005e865a13
cli: use state file on init and upgrade (#2395)
* [wip] use state file in CLI

Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com>

tidy

Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com>

* use state file in CLI

Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com>

take clusterConfig from IDFile for compat

Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com>

various fixes

Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com>

wip

Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com>

* add GCP-specific values in Helm loader test

Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com>

* remove unnecessary pointer

Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com>

* write ClusterValues in one step

Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com>

* move stub to test file

Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com>

* remove mention of id-file

Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com>

* move output to `migrateTerraform`

Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com>

* unconditional assignments converting from idFile

Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com>

* move require block in go modules file

Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com>

* fall back to id file on upgrade

Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com>

* tidy

Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com>

* fix linter check

Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com>

* add notice to remove Terraform state check on manual migration

Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com>

* add `name` field

Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com>

fix name tests

Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com>

* return early if no Terraform diff

Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com>

* tidy

Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com>

* return infrastructure state even if no diff exists

Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com>

* add TODO to remove comment

Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com>

* use state-file in miniconstellation

Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com>

* cli: remove id-file (#2402)

* remove id-file from `constellation create`

Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com>

* add file renaming to handler

* rename id-file after upgrade

* use idFile on `constellation init`

Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com>

* remove id-file from `constellation verify`

Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com>

* linter fixes

Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com>

* remove id-file from `constellation mini`

* remove id-file from `constellation recover`

* linter fixes

* remove id-file from `constellation terminate`

* fix initSecret type

* fix recover argument precedence

* fix terminate test

* generate

* add TODO to remove id-file removal

* Update cli/internal/cmd/init.go

Co-authored-by: Adrian Stobbe <stobbe.adrian@gmail.com>

* fix verify arg parse logic

Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com>

* add version test

Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com>

* remove id-file from docs

* add file not found log

* use state-file in miniconstellation

Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com>

* remove id-file from `constellation iam destroy`

Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com>

* remove id-file from `cdbg deploy`

Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com>

---------

Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com>
Co-authored-by: Adrian Stobbe <stobbe.adrian@gmail.com>

* use state-file in CI

Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com>

* update orchestration docs

---------

Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com>
Co-authored-by: Adrian Stobbe <stobbe.adrian@gmail.com>
2023-10-09 13:04:29 +02:00
..
charts cli: update Azure/GCP CSI charts (#2416) 2023-10-06 14:56:49 +02:00
imageversion bazel: allow custom container_prefix (#1693) 2023-04-27 11:52:02 +02:00
testdata joinservice: cache certificates for Azure SEV-SNP attestation (#2336) 2023-09-29 14:29:50 +02:00
action.go Retry helm apply on any error (#2322) 2023-09-08 22:54:01 +02:00
actionfactory_test.go cli: check chart versions against target version in users config before upgrading (#2319) 2023-09-08 23:09:02 +02:00
actionfactory.go cli: check chart versions against target version in users config before upgrading (#2319) 2023-09-08 23:09:02 +02:00
BUILD.bazel cli: use state file on init and upgrade (#2395) 2023-10-09 13:04:29 +02:00
chartutil.go cli: save Helm charts to disk before running upgrades (#2305) 2023-09-08 12:02:16 +02:00
cilium.patch deploy cilium via helmchart (#321) 2022-08-12 10:20:19 +02:00
ciliumhelper.go cli: install cilium in cli instead of bootstrapper (#2146) 2023-08-02 15:49:40 +02:00
generateCertManager.sh bazel: add go generate to //:generate target 2023-03-29 12:51:40 -04:00
generateCilium.sh bazel: add go generate to //:generate target 2023-03-29 12:51:40 -04:00
helm_test.go cli: use state file on init and upgrade (#2395) 2023-10-09 13:04:29 +02:00
helm.go cli: use state file on init and upgrade (#2395) 2023-10-09 13:04:29 +02:00
loader_test.go cli: use state file on init and upgrade (#2395) 2023-10-09 13:04:29 +02:00
loader.go cli: use state file on init and upgrade (#2395) 2023-10-09 13:04:29 +02:00
overrides.go cli: use state file on init and upgrade (#2395) 2023-10-09 13:04:29 +02:00
README.md Fix README 2023-07-20 15:47:12 +02:00
release.go cli: helm install and upgrade unification (#2244) 2023-08-24 16:40:47 +02:00
retryaction_test.go Retry helm apply on any error (#2322) 2023-09-08 22:54:01 +02:00
retryaction.go Retry helm apply on any error (#2322) 2023-09-08 22:54:01 +02:00
serviceversion.go cli: output CSI driver versions on status (#2128) 2023-07-27 16:14:36 +02:00
update-aws-load-balancer-chart.sh aws: use new LB controller to fix SecurityGroup cleanup on K8s service deletion (#2090) 2023-07-24 10:30:53 +02:00
update-csi-charts.sh cli: update Azure/GCP CSI charts (#2416) 2023-10-06 14:56:49 +02:00
values.go aws: use new LB controller to fix SecurityGroup cleanup on K8s service deletion (#2090) 2023-07-24 10:30:53 +02:00
versionlister.go cli: helm install and upgrade unification (#2244) 2023-08-24 16:40:47 +02:00

Helm

Constellation uses helm to install and upgrade deployments to the Kubernetes cluster. Helm wraps deployments into charts. One chart should contain all the configuration needed to run a deployment.

Charts used by Constellation

To make installation and lifecycle management easier, Constellation groups multiple related charts into sub-charts. The following "parent" charts are used by Constellation:

  • cert-manager

  • Cilium

  • constellation-services

    Cluster services (mostly) written by us, providing basic functionality of the cluster

  • csi

    Our modified Kubernetes CSI drivers and Snapshot controller/CRDs

  • operators

    Kubernetes operators we use to control and manage the lifecycle of a Constellation cluster

Chart upgrades

All services that are installed via helm-install are upgraded via helm-upgrade. Two aspects are not full covered by running helm-upgrade: CRDs and values. While helm-install can install CRDs if they are contained in a chart's crds folder, upgrade won't change any installed CRDs. Furthermore, new values introduced with a new version of a chart will not be installed into the cluster if the --reuse-values flag is set. Nevertheless, we have to rely on the values already present in the cluster because some of the values are set by the bootstrapper during installation. Because upgrades should be a CLI-only operation and we want to avoid the behaviour of --reuse-values, we fetch the cluster values and merge them with any new values.

Here is how we manage CRD upgrades for each chart.

Cilium

  • CRDs are updated by cilium-operator.

cert-manager

  • installCRDs flag is set during upgrade. This flag is managed by cert-manager. cert-manager is in charge of correctly upgrading the CRDs.
  • WARNING: upgrading cert-manager might break other installations of cert-manager in the cluster, if those other installation are not on the same version as the Constellation-manager installation. This is due to the cluster-wide CRDs.

Operators

  • Manually update CRDs before upgrading the chart. Update by applying the CRDs found in the operators/crds/ folder.

Constellation-services

  • There currently are no CRDs in this chart.

CSI

  • CRDs are required for enabling snapshot support
  • CRDs are provided as their own helm chart and may be updated using helm