-
Business problem being solved for
Currently, we have a large helm chart that includes external dependencies as sub-charts (e.g. a helm chart for databases, another for controllers, another for operators, etc.) We are attempting to convert this helm chart into timoni module / bundle analogues. The problem is: How to reliably include external dependencies as part of a timoni module? Currently we use Helm sub-charts to include external dependencies as part of our helm chart.
Example
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 8 replies
-
I think I just found the ideal solution. I don't know why I didn't see it in the docs earlier. timoni bundle syntax supports local folder as a module reference. Referencing a local module folder means I don't need 2 bundle files, just 1, and I don't need to push and pull OCI artifacts. Below is a what I got working with local folder reference: // my-apps/bundles/my-apps-for-a-clean-cluster.cue
bundle: {
apiVersion: "v1alpha1"
name: "my-apps"
// timoni will deploy the following instances in the order they are defined below
instances: {
// flux is necessary to deploy first because it will deploy HelmRepository and HelmRelease CRDs
// these CRDs are used later to allow Flux to deploy our external dependencies
"flux": {
module: url: "oci://ghcr.io/stefanprodan/modules/flux-aio"
namespace: "flux-system"
values: {
controllers: {
helm: enabled: true
kustomize: enabled: false
notification: enabled: false
}
hostNetwork: false
securityProfile: "privileged"
}
}
// Install external dependencies
"cert-manager": {
module: url: "oci://ghcr.io/stefanprodan/modules/flux-helm-release"
namespace: "cert-manager"
values: {
repository: url: "https://charts.jetstack.io"
chart: {
name: "cert-manager"
version: "1.x"
}
helmValues: {
installCRDs: true
}
}
}
// Install external dependencies
"ingress-nginx": {
module: url: "oci://ghcr.io/stefanprodan/modules/flux-helm-release"
namespace: "ingress-nginx"
values: {
repository: url: "https://kubernetes.github.io/ingress-nginx"
chart: {
name: "ingress-nginx"
version: "4.x"
}
helmValues: {
controller: service: type: "NodePort"
}
}
}
// Install my apps module (analogue of helm chart)
"my-apps": {
module: url: "file://../." // <<<<< Local folder reference (relative to current working directory)
namespace: "my-apps"
values: {}
}
}
} However, I did notice that with this approach, the external dependencies of This is not a deal breaker for us, because we can still add flux to our bundle like above, but then create the custom resources for |
Beta Was this translation helpful? Give feedback.
-
Sharing syntax here for anyone who may need to include Flux CRDs in their module: package templates
import (
timoniv1 "timoni.sh/core/v1alpha1"
flux_helmrelease "helm.toolkit.fluxcd.io/helmrelease/v2"
)
// Reference: https://fluxcd.io/flux/components/helm/helmreleases/
#BitnamiRedisHelmRelease: flux_helmrelease.#HelmRelease & {
#config: #Config
// **********************************************
// I was looking for elegant syntax like this:
metadata: timoniv1.#MetaComponent & {
#Meta: #config.metadata
#Component: "redis"
}
// **********************************************
spec: flux_helmrelease.#HelmReleaseSpec & {
#config.bitnamiHelmRepository.redis.releaseSpec
}
} |
Beta Was this translation helpful? Give feedback.
After some more deliberations and looking at
GetBundle
ininternal/engine/bundle_builder.go
and how it is used incmd/timoni/bundle_build.go
, it feels that the CUE configuration is preferred at the bundle level, and the--namespace
flag has no effect.So the cleanest solution now is to utilize some CUE and timoni techniques to allow the namespace to be configurable at the bundle level.
With below file: