Help on Understanding a Dependency Misconfiguration #5172
-
|
Hello everyone. This is a classical directory structure for repositories hosting flux .
└── replica
├── flux-system
│ ├── gotk-components.yaml
│ ├── gotk-sync.yaml
│ └── kustomization.yaml
├── infra
│ ├── configurations
│ │ ├── cluster-secret
│ │ ├── datadog-agent
│ │ ├── istio
│ │ ├── karpenter
│ │ ├── ks.yaml
│ │ └── weaveworks-dashboard
│ ├── controllers
│ │ ├── alb
│ │ ├── cert-manager
│ │ ├── cluster-secret
│ │ ├── datadog-operator
│ │ ├── istio
│ │ ├── karpenter
│ │ ├── kiali
│ │ ├── ks.yaml
│ │ ├── locust
│ │ └── metrics-server
│ └── kustomization.yaml
└── README.mdSo nothing special here.
# This manifest was generated by flux. DO NOT EDIT.
---
apiVersion: source.toolkit.fluxcd.io/v1
kind: GitRepository
metadata:
name: flux-system
namespace: flux-system
spec:
interval: 1m0s
ref:
branch: master
secretRef:
name: flux-system
url: https://github.com/KeylessTech/kl_kubernetes.git
---
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
metadata:
name: flux-system
namespace: flux-system
spec:
interval: 10m0s
path: ./clusters/staging/replica
prune: true
sourceRef:
kind: GitRepository
name: flux-systemAs we are on EKS we run flux with a role to access KMS, again nothing special here.
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- gotk-components.yaml
- gotk-sync.yaml
patches:
- patch: |
apiVersion: v1
kind: ServiceAccount
metadata:
name: controller
annotations:
eks.amazonaws.com/role-arn: "arn:aws:iam::446813827414:role/flux-kms-role"
target:
kind: ServiceAccount
name: "kustomize-controller"We also have dependencies between
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- configurations/ks.yaml
- controllers/ks.yaml
---
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
metadata:
name: controllers
namespace: flux-system
spec:
interval: 1m
path: "./clusters/staging/replica/infra/controllers"
prune: true
sourceRef:
kind: GitRepository
name: flux-system
decryption:
provider: sops
---
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
metadata:
name: configurations
namespace: flux-system
spec:
dependsOn:
- name: controllers <------------------------------------------- Notice the dependency here
interval: 1m
path: "./clusters/staging/replica/infra/configurations"
prune: true
sourceRef:
kind: GitRepository
name: flux-system
decryption:
provider: sopsHere's the simplified directory structure .
└── replica
├── flux-system
│ └── kustomization.yaml
├── infra
│ ├── configurations
│ │ └── ks.yaml
│ ├── controllers
│ │ └── ks.yaml
│ └── kustomization.yaml
└── README.mdThis all worked fine as expected. Now...we wanted to add some applications so that the directory structure would become the following we also wanted to explicitly say that
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- apps/ks.yaml
---
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
metadata:
name: apps
namespace: flux-system
spec:
dependsOn:
- name: controllers <------------------------------------------------------
interval: 1m
path: "./clusters/staging/replica/apps"
prune: true
sourceRef:
kind: GitRepository
name: flux-system
decryption:
provider: sops.
└── replica
│ └── kustomization.yaml <------------
├── apps
│ │ └── ks.yaml <---------------
│ └── my-app
│ └── foo.yaml
├── flux-system
│ ├── gotk-components.yaml
│ ├── gotk-sync.yaml
│ └── kustomization.yaml
├── infra
│ ├── configurations
│ │ └── ks.yaml
│ ├── controllers
│ │ └── ks.yaml
│ └── kustomization.yaml
└── README.mdNow, as soon as we merged this commit into our master branch ( tracked by source controller) flux started going mad, trying to reconcile every kustomization, disrupting the service, and even removing the flux-system namespace and of course everything that was deployed there, so I'm reasonably confident the directory structure is not correct. How should I structure the directories to achieve the dependency schema I want between them? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
Well, in the end I wasn't able to find a solution that was somewhat different than creating a subdirectory in so the kustomization.yaml looks like this while the ks.yaml file looks like this |
Beta Was this translation helpful? Give feedback.
Well, in the end I wasn't able to find a solution that was somewhat different than creating a subdirectory in
appsfolder mimickinginfrafolder configurations.i.e.
so the kustomization.…