wait for infrastructure to be build before bringing up workload #155
Description
We have infrastructure that we need to build first which takes 15 min, then we create our app deployment which will use infrastructure
I tried to use fluxv2 Kustomization health assessment
In the example below I used Kustomization to check if the workspace
finished applying and then deploy our app.
But looks like workspace
CRD is not compatible with kstatus (unless I did something wrong)
---
apiVersion: kustomize.toolkit.fluxcd.io/v1beta2
kind: Kustomization
metadata:
name: infra-my-test-env-1
namespace: terraform-operator
spec:
interval: 5m
path: ./terraform-operator/kustomization # <- contains workspace
prune: true
sourceRef:
kind: GitRepository
name: flux-system
namespace: flux-system
healthChecks:
- apiVersion: app.terraform.io/v1alpha1
kind: Workspace
name: my-test-env-1
namespace: terraform-operator
---
apiVersion: source.toolkit.fluxcd.io/v1beta2
kind: GitRepository
metadata:
name: podinfo
namespace: terraform-operator
spec:
interval: 30s
ref:
branch: master
url: https://github.com/stefanprodan/podinfo
---
apiVersion: kustomize.toolkit.fluxcd.io/v1beta2
kind: Kustomization
metadata:
name: podinfo
namespace: terraform-operator
spec:
interval: 5m0s
path: ./kustomize
prune: true
sourceRef:
kind: GitRepository
name: podinfo
namespace: terraform-operator
dependsOn:
- name: infra-my-test-env-1
targetNamespace: terraform-operator
Helm will be more preferred way for me.
So I tried to use helm release. where I create helm chard which will template workspace
and defined dependency (so my app helm will wait for infra creation first) but helm applies and it is not waiting for apply
to complete. See example below
apiVersion: helm.toolkit.fluxcd.io/v2beta1
kind: HelmRelease
metadata:
name: redis-my-infra-v2
namespace: terraform-operator
spec:
interval: 5m
chart:
spec:
chart: terraform-operator/helm/tf-infra
sourceRef:
kind: GitRepository
name: flux-system
namespace: flux-system
interval: 1m
upgrade:
remediation:
remediateLastFailure: true
---
apiVersion: source.toolkit.fluxcd.io/v1beta2
kind: HelmRepository
metadata:
name: podinfo
namespace: terraform-operator
spec:
interval: 5m0s
url: https://stefanprodan.github.io/podinfo
---
apiVersion: helm.toolkit.fluxcd.io/v2beta1
kind: HelmRelease
metadata:
name: frontend
namespace: terraform-operator
spec:
interval: 5m
chart:
spec:
chart: podinfo
version: ">=4.0.0 <5.0.0"
sourceRef:
kind: HelmRepository
name: podinfo
namespace: terraform-operator
interval: 1m
dependsOn:
- name: redis-my-infra-v2
upgrade:
remediation:
remediateLastFailure: true
values:
backend: http://backend-podinfo:9898/echo
resources:
requests:
cpu: 100m
memory: 64Mi
The question is if there is a way to tell helm to wait for a workspace to apply.
Or is there another approach that I can take?