source-controller: define source dependencies #326
-
Sometimes kustomizations need to combine manifests from multiple git repositories. For example one may keep most of their manifests for a given cluster type in one repo, while each cluster instance of this type contains parameters to patch into the cluster type manifests in its own repo. When using Note: while kustomizations can reference remote git refs in This could be supported by allowing sources to specify dependencies including where to store them within the dependent source artifact. For example: apiVersion: source.toolkit.fluxcd.io/v1beta1
kind: GitRepository
metadata:
name: type
# ...
---
apiVersion: source.toolkit.fluxcd.io/v1beta1
kind: GitRepository
metadata:
name: instance
spec:
dependsOn:
- name: type
targetPath: dependencies/type
# ...
---
apiVersion: kustomize.toolkit.fluxcd.io/v1beta1
kind: Kustomization
metadata:
name: deps
spec:
sourceRef:
kind: GitRepository
name: instance
path: . # < kustomization references `dependencies/type`
# ... This could also be used to potentially solve the following limitation (mentioned here with sourcing Helm charts from Git:
Alternatives
|
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 16 replies
-
When using remote bases, kustomize-controller does not support private repos, your proposal would solve this along with the caching problem. I don't think apiVersion: source.toolkit.fluxcd.io/v1beta1
kind: GitRepository
metadata:
name: app
# ...
---
apiVersion: source.toolkit.fluxcd.io/v1beta1
kind: GitRepository
metadata:
name: infra
spec:
include:
- name: app
namespace: gotk-system
from: "./deploy"
to: "./bases/apps/app"
# ...
---
apiVersion: kustomize.toolkit.fluxcd.io/v1beta1
kind: Kustomization
metadata:
name: infra
spec:
sourceRef:
kind: GitRepository
name: infra
path: ./clusters/prod # < kustomization.yaml references `../bases/apps/app`
# ... |
Beta Was this translation helpful? Give feedback.
-
I think 2 options are needed:
We use both but submodules more often. In our practice we compose fleet repository from cluster wide manifests and application/team manifests tracked in external repositories. In such scenario fleet repository contains main application kustomization in which external manifests is used as base or referenced somehow else. |
Beta Was this translation helpful? Give feedback.
-
We build workaround that uses kustomize (go-get) ability to fetch external resources. Of course it has drawbacks:
|
Beta Was this translation helpful? Give feedback.
-
Hello- I was wondering what the status of this discussion is. I'm really looking forward to adopt flux v2 for multitenancy, but I depend on git submodules to manage shared kustomize bases for various teams. So far with flux v1 I've been using flux.yaml file to pull those submodules using ssh keys that are registered with my ci bot user (instead of repo deploy key). Is there any way I can help? |
Beta Was this translation helpful? Give feedback.
-
Git submodulesStarting with flux2 v0.12 you can bootstrap with apiVersion: source.toolkit.fluxcd.io/v1beta1
kind: GitRepository
metadata:
name: repo-with-submodules
namespace: default
spec:
interval: 1m
url: https://github.com/<organization>/<repository>
secretRef:
name: https-credentials
ref:
branch: main
recurseSubmodules: true
gitImplementation: go-git
---
apiVersion: v1
kind: Secret
metadata:
name: https-credentials
namespace: default
type: Opaque
data:
username: <Username>
password: <Token or Password> Note that deploy keys can't be used to pull submodules from private repositories as GitHub and GitLab doesn't allow a deploy key to be reused across repositories. You have to use either HTTPS token-based authentication, or an SSH key belonging to a user that has access to the main repository and all its submodules. More info here. |
Beta Was this translation helpful? Give feedback.
-
Sorry to resurrect this from the past, but is there any intention of supporting a similar flow for OCI sources? Kustomize's support for remote OCI bases is stalled but the same security and performance concerns as for git remote bases exist, so it'd be preferable if there was some way to do this with Flux. |
Beta Was this translation helpful? Give feedback.
When using remote bases, kustomize-controller does not support private repos, your proposal would solve this along with the caching problem.
I don't think
dependsOn
is the right term to describe this features, my proposal is: