Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wait for infrastructure to be build before bringing up workload #155

Open
rpuserh opened this issue Jan 14, 2023 · 1 comment
Open

wait for infrastructure to be build before bringing up workload #155

rpuserh opened this issue Jan 14, 2023 · 1 comment
Labels
wontfix This will not be worked on

Comments

@rpuserh
Copy link

rpuserh commented Jan 14, 2023

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?

@rpuserh rpuserh added the bug Something isn't working label Jan 14, 2023
@rpuserh
Copy link
Author

rpuserh commented Jan 20, 2023

Any feedback on this ?

@alexsomesan alexsomesan added wontfix This will not be worked on and removed bug Something isn't working labels May 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants