From 77bfee85bbf43b26fab2f8ee0d5478e1621db810 Mon Sep 17 00:00:00 2001 From: Lukasz Piatkowski Date: Wed, 29 Jun 2022 11:15:49 +0200 Subject: [PATCH] Feature: environments (#41) * add: environments management --- CHANGELOG.md | 10 + .../app_sets/hello-web-app/kustomization.yaml | 12 + .../override_config_hello_world.yaml | 6 + .../cluster/cluster_user_config.yaml | 10 + .../cluster/kustomization.yaml | 10 + .../cluster/patch_user_config.yaml | 10 + .../hello_app_cluster/kustomization.yaml | 6 + .../automatic_updates/catalog.yaml | 17 + .../automatic_updates/imageupdate.yaml | 28 + .../automatic_updates/kustomization.yaml | 8 + .../hello_world_app_user_config.yaml | 1 + .../dev/hello_app_cluster/imagepolicies.yaml | 24 + .../hello_app_cluster/imagerepositories.yaml | 16 + .../dev/hello_app_cluster/kustomization.yaml | 32 + .../cluster_user_config.yaml | 10 + .../hello_world_app_user_config.yaml | 1 + .../prod/hello_app_cluster/kustomization.yaml | 34 ++ .../automatic_updates/catalog.yaml | 17 + .../automatic_updates/imageupdate.yaml | 28 + .../automatic_updates/kustomization.yaml | 8 + .../hello_world_app_user_config.yaml | 1 + .../hello_app_cluster/imagepolicies.yaml | 22 + .../hello_app_cluster/imagerepositories.yaml | 16 + .../hello_app_cluster/kustomization.yaml | 32 + docs/add_wc.md | 1 + docs/add_wc_environments.md | 563 ++++++++++++++++++ docs/add_wc_template.md | 2 +- docs/appendices.md | 2 +- .../HELLO_APP_DEV_CLUSTER_1.yaml | 22 + .../kustomization.yaml | 5 + .../HELLO_APP_PROD_CLUSTER_1.yaml | 22 + .../kustomization.yaml | 5 + .../HELLO_APP_STAGING_CLUSTER_1.yaml | 22 + .../kustomization.yaml | 5 + .../workload-clusters/kustomization.yaml | 4 + 35 files changed, 1010 insertions(+), 2 deletions(-) create mode 100644 CHANGELOG.md create mode 100644 bases/cluster_templates/hello_app_cluster/app_sets/hello-web-app/kustomization.yaml create mode 100644 bases/cluster_templates/hello_app_cluster/app_sets/hello-web-app/override_config_hello_world.yaml create mode 100644 bases/cluster_templates/hello_app_cluster/cluster/cluster_user_config.yaml create mode 100644 bases/cluster_templates/hello_app_cluster/cluster/kustomization.yaml create mode 100644 bases/cluster_templates/hello_app_cluster/cluster/patch_user_config.yaml create mode 100644 bases/cluster_templates/hello_app_cluster/kustomization.yaml create mode 100644 bases/environments/stages/dev/hello_app_cluster/automatic_updates/catalog.yaml create mode 100644 bases/environments/stages/dev/hello_app_cluster/automatic_updates/imageupdate.yaml create mode 100644 bases/environments/stages/dev/hello_app_cluster/automatic_updates/kustomization.yaml create mode 100644 bases/environments/stages/dev/hello_app_cluster/hello_world_app_user_config.yaml create mode 100644 bases/environments/stages/dev/hello_app_cluster/imagepolicies.yaml create mode 100644 bases/environments/stages/dev/hello_app_cluster/imagerepositories.yaml create mode 100644 bases/environments/stages/dev/hello_app_cluster/kustomization.yaml create mode 100644 bases/environments/stages/prod/hello_app_cluster/cluster_user_config.yaml create mode 100644 bases/environments/stages/prod/hello_app_cluster/hello_world_app_user_config.yaml create mode 100644 bases/environments/stages/prod/hello_app_cluster/kustomization.yaml create mode 100644 bases/environments/stages/staging/hello_app_cluster/automatic_updates/catalog.yaml create mode 100644 bases/environments/stages/staging/hello_app_cluster/automatic_updates/imageupdate.yaml create mode 100644 bases/environments/stages/staging/hello_app_cluster/automatic_updates/kustomization.yaml create mode 100644 bases/environments/stages/staging/hello_app_cluster/hello_world_app_user_config.yaml create mode 100644 bases/environments/stages/staging/hello_app_cluster/imagepolicies.yaml create mode 100644 bases/environments/stages/staging/hello_app_cluster/imagerepositories.yaml create mode 100644 bases/environments/stages/staging/hello_app_cluster/kustomization.yaml create mode 100644 docs/add_wc_environments.md create mode 100644 management-clusters/MC_NAME/organizations/ORG_NAME/workload-clusters/HELLO_APP_DEV_CLUSTER_1.yaml create mode 100644 management-clusters/MC_NAME/organizations/ORG_NAME/workload-clusters/HELLO_APP_DEV_CLUSTER_1/kustomization.yaml create mode 100644 management-clusters/MC_NAME/organizations/ORG_NAME/workload-clusters/HELLO_APP_PROD_CLUSTER_1.yaml create mode 100644 management-clusters/MC_NAME/organizations/ORG_NAME/workload-clusters/HELLO_APP_PROD_CLUSTER_1/kustomization.yaml create mode 100644 management-clusters/MC_NAME/organizations/ORG_NAME/workload-clusters/HELLO_APP_STAGING_CLUSTER_1.yaml create mode 100644 management-clusters/MC_NAME/organizations/ORG_NAME/workload-clusters/HELLO_APP_STAGING_CLUSTER_1/kustomization.yaml diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000..7efa9a8c --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,10 @@ +# Changelog + +Based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +following [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +- Added + - Description and examples for environment management + - Initail release with basic fnunctionality and docs in place diff --git a/bases/cluster_templates/hello_app_cluster/app_sets/hello-web-app/kustomization.yaml b/bases/cluster_templates/hello_app_cluster/app_sets/hello-web-app/kustomization.yaml new file mode 100644 index 00000000..db77125b --- /dev/null +++ b/bases/cluster_templates/hello_app_cluster/app_sets/hello-web-app/kustomization.yaml @@ -0,0 +1,12 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +buildMetadata: [originAnnotations] +configMapGenerator: + - behavior: replace + files: + - values=override_config_hello_world.yaml + name: ${cluster_id}-hello-world-values +generatorOptions: + disableNameSuffixHash: true +kind: Kustomization +resources: + - ../../../../app_sets/hello-web-app/ diff --git a/bases/cluster_templates/hello_app_cluster/app_sets/hello-web-app/override_config_hello_world.yaml b/bases/cluster_templates/hello_app_cluster/app_sets/hello-web-app/override_config_hello_world.yaml new file mode 100644 index 00000000..42ba79da --- /dev/null +++ b/bases/cluster_templates/hello_app_cluster/app_sets/hello-web-app/override_config_hello_world.yaml @@ -0,0 +1,6 @@ +admin_login: hello-admin-in-cluster-template +db_config: + db_port: 5433 # has to be in sync with config in default_config_simple_db.yaml + db_user: hello-web-app # has to be in sync with config in default_config_simple_db.yaml + host: simple-db.simple-web.svc # has to be in sync with 'namespace:' set in kustomization.yaml +thread_pool_size: 64 diff --git a/bases/cluster_templates/hello_app_cluster/cluster/cluster_user_config.yaml b/bases/cluster_templates/hello_app_cluster/cluster/cluster_user_config.yaml new file mode 100644 index 00000000..7a3ae0f7 --- /dev/null +++ b/bases/cluster_templates/hello_app_cluster/cluster/cluster_user_config.yaml @@ -0,0 +1,10 @@ +apiVersion: v1 +data: + values: | + cloudConfig: cloud-config-giantswarm-2 + cloudName: openstack + externalNetworkID: aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee +kind: ConfigMap +metadata: + name: ${cluster_name}-user-config + namespace: org-${organization} diff --git a/bases/cluster_templates/hello_app_cluster/cluster/kustomization.yaml b/bases/cluster_templates/hello_app_cluster/cluster/kustomization.yaml new file mode 100644 index 00000000..faac0a3e --- /dev/null +++ b/bases/cluster_templates/hello_app_cluster/cluster/kustomization.yaml @@ -0,0 +1,10 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +buildMetadata: [originAnnotations] +commonLabels: + giantswarm.io/managed-by: flux +kind: Kustomization +patchesStrategicMerge: + - patch_user_config.yaml +resources: + - ../../../clusters/capo/>=v0.6.0 + - cluster_user_config.yaml diff --git a/bases/cluster_templates/hello_app_cluster/cluster/patch_user_config.yaml b/bases/cluster_templates/hello_app_cluster/cluster/patch_user_config.yaml new file mode 100644 index 00000000..0143eae2 --- /dev/null +++ b/bases/cluster_templates/hello_app_cluster/cluster/patch_user_config.yaml @@ -0,0 +1,10 @@ +apiVersion: application.giantswarm.io/v1alpha1 +kind: App +metadata: + name: ${cluster_name} + namespace: org-${organization} +spec: + userConfig: + configMap: + name: ${cluster_name}-user-config + namespace: org-${organization} diff --git a/bases/cluster_templates/hello_app_cluster/kustomization.yaml b/bases/cluster_templates/hello_app_cluster/kustomization.yaml new file mode 100644 index 00000000..9e9f7c81 --- /dev/null +++ b/bases/cluster_templates/hello_app_cluster/kustomization.yaml @@ -0,0 +1,6 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +buildMetadata: [originAnnotations] +kind: Kustomization +resources: + - cluster/ + - app_sets/hello-web-app/ diff --git a/bases/environments/stages/dev/hello_app_cluster/automatic_updates/catalog.yaml b/bases/environments/stages/dev/hello_app_cluster/automatic_updates/catalog.yaml new file mode 100644 index 00000000..1172539a --- /dev/null +++ b/bases/environments/stages/dev/hello_app_cluster/automatic_updates/catalog.yaml @@ -0,0 +1,17 @@ +apiVersion: application.giantswarm.io/v1alpha1 +kind: Catalog +metadata: + labels: + application.giantswarm.io/catalog-visibility: internal + name: giantswarm-catalog-oci + namespace: org-${organization} +spec: + description: giantswarm-catalog-oci + logoURL: "https://avatars.githubusercontent.com/u/7556340?s=60&v=4" + repositories: + - URL: oci://giantswarmpublic.azurecr.io/giantswarm-catalog/ + type: helm + storage: + URL: oci://giantswarmpublic.azurecr.io/giantswarm-catalog/ + type: helm + title: giantswarm-catalog-oci diff --git a/bases/environments/stages/dev/hello_app_cluster/automatic_updates/imageupdate.yaml b/bases/environments/stages/dev/hello_app_cluster/automatic_updates/imageupdate.yaml new file mode 100644 index 00000000..3183a7c5 --- /dev/null +++ b/bases/environments/stages/dev/hello_app_cluster/automatic_updates/imageupdate.yaml @@ -0,0 +1,28 @@ +apiVersion: image.toolkit.fluxcd.io/v1beta1 +kind: ImageUpdateAutomation +metadata: + name: ${cluster_id}-image-updates + namespace: org-${organization} +spec: + git: + checkout: + ref: + branch: main + commit: + author: + email: fluxcdbot@users.noreply.github.com + name: fluxcdbot + messageTemplate: | + automated app upgrades: + {{ range $image, $_ := .Updated.Images -}} + - {{ $image.Repository }} to {{ $image.Identifier }} + {{ end -}} + push: + branch: main + interval: 1m0s + sourceRef: + kind: GitRepository + name: YOUR_GIT_REPO + update: + path: ./management-clusters/MC_NAME + strategy: Setters diff --git a/bases/environments/stages/dev/hello_app_cluster/automatic_updates/kustomization.yaml b/bases/environments/stages/dev/hello_app_cluster/automatic_updates/kustomization.yaml new file mode 100644 index 00000000..9c92d9cd --- /dev/null +++ b/bases/environments/stages/dev/hello_app_cluster/automatic_updates/kustomization.yaml @@ -0,0 +1,8 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +buildMetadata: [originAnnotations] +commonLabels: + giantswarm.io/managed-by: flux +kind: Kustomization +resources: +- catalog.yaml +- imageupdate.yaml diff --git a/bases/environments/stages/dev/hello_app_cluster/hello_world_app_user_config.yaml b/bases/environments/stages/dev/hello_app_cluster/hello_world_app_user_config.yaml new file mode 100644 index 00000000..0c601685 --- /dev/null +++ b/bases/environments/stages/dev/hello_app_cluster/hello_world_app_user_config.yaml @@ -0,0 +1 @@ +thread_pool_size: 16 diff --git a/bases/environments/stages/dev/hello_app_cluster/imagepolicies.yaml b/bases/environments/stages/dev/hello_app_cluster/imagepolicies.yaml new file mode 100644 index 00000000..25a7028a --- /dev/null +++ b/bases/environments/stages/dev/hello_app_cluster/imagepolicies.yaml @@ -0,0 +1,24 @@ +--- +apiVersion: image.toolkit.fluxcd.io/v1beta1 +kind: ImagePolicy +metadata: + name: ${cluster_id}-hello-app +spec: + filterTags: + pattern: '.*-dev.*' + imageRepositoryRef: + name: ${cluster_id}-hello-app + policy: + semver: + range: '>=0.1.0' +--- +apiVersion: image.toolkit.fluxcd.io/v1beta1 +kind: ImagePolicy +metadata: + name: ${cluster_id}-simple-db-app +spec: + imageRepositoryRef: + name: ${cluster_id}-simple-db + policy: + semver: + range: '>=0.1.0 <0.2.0' diff --git a/bases/environments/stages/dev/hello_app_cluster/imagerepositories.yaml b/bases/environments/stages/dev/hello_app_cluster/imagerepositories.yaml new file mode 100644 index 00000000..94bcb4ce --- /dev/null +++ b/bases/environments/stages/dev/hello_app_cluster/imagerepositories.yaml @@ -0,0 +1,16 @@ +--- +apiVersion: image.toolkit.fluxcd.io/v1beta1 +kind: ImageRepository +metadata: + name: ${cluster_id}-hello-app +spec: + image: giantswarmpublic.azurecr.io/giantswarm-catalog/hello-world-app + interval: 10m0s +--- +apiVersion: image.toolkit.fluxcd.io/v1beta1 +kind: ImageRepository +metadata: + name: ${cluster_id}-simple-db-app +spec: + image: giantswarmpublic.azurecr.io/giantswarm-catalog/simple-db-app + interval: 10m0s diff --git a/bases/environments/stages/dev/hello_app_cluster/kustomization.yaml b/bases/environments/stages/dev/hello_app_cluster/kustomization.yaml new file mode 100644 index 00000000..b7ef4a2c --- /dev/null +++ b/bases/environments/stages/dev/hello_app_cluster/kustomization.yaml @@ -0,0 +1,32 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +buildMetadata: [originAnnotations] +configMapGenerator: + - behavior: create + files: + - values=hello_world_app_user_config.yaml + name: ${cluster_id}-hello-world-user-config +generatorOptions: + disableNameSuffixHash: true +kind: Kustomization +# (optional) here we can enforce versions for both component of the app that we want in prod +patches: + - patch: |- + - op: replace + path: /spec/version + value: '0.1.8 # {"$imagepolicy": "org-${organization}:${cluster_id}-hello-app"}' + target: + kind: App + name: \${cluster_id}-hello-world + - patch: |- + - op: replace + path: /spec/version + value: '0.1.0 # {"$imagepolicy": "org-${organization}:${cluster_id}-simple-db-app"}' + target: + kind: App + name: \${cluster_id}-simple-db +# block end +resources: + - automatic_updates/ + - imagepolicies.yaml + - imagerepositories.yaml + - ../../../../cluster_templates/hello_app_cluster diff --git a/bases/environments/stages/prod/hello_app_cluster/cluster_user_config.yaml b/bases/environments/stages/prod/hello_app_cluster/cluster_user_config.yaml new file mode 100644 index 00000000..ba7779d1 --- /dev/null +++ b/bases/environments/stages/prod/hello_app_cluster/cluster_user_config.yaml @@ -0,0 +1,10 @@ +values: | + cloudConfig: cloud-config-giantswarm-2 + cloudName: openstack + externalNetworkID: prod-bbbb-cccc-dddd-eeeeeeeeeeee + nodeClasses: + - bootFromVolume: true + diskSize: 150 + flavor: n1.large + image: dddddddd-dddd-dddd-dddd-dddddddddddd + name: default diff --git a/bases/environments/stages/prod/hello_app_cluster/hello_world_app_user_config.yaml b/bases/environments/stages/prod/hello_app_cluster/hello_world_app_user_config.yaml new file mode 100644 index 00000000..c8dc14ac --- /dev/null +++ b/bases/environments/stages/prod/hello_app_cluster/hello_world_app_user_config.yaml @@ -0,0 +1 @@ +thread_pool_size: 256 diff --git a/bases/environments/stages/prod/hello_app_cluster/kustomization.yaml b/bases/environments/stages/prod/hello_app_cluster/kustomization.yaml new file mode 100644 index 00000000..0d213177 --- /dev/null +++ b/bases/environments/stages/prod/hello_app_cluster/kustomization.yaml @@ -0,0 +1,34 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +buildMetadata: [originAnnotations] +configMapGenerator: + - behavior: create + files: + - values=hello_world_app_user_config.yaml + name: ${cluster_id}-hello-world-user-config + - behavior: replace + files: + - values=cluster_user_config.yaml + name: ${cluster_name}-user-config + namespace: org-${organization} +generatorOptions: + disableNameSuffixHash: true +kind: Kustomization +# (optional) here we can enforce versions for both component of the app that we want in prod +patches: + - patch: |- + - op: replace + path: /spec/version + value: 0.1.8 + target: + kind: App + name: \${cluster_id}-hello-world + - patch: |- + - op: replace + path: /spec/version + value: 0.1.0 + target: + kind: App + name: \${cluster_id}-simple-db +# block end +resources: + - ../../../../cluster_templates/hello_app_cluster diff --git a/bases/environments/stages/staging/hello_app_cluster/automatic_updates/catalog.yaml b/bases/environments/stages/staging/hello_app_cluster/automatic_updates/catalog.yaml new file mode 100644 index 00000000..1172539a --- /dev/null +++ b/bases/environments/stages/staging/hello_app_cluster/automatic_updates/catalog.yaml @@ -0,0 +1,17 @@ +apiVersion: application.giantswarm.io/v1alpha1 +kind: Catalog +metadata: + labels: + application.giantswarm.io/catalog-visibility: internal + name: giantswarm-catalog-oci + namespace: org-${organization} +spec: + description: giantswarm-catalog-oci + logoURL: "https://avatars.githubusercontent.com/u/7556340?s=60&v=4" + repositories: + - URL: oci://giantswarmpublic.azurecr.io/giantswarm-catalog/ + type: helm + storage: + URL: oci://giantswarmpublic.azurecr.io/giantswarm-catalog/ + type: helm + title: giantswarm-catalog-oci diff --git a/bases/environments/stages/staging/hello_app_cluster/automatic_updates/imageupdate.yaml b/bases/environments/stages/staging/hello_app_cluster/automatic_updates/imageupdate.yaml new file mode 100644 index 00000000..3183a7c5 --- /dev/null +++ b/bases/environments/stages/staging/hello_app_cluster/automatic_updates/imageupdate.yaml @@ -0,0 +1,28 @@ +apiVersion: image.toolkit.fluxcd.io/v1beta1 +kind: ImageUpdateAutomation +metadata: + name: ${cluster_id}-image-updates + namespace: org-${organization} +spec: + git: + checkout: + ref: + branch: main + commit: + author: + email: fluxcdbot@users.noreply.github.com + name: fluxcdbot + messageTemplate: | + automated app upgrades: + {{ range $image, $_ := .Updated.Images -}} + - {{ $image.Repository }} to {{ $image.Identifier }} + {{ end -}} + push: + branch: main + interval: 1m0s + sourceRef: + kind: GitRepository + name: YOUR_GIT_REPO + update: + path: ./management-clusters/MC_NAME + strategy: Setters diff --git a/bases/environments/stages/staging/hello_app_cluster/automatic_updates/kustomization.yaml b/bases/environments/stages/staging/hello_app_cluster/automatic_updates/kustomization.yaml new file mode 100644 index 00000000..9c92d9cd --- /dev/null +++ b/bases/environments/stages/staging/hello_app_cluster/automatic_updates/kustomization.yaml @@ -0,0 +1,8 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +buildMetadata: [originAnnotations] +commonLabels: + giantswarm.io/managed-by: flux +kind: Kustomization +resources: +- catalog.yaml +- imageupdate.yaml diff --git a/bases/environments/stages/staging/hello_app_cluster/hello_world_app_user_config.yaml b/bases/environments/stages/staging/hello_app_cluster/hello_world_app_user_config.yaml new file mode 100644 index 00000000..17249927 --- /dev/null +++ b/bases/environments/stages/staging/hello_app_cluster/hello_world_app_user_config.yaml @@ -0,0 +1 @@ +thread_pool_size: 64 diff --git a/bases/environments/stages/staging/hello_app_cluster/imagepolicies.yaml b/bases/environments/stages/staging/hello_app_cluster/imagepolicies.yaml new file mode 100644 index 00000000..f7437788 --- /dev/null +++ b/bases/environments/stages/staging/hello_app_cluster/imagepolicies.yaml @@ -0,0 +1,22 @@ +--- +apiVersion: image.toolkit.fluxcd.io/v1beta1 +kind: ImagePolicy +metadata: + name: ${cluster_id}-hello-app +spec: + imageRepositoryRef: + name: ${cluster_id}-hello-app + policy: + semver: + range: '>=0.1.0 <1.0.0' +--- +apiVersion: image.toolkit.fluxcd.io/v1beta1 +kind: ImagePolicy +metadata: + name: ${cluster_id}-simple-db-app +spec: + imageRepositoryRef: + name: ${cluster_id}-simple-db + policy: + semver: + range: '>=0.1.0 <0.2.0' diff --git a/bases/environments/stages/staging/hello_app_cluster/imagerepositories.yaml b/bases/environments/stages/staging/hello_app_cluster/imagerepositories.yaml new file mode 100644 index 00000000..94bcb4ce --- /dev/null +++ b/bases/environments/stages/staging/hello_app_cluster/imagerepositories.yaml @@ -0,0 +1,16 @@ +--- +apiVersion: image.toolkit.fluxcd.io/v1beta1 +kind: ImageRepository +metadata: + name: ${cluster_id}-hello-app +spec: + image: giantswarmpublic.azurecr.io/giantswarm-catalog/hello-world-app + interval: 10m0s +--- +apiVersion: image.toolkit.fluxcd.io/v1beta1 +kind: ImageRepository +metadata: + name: ${cluster_id}-simple-db-app +spec: + image: giantswarmpublic.azurecr.io/giantswarm-catalog/simple-db-app + interval: 10m0s diff --git a/bases/environments/stages/staging/hello_app_cluster/kustomization.yaml b/bases/environments/stages/staging/hello_app_cluster/kustomization.yaml new file mode 100644 index 00000000..b7ef4a2c --- /dev/null +++ b/bases/environments/stages/staging/hello_app_cluster/kustomization.yaml @@ -0,0 +1,32 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +buildMetadata: [originAnnotations] +configMapGenerator: + - behavior: create + files: + - values=hello_world_app_user_config.yaml + name: ${cluster_id}-hello-world-user-config +generatorOptions: + disableNameSuffixHash: true +kind: Kustomization +# (optional) here we can enforce versions for both component of the app that we want in prod +patches: + - patch: |- + - op: replace + path: /spec/version + value: '0.1.8 # {"$imagepolicy": "org-${organization}:${cluster_id}-hello-app"}' + target: + kind: App + name: \${cluster_id}-hello-world + - patch: |- + - op: replace + path: /spec/version + value: '0.1.0 # {"$imagepolicy": "org-${organization}:${cluster_id}-simple-db-app"}' + target: + kind: App + name: \${cluster_id}-simple-db +# block end +resources: + - automatic_updates/ + - imagepolicies.yaml + - imagerepositories.yaml + - ../../../../cluster_templates/hello_app_cluster diff --git a/docs/add_wc.md b/docs/add_wc.md index aaf0531f..303d56cf 100644 --- a/docs/add_wc.md +++ b/docs/add_wc.md @@ -5,6 +5,7 @@ understand and follow all of them to produce a valid configuration. These steps 1. [Preparing a cluster definition template](./add_wc_template.md) you want to use for your cluster (if it doesn't already exist). +1. [Preparing multiple environments](./add_wc_environments.md) 1. [Preparing GitOps repository structure, encryption secrets and dedicated Flux Kustomization](./add_wc_structure.md). 1. [Providing actual instance of a cluster, a definition of infrastructure required to run it](./add_wc_instance.md). 1. [Configuring Apps to be deployed in the new cluster](./apps/README.md). diff --git a/docs/add_wc_environments.md b/docs/add_wc_environments.md new file mode 100644 index 00000000..d8100e82 --- /dev/null +++ b/docs/add_wc_environments.md @@ -0,0 +1,563 @@ +# Add Workload Cluster environments + +- [General note](#general-note) +- [Environments](#environments) + - [Stages](#stages) + - [The development cluster](#the-development-cluster) + - [The staging cluster](#the-staging-cluster) + - [The production cluster](#the-production-cluster) +- [Add Workload Clusters based on the environment cluster templates](#add-workload-clusters-based-on-the-environment-cluster-templates) +- [Tips for developing environments](#tips-for-developing-environments) + +You might want to set up multiple, similar Workload Clusters that serve as for example development, +staging and production environments. You can utilize [bases](/bases) to achieve that. Let's take a look at the +[/bases/environments](/bases/environments) folder structure. + +## General note + +It is possible to solve the environment and environment propagation problem in multiple ways, notably by: + +- using a multi-directory structure, where each environment is represented as a directory in a `main` branch of a single + repository +- using a multi-branch approach, where each branch corresponds to one environment, but they are in the same repo +- using a multi-repo setup, where there's one root repository providing all the necessary templates, then there is one another + repository per environment. + +Each of these approaches has pros and cons. We propose the multi-directory approach. The pros of it are: +a single repo and branch serving as the source of truth for all the environments, very easy template sharing and +relatively easy way to compare and promote configuration across environments. On the other hand, it might not be the +best solution for access control, template versioning and also easy comparing of environments. + +## Environments + +The `stages` folder is how we propose to group environment specifications. +There is a good reason for this additional layer of grouping. You can use this approach to have multiple +different clusters - like the dev, staging, production - but also to have multiple different +regions or data centers where you want to spin these clusters up. + +```sh +mkdir -p bases/environments/stages +``` + +We're assuming that all the clusters using this environments pattern should in many regards look the same +across all the environments. Still, each environment layer introduces some key differences, like app version being deployed +for `dev/staging/prod` environments or a specific IP range, certificate or ingresses config for data center related environments +like `us-east-1/us-west-2`. + +To create an environment template, you need to make a directory in `environments` that describes the best the +differentiating factor for that kind of environment, then you should create sub folder there for different possible values. +For example, for multiple data centers, we recommend putting region specific configuration into +`/bases/environments/regions` folder and under there create `ap-east-1`, `eu-central-1` and `us-west-2` folders. + +Once your environment templates are ready, you can use them to create new clusters by placing cluster definitions +in [/management-clusters/MC_NAME/organizations/ORG_NAME/workload-clusters]( +/management-clusters/MC_NAME/organizations/ORG_NAME/workload-clusters) + +> :construction: Please note that if you want to use multiple environment templates to create a single cluster +that uses `App CR`s for deployments, like you would like to use `dev` out of `staging` layout to set app configuration +and then use `east` from the `data-centers` to set the IP ranges, you will run into issues around merging +configurations, as currently one configuration source (i.e. `ConfigMap` in `spec.config.configMap`) completely +overrides the whole value of the same attribute coming from the other base. We're working to remove this limitation. + +### Stages + +We have 3 example clusters under [/bases/environments/stages](/bases/environments/stages): + +- [dev](/bases/environments/stages/dev) +- [staging](/bases/environments/stages/staging) +- [prod](/bases/environments/stages/prod) + +```sh +mkdir -p bases/environments/stages/dev +mkdir -p bases/environments/stages/staging +mkdir -p bases/environments/stages/prod +``` + +Each of these contain a `hello_app_cluster` example. +This name might already be familiar to you from [Preparing a cluster definition template](./add_wc_template.md) section. + +```sh +mkdir -p bases/environments/stages/dev/hello_app_cluster +mkdir -p bases/environments/stages/staging/hello_app_cluster +mkdir -p bases/environments/stages/prod/hello_app_cluster +``` + +By checking each `kustomization.yaml` files - the [dev]( +/bases/environments/stages/dev/hello_app_cluster/kustomization.yaml) one for example - you will notice that they +all reference our [hello_app_cluster](/bases/cluster_templates/hello_app_cluster) template base. + +```yaml +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +# ... +resources: + # ... + - ../../../../cluster_templates/hello_app_cluster +``` + +You can put additional configuration under these folders that should be same for each instances of these clusters. +Let's take a closer look at our examples. + +#### The development cluster + +Set up our environment first. + +```sh +export MC_NAME=CODENAME +export WC_NAME=CLUSTER_NAME +export ORG_NAME=ORGANIZATION +export GIT_REPOSITORY_NAME=REPOSITORY_NAME +``` + +Change our working directory to the `hello_app_cluster` development cluster environment base. + +```sh +cd bases/environments/stages/dev/hello_app_cluster +``` + +Let's crete the `kustomization.yaml` file for the development cluster. + +```sh +cat < kustomization.yaml +apiVersion: kustomize.config.k8s.io/v1beta1 +buildMetadata: [originAnnotations] +configMapGenerator: + - behavior: create + files: + - values=hello_world_app_user_config.yaml + name: ${WC_NAME}-hello-world-user-config +generatorOptions: + disableNameSuffixHash: true +kind: Kustomization +resources: + - automatic_updates/ + - imagepolicies.yaml + - imagerepositories.yaml + - ../../../../cluster_templates/hello_app_cluster +EOF +``` + +In [hello_app_cluster](/bases/cluster_templates/hello_app_cluster) base cluster template defines that the +[hello-web-app app set](/bases/app_sets/hello-web-app) should be installed in all of these clusters. +We can provide overrides to the settings via the [hello_world_app_user_config.yaml]( +/bases/environments/stages/dev/hello_app_cluster/hello_world_app_user_config.yaml) file, for example +setting a lower thread pool size. + +```sh +cat < hello_world_app_user_config.yaml +thread_pool_size: 16 +EOF +``` + +It also makes sense to configure `Automatic Updates` for our development cluster. We store these configurations under +the [/bases/environments/stages/dev/hello_app_cluster/automatic_updates]( +/bases/environments/stages/dev/hello_app_cluster/automatic_updates) folder. You can read more about how +`Automatic Updates` work [here](/docs/apps/automatic_updates_appcr.md) + +```sh +mkdir automatic_updates + +# Let's create the Kustomization for automatic updates +cat < automatic_updates/kustomization.yaml +apiVersion: kustomize.config.k8s.io/v1beta1 +buildMetadata: [originAnnotations] +commonLabels: + giantswarm.io/managed-by: flux +kind: Kustomization +resources: +- catalog.yaml +- imageupdate.yaml +EOF + +# Let's create the catalog +cat < automatic_updates/catalog.yaml +apiVersion: application.giantswarm.io/v1alpha1 +kind: Catalog +metadata: + labels: + application.giantswarm.io/catalog-visibility: internal + name: giantswarm-catalog-oci + namespace: org-${ORG_NAME} +spec: + description: giantswarm-catalog-oci + logoURL: "https://avatars.githubusercontent.com/u/7556340?s=60&v=4" + storage: + URL: oci://giantswarmpublic.azurecr.io/giantswarm-catalog/ + type: helm + title: giantswarm-catalog-oci +EOF + +# Let' create the image update automation for Flux +cat < automatic_updates/imageupdate.yaml +apiVersion: image.toolkit.fluxcd.io/v1beta1 +kind: ImageUpdateAutomation +metadata: + name: ${cluster_id}-image-updates + namespace: org-${ORG_NAME} +spec: + git: + checkout: + ref: + branch: main + commit: + author: + email: fluxcdbot@users.noreply.github.com + name: fluxcdbot + messageTemplate: | + automated app upgrades: + {{ range $image, $_ := .Updated.Images -}} + - {{ $image.Repository }} to {{ $image.Identifier }} + {{ end -}} + push: + branch: main + interval: 1m0s + sourceRef: + kind: GitRepository + name: ${GIT_REPOSITORY_NAME} + update: + path: ./management-clusters/MC_NAME + strategy: Setters +EOF +``` + +Now that we have automation set up around `Automatic Updates` we can set up our rules for the development cluster +on how it should update `Apps`. We need 2 things to achieve that, and we recommend setting up one multi-document YAML +files to store all these in a single place. + +The [ImageRepository](https://fluxcd.io/docs/components/image/imagerepositories/) definitions to tell Flux +where to look for updates stored in: [imagerepositories.yaml]( +/bases/environments/stages/dev/hello_app_cluster/imagerepositories.yaml). + +Let's tell Flux to look for available images for the `hello-world-app` +in the `giantswarmpublic.azurecr.io/giantswarm-catalog` registry every 10 minutes. + +```sh +cat < imagerepositories.yaml +--- +apiVersion: image.toolkit.fluxcd.io/v1beta1 +kind: ImageRepository +metadata: + name: ${WC_NAME}-hello-app +spec: + image: giantswarmpublic.azurecr.io/giantswarm-catalog/hello-world-app + interval: 10m0s +--- +apiVersion: image.toolkit.fluxcd.io/v1beta1 +kind: ImageRepository +metadata: + name: ${WC_NAME}-simple-db-app +spec: + image: giantswarmpublic.azurecr.io/giantswarm-catalog/simple-db-app + interval: 10m0s +EOF +``` + +The second half are the [ImagePolicy](https://fluxcd.io/docs/components/image/imagepolicies/) definitions to tell Flux +which versions it should automatically apply stored in: [imagepolicies.yaml]( +/bases/environments/stages/dev/hello_app_cluster/imagepolicies.yaml). + +Let's have Flux automatically roll out all `-dev` releases that are of at least version `0.1.0` or above. + +```sh +cat < imagepolicies.yaml +--- +apiVersion: image.toolkit.fluxcd.io/v1beta1 +kind: ImagePolicy +metadata: + name: ${WC_NAME}-hello-app +spec: + filterTags: + pattern: '.*-dev.*' + imageRepositoryRef: + name: ${WC_NAME}-hello-app + policy: + semver: + range: '>=0.1.0' +--- +apiVersion: image.toolkit.fluxcd.io/v1beta1 +kind: ImagePolicy +metadata: + name: ${WC_NAME}-simple-db-app +spec: + imageRepositoryRef: + name: ${WC_NAME}-simple-db + policy: + semver: + range: '>=0.1.0 <0.2.0' +EOF +``` + +We can also use `Kustomization` patches to set exact versions to use in the cluster's `kustomization.yaml` file. + +```sh +cat <> kustomization.yaml +patches: + - patch: |- + - op: replace + path: /spec/version + value: '0.1.8 + target: + kind: App + name: ${WC_NAME}-hello-world + - patch: |- + - op: replace + path: /spec/version + value: '0.1.0' + target: + kind: App + name: ${WC_NAME}-simple-db +EOF +``` + +And pretty much that is it for the development cluster. Let's look at the staging cluster next to the minor differences. + +#### The staging cluster + +Let's change our working directory to the staging cluster. + +```sh +cd ../../staging/hello_app_cluster +``` + +We will use the same environment variables and `kustomization.yaml` for this cluster template as we did for the +development cluster. + +It is similar to the development cluster in the following manners: + +- it is based on the [hello_app_cluster](/bases/cluster_templates/hello_app_cluster) template base +- it has automatic updates set up + +It also provides overrides to the [hello-web-app app set](/bases/app_sets/hello-web-app) via +[hello_world_app_user_config.yaml]( +/bases/environments/stages/staging/hello_app_cluster/hello_world_app_user_config.yaml). +We want this environment to be closer to production so let's say we set a larger thread pool size. + +```sh +cat < hello_world_app_user_config.yaml +thread_pool_size: 64 +EOF +``` + +Setting up the `automatic_updates` folder and the `imagerepositories.yaml` files requires exactly the same steps +as we did above for the development cluster. + +We also want the images automatically rolled out here to be more stable, so we have a slightly different +[imagepolicies.yaml](/bases/environments/stages/staging/hello_app_cluster/imagepolicies.yaml) here where +we tell Flux to automatically install all stable versions that are at least version `0.1.0` but we do not want +to automatically introduce possibly breaking changes in major version bump, so let's stay below `1.0.0`. + +```sh +cat < imagepolicies.yaml +--- +apiVersion: image.toolkit.fluxcd.io/v1beta1 +kind: ImagePolicy +metadata: + name: ${WC_NAME}-hello-app +spec: + imageRepositoryRef: + name: ${WC_NAME}-hello-app + policy: + semver: + range: '>=0.1.0 <1.0.0' +--- +apiVersion: image.toolkit.fluxcd.io/v1beta1 +kind: ImagePolicy +metadata: + name: ${WC_NAME}-simple-db-app +spec: + imageRepositoryRef: + name: ${WC_NAME}-simple-db + policy: + semver: + range: '>=0.1.0 <0.2.0' +EOF +``` + +So basically our staging cluster in our example is a smaller scale cluster carrying stable versions of our applications. + +Now, let's take a look at the production cluster example. + +#### The production cluster + +Let's change our working directory to the staging cluster. + +```sh +cd ../../prod/hello_app_cluster +``` + +We will use the same environment variables for this cluster template as we did for the development cluster. + +Let's create the `Kustomization` for the production cluster environment template. + +```sh +cat < kustomization.yaml +apiVersion: kustomize.config.k8s.io/v1beta1 +buildMetadata: [originAnnotations] +configMapGenerator: + - behavior: create + files: + - values=hello_world_app_user_config.yaml + name: ${WC_NAME}-hello-world-user-config + - behavior: replace + files: + - values=cluster_user_config.yaml + name: ${WC_NAME}-user-config + namespace: org-${ORG_NAME} +generatorOptions: + disableNameSuffixHash: true +kind: Kustomization +resources: + - ../../../../cluster_templates/hello_app_cluster +EOF +``` + +It is similar to the staging cluster in the following manners: + +- it is based on the [hello_app_cluster](/bases/cluster_templates/hello_app_cluster) template base + +Note in the `kustomization.yaml` above that we create another `ConfigMap` for the production cluster +that contains some extra settings for our cluster. + +```sh +cat < cluster_user_config.yaml +values: | + cloudConfig: cloud-config-giantswarm-2 + cloudName: openstack + externalNetworkID: prod-bbbb-cccc-dddd-eeeeeeeeeeee + nodeClasses: + - bootFromVolume: true + diskSize: 150 + flavor: n1.large + image: dddddddd-dddd-dddd-dddd-dddddddddddd + name: default +EOF +``` + +Then we provide some overrides to the [hello-web-app app set](/bases/app_sets/hello-web-app) via +[hello_world_app_user_config.yaml]( +/bases/environments/stages/prod/hello_app_cluster/hello_world_app_user_config.yaml). + +```yaml +cat < hello_world_app_user_config.yaml +thread_pool_size: 256 +EOF +``` + +Notice however that we decided not to set up `Automatic Updates` for this cluster. + +Instead, we use the `Kustomization` in the cluster's [kustomization.yaml]( +/bases/environments/stages/prod/hello_app_cluster/kustomization.yaml) to patch the exact versions to use +in out App CRs. + +```sh +cat <> kustomization.yaml +patches: + - patch: |- + - op: replace + path: /spec/version + value: 0.1.8 + target: + kind: App + name: ${WC_NAME}-hello-world + - patch: |- + - op: replace + path: /spec/version + value: 0.1.0 + target: + kind: App + name: ${WC_NAME}-simple-db +EOF +``` + +We tell Flux to use version `0.1.8` of `hello-world-app` and version `0.1.0` of `simple-db-app`. + +In this example when we sufficiently validated our released changes in the staging environment we update the versions +in the `Kustomization`, merge the change and let Flux do the work. + +## Add Workload Clusters based on the environment cluster templates + +Just as any other Workload Clusters we define them in +[/management-clusters/MC_NAME/organizations/ORG_NAME/workload-clusters]( +/management-clusters/MC_NAME/organizations/ORG_NAME/workload-clusters). + +Relative to the root of the repository, let's change our working directory to our `workload-clusters` folder. + +```sh +cd management-clusters/${MC_NAME}/organizations/${ORG_NAME}/workload-clusters +``` + +Then let's tell Flux to manage our cluster instance. + +```sh +cat < HELLO_APP_DEV_CLUSTER_1.yaml +apiVersion: kustomize.toolkit.fluxcd.io/v1beta2 +kind: Kustomization +metadata: + name: clusters-${WC_NAME} + namespace: default +spec: + interval: 1m + path: "./management-clusters/${MC_NAME}/organizations/${ORG_NAME}/workload-clusters/HELLO_APP_DEV_CLUSTER_1" + postBuild: + substitute: + cluster_domain: "MY_DOMAIN" + cluster_id: "HELLO_APP_DEV_1" + cluster_name: "HELLO_APP_DEV_1" + cluster_release: "0.8.1" + default_apps_release: "0.2.0" + organization: "${ORG_NAME}" + prune: false + serviceAccountName: automation + sourceRef: + kind: GitRepository + name: ${GIT_REPOSITORY_NAME} + timeout: 2m + +EOF +``` + +In our example we create one instance from each cluster environment base: + +- from the dev environment we create [HELLO_APP_DEV_CLUSTER_1]( +/management-clusters/MC_NAME/organizations/ORG_NAME/workload-clusters/HELLO_APP_DEV_CLUSTER_1/kustomization.yaml) +- from the staging environment we create [HELLO_APP_STAGING_CLUSTER_1]( + /management-clusters/MC_NAME/organizations/ORG_NAME/workload-clusters/HELLO_APP_STAGING_CLUSTER_1/kustomization.yaml) +- from the dev environment we create [HELLO_APP_PROD_CLUSTER_1]( + /management-clusters/MC_NAME/organizations/ORG_NAME/workload-clusters/HELLO_APP_PROD_CLUSTER_1/kustomization.yaml) + +All of their `kustomization.yaml` look very similar. Let's take a look at the development environment instance. + +```sh +mkdir HELLO_APP_DEV_CLUSTER_1 + +cat < HELLO_APP_DEV_CLUSTER_1/kustomization.yaml +apiVersion: kustomize.config.k8s.io/v1beta1 +buildMetadata: [originAnnotations] +kind: Kustomization +resources: + - ../../../../../../bases/environments/stages/dev/hello_app_cluster +EOF +``` + +It basically just references our environment base. But in more complex examples it could do more. + +Think back on the example of having multiple regions or data centers where you need to set specific +configurations. In such a case you would end upt with something like the below setup. + +You have workload cluster for each of them as `HELLO_APP_DEV_CLUSTER_AP_EAST_1`, `HELLO_APP_DEV_CLUSTER_EU_CENTRAL_1` +and `HELLO_APP_DEV_CLUSTER_US_WEST_2`. Their `kustomization.yaml` would look something like this. + +```yaml +apiVersion: kustomize.config.k8s.io/v1beta1 +buildMetadata: [originAnnotations] +kind: Kustomization +resources: + - ../../../../../../bases/environments/stages/dev/hello_app_cluster + - ../../../../../../bases/environments/regions/[[ REGION_NAME ]] +``` + +## Tips for developing environments + +For complex clusters, you can end up merging a lot of layers of templates and configurations. +Under `tools` folder in this repository you can find the `fake-flux-build` script that helps +you render and inspect the final result. For more information check [tools/README.md](/tools/README.md). diff --git a/docs/add_wc_template.md b/docs/add_wc_template.md index 0ff2070c..c1f66815 100644 --- a/docs/add_wc_template.md +++ b/docs/add_wc_template.md @@ -7,7 +7,7 @@ a [Vintage cluster template](./add_wc_template_vintage.md) or the new [CAPI based cluster template](./add_wc_template_capi.md). Please check these docs about how to add a template in each of the cases. -If the template you need already exists, you can skip this step and continue to recommended next steps: +If the template you need already exists, you can skip this step and continue to the recommended next steps: - [Add a new Workload Cluster repository structure](./add_wc_structure.md) - [Add Workload Cluster instance](./add_wc_instance.md) diff --git a/docs/appendices.md b/docs/appendices.md index b3a198b6..c2b45b4e 100644 --- a/docs/appendices.md +++ b/docs/appendices.md @@ -11,7 +11,7 @@ This section contains the list of tools used thought the code examples in this r ### Core utilities -For core utilties like `base64`, `sed`, `tr`, etc. GNU compatible versions are assumed in the code examples. +For core utilities like `base64`, `sed`, `tr`, etc. GNU compatible versions are assumed in the code examples. ### Working with YAML files diff --git a/management-clusters/MC_NAME/organizations/ORG_NAME/workload-clusters/HELLO_APP_DEV_CLUSTER_1.yaml b/management-clusters/MC_NAME/organizations/ORG_NAME/workload-clusters/HELLO_APP_DEV_CLUSTER_1.yaml new file mode 100644 index 00000000..9e9f6c06 --- /dev/null +++ b/management-clusters/MC_NAME/organizations/ORG_NAME/workload-clusters/HELLO_APP_DEV_CLUSTER_1.yaml @@ -0,0 +1,22 @@ +apiVersion: kustomize.toolkit.fluxcd.io/v1beta2 +kind: Kustomization +metadata: + name: clusters-CAPI_WC_NAME + namespace: default +spec: + interval: 1m + path: "./management-clusters/MC_NAME/organizations/ORG_NAME/workload-clusters/HELLO_APP_DEV_CLUSTER_1" + postBuild: + substitute: + cluster_domain: "MY_DOMAIN" + cluster_id: "HELLO_APP_DEV_1" + cluster_name: "HELLO_APP_DEV_1" + cluster_release: "0.8.1" + default_apps_release: "0.2.0" + organization: "ORG_NAME" + prune: false + serviceAccountName: automation + sourceRef: + kind: GitRepository + name: REPO_NAME + timeout: 2m diff --git a/management-clusters/MC_NAME/organizations/ORG_NAME/workload-clusters/HELLO_APP_DEV_CLUSTER_1/kustomization.yaml b/management-clusters/MC_NAME/organizations/ORG_NAME/workload-clusters/HELLO_APP_DEV_CLUSTER_1/kustomization.yaml new file mode 100644 index 00000000..6775fcf7 --- /dev/null +++ b/management-clusters/MC_NAME/organizations/ORG_NAME/workload-clusters/HELLO_APP_DEV_CLUSTER_1/kustomization.yaml @@ -0,0 +1,5 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +buildMetadata: [originAnnotations] +kind: Kustomization +resources: + - ../../../../../../bases/environments/stages/dev/hello_app_cluster diff --git a/management-clusters/MC_NAME/organizations/ORG_NAME/workload-clusters/HELLO_APP_PROD_CLUSTER_1.yaml b/management-clusters/MC_NAME/organizations/ORG_NAME/workload-clusters/HELLO_APP_PROD_CLUSTER_1.yaml new file mode 100644 index 00000000..c4e1ccc4 --- /dev/null +++ b/management-clusters/MC_NAME/organizations/ORG_NAME/workload-clusters/HELLO_APP_PROD_CLUSTER_1.yaml @@ -0,0 +1,22 @@ +apiVersion: kustomize.toolkit.fluxcd.io/v1beta2 +kind: Kustomization +metadata: + name: clusters-CAPI_WC_NAME + namespace: default +spec: + interval: 1m + path: "./management-clusters/MC_NAME/organizations/ORG_NAME/workload-clusters/HELLO_APP_PROD_CLUSTER_1" + postBuild: + substitute: + cluster_domain: "MY_DOMAIN" + cluster_id: "HELLO_APP_PROD_1" + cluster_name: "HELLO_APP_PROD_1" + cluster_release: "0.8.1" + default_apps_release: "0.2.0" + organization: "ORG_NAME" + prune: false + serviceAccountName: automation + sourceRef: + kind: GitRepository + name: REPO_NAME + timeout: 2m diff --git a/management-clusters/MC_NAME/organizations/ORG_NAME/workload-clusters/HELLO_APP_PROD_CLUSTER_1/kustomization.yaml b/management-clusters/MC_NAME/organizations/ORG_NAME/workload-clusters/HELLO_APP_PROD_CLUSTER_1/kustomization.yaml new file mode 100644 index 00000000..af315ebb --- /dev/null +++ b/management-clusters/MC_NAME/organizations/ORG_NAME/workload-clusters/HELLO_APP_PROD_CLUSTER_1/kustomization.yaml @@ -0,0 +1,5 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +buildMetadata: [originAnnotations] +kind: Kustomization +resources: + - ../../../../../../bases/environments/stages/prod/hello_app_cluster diff --git a/management-clusters/MC_NAME/organizations/ORG_NAME/workload-clusters/HELLO_APP_STAGING_CLUSTER_1.yaml b/management-clusters/MC_NAME/organizations/ORG_NAME/workload-clusters/HELLO_APP_STAGING_CLUSTER_1.yaml new file mode 100644 index 00000000..9f7aeaaf --- /dev/null +++ b/management-clusters/MC_NAME/organizations/ORG_NAME/workload-clusters/HELLO_APP_STAGING_CLUSTER_1.yaml @@ -0,0 +1,22 @@ +apiVersion: kustomize.toolkit.fluxcd.io/v1beta2 +kind: Kustomization +metadata: + name: clusters-CAPI_WC_NAME + namespace: default +spec: + interval: 1m + path: "./management-clusters/MC_NAME/organizations/ORG_NAME/workload-clusters/HELLO_APP_STAGING_CLUSTER_1" + postBuild: + substitute: + cluster_domain: "MY_DOMAIN" + cluster_id: "HELLO_APP_STAGING_1" + cluster_name: "HELLO_APP_STAGING_1" + cluster_release: "0.8.1" + default_apps_release: "0.2.0" + organization: "ORG_NAME" + prune: false + serviceAccountName: automation + sourceRef: + kind: GitRepository + name: REPO_NAME + timeout: 2m diff --git a/management-clusters/MC_NAME/organizations/ORG_NAME/workload-clusters/HELLO_APP_STAGING_CLUSTER_1/kustomization.yaml b/management-clusters/MC_NAME/organizations/ORG_NAME/workload-clusters/HELLO_APP_STAGING_CLUSTER_1/kustomization.yaml new file mode 100644 index 00000000..f4fca841 --- /dev/null +++ b/management-clusters/MC_NAME/organizations/ORG_NAME/workload-clusters/HELLO_APP_STAGING_CLUSTER_1/kustomization.yaml @@ -0,0 +1,5 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +buildMetadata: [originAnnotations] +kind: Kustomization +resources: + - ../../../../../../bases/environments/stages/staging/hello_app_cluster diff --git a/management-clusters/MC_NAME/organizations/ORG_NAME/workload-clusters/kustomization.yaml b/management-clusters/MC_NAME/organizations/ORG_NAME/workload-clusters/kustomization.yaml index 0d9e3f4b..68806ffe 100644 --- a/management-clusters/MC_NAME/organizations/ORG_NAME/workload-clusters/kustomization.yaml +++ b/management-clusters/MC_NAME/organizations/ORG_NAME/workload-clusters/kustomization.yaml @@ -6,6 +6,10 @@ kind: Kustomization resources: - FROM_TEMPLATE_WC_NAME.yaml - CAPI_WC_NAME.yaml +- WC_NAME.yaml +- HELLO_APP_PROD_CLUSTER_1.yaml +- HELLO_APP_STAGING_CLUSTER_1.yaml +- HELLO_APP_DEV_CLUSTER_1.yaml - WC_NAME_NO_OUT_OF_BAND.yaml - WC_NAME_OUT_OF_BAND_FLUX_APP.yaml - WC_NAME_OUT_OF_BAND_NO_FLUX_APP.yaml