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

[Addon] Update to Flux2 #722

Merged
merged 3 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 32 additions & 11 deletions addons/fluxcd/definitions/helm-release-def.cue
Original file line number Diff line number Diff line change
Expand Up @@ -61,23 +61,36 @@ template: {
outputs: {
if parameter.sourceName == _|_ {
repo: {
apiVersion: "source.toolkit.fluxcd.io/v1beta2"
metadata: {
name: context.name
}
if parameter.repoType == "git" {
kind: "GitRepository"
apiVersion: "source.toolkit.fluxcd.io/v1"
kind: "GitRepository"
spec: {
url: parameter.url
if parameter.git.branch != _|_ {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if parameter.git.branch != _|_ {
if parameter.git != _|_ {
ref: parameter.git
}

ref: branch: parameter.git.branch
}
if parameter.git.commit != _|_ {
ref: commit: parameter.git.commit
}
if parameter.git.name != _|_ {
ref: name: parameter.git.name
}
if parameter.git.semver != _|_ {
ref: semver: parameter.git.semver
}
if parameter.git.tag != _|_ {
ref: tag: parameter.git.tag
}
_secret
_sourceCommonArgs
}
}
if parameter.repoType == "oss" {
kind: "Bucket"
apiVersion: "source.toolkit.fluxcd.io/v1beta2"
kind: "Bucket"
spec: {
endpoint: parameter.url
bucketName: parameter.oss.bucketName
Expand All @@ -90,7 +103,8 @@ template: {
}
}
if parameter.repoType == "helm" || parameter.repoType == "oci" {
kind: "HelmRepository"
apiVersion: "source.toolkit.fluxcd.io/v1beta2"
kind: "HelmRepository"
spec: {
url: parameter.url
if parameter.repoType == "oci" {
Expand Down Expand Up @@ -152,7 +166,7 @@ template: {
values: parameter.values
}
if parameter.valuesFrom != _|_ {
valuesFrom: [for v in parameter.valuesFrom {{
valuesFrom: [ for v in parameter.valuesFrom {{
kind: v.kind
name: v.name
if v.valuesKey != _|_ {
Expand All @@ -177,7 +191,7 @@ template: {
}
if parameter.upgradeCRD != _|_ {
if parameter.upgradeCRD {
crds: "CreateReplace"
crds: "CreateReplace"
}
}
}
Expand Down Expand Up @@ -219,8 +233,16 @@ template: {
sourceName?: string

git?: {
// +usage=The Git reference to checkout and monitor for changes, defaults to main branch
branch: *"main" | string
// +usage=The Git branch to checkout and monitor for changes, defaults to main branch
branch?: *"main" | string
// +usage=The Git commit to checkout and monitor for changes, takes precedence over all reference fields
commit?: string
// +usage=The Git reference name to checkout and monitor for changes, takes precendence over branch, tag and semver
name?: string
// +usage=Semver tag expression to checkout and monitor for changes, takes precedence over tag
semver?: string
// +usage=The Git tag to checkout and monitor for changes, takes precedence over branch
tag?: string
}
oss?: {
// +usage=The bucket's name, required if repoType is oss
Expand All @@ -230,10 +252,9 @@ template: {
// +usage=The bucket region, optional
region?: string
}
helmrepository?: {
helmrepository?: {
// +usage=The OIDC provider used for authentication purposes.The generic provider can be used for public repositories or when static credentials are used for authentication, either with spec.secretRef or spec.serviceAccountName
provider: *"generic" | "azure" | "aws" | "gcp"

provider: *"generic" | "azure" | "aws" | "gcp"
}
// +usage=Alternative list of values files to use as the chart values (values.yaml is not included by default), expected to be a relative path in the SourceRef.Values files are merged in the order of this list with the last file overriding the first.
valuesFiles?: [...string]
Expand Down
65 changes: 43 additions & 22 deletions addons/fluxcd/definitions/kustomize.cue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ kustomize: {

template: {
output: {
apiVersion: "kustomize.toolkit.fluxcd.io/v1beta2"
apiVersion: "kustomize.toolkit.fluxcd.io/v1"
kind: "Kustomization"
metadata: {
name: context.name
Expand Down Expand Up @@ -48,32 +48,37 @@ template: {
outputs: {
if parameter.sourceName == _|_ {
repo: {
apiVersion: "source.toolkit.fluxcd.io/v1beta2"
metadata: {
name: context.name
namespace: context.namespace
}
if parameter.repoType == "git" {
kind: "GitRepository"
apiVersion: "source.toolkit.fluxcd.io/v1"
kind: "GitRepository"
spec: {
url: parameter.url
if parameter.git.branch != _|_ {
ref: branch: parameter.git.branch
}
if parameter.git.provider != _|_ {
if parameter.git.provider == "GitHub" {
gitImplementation: "go-git"
}
if parameter.git.provider == "AzureDevOps" {
gitImplementation: "libgit2"
}
if parameter.git.commit != _|_ {
ref: commit: parameter.git.commit
}
if parameter.git.name != _|_ {
ref: name: parameter.git.name
}
if parameter.git.semver != _|_ {
ref: semver: parameter.git.semver
}
if parameter.git.tag != _|_ {
ref: tag: parameter.git.tag
}
_secret
_sourceCommonArgs
}
}
if parameter.repoType == "oss" {
kind: "Bucket"
apiVersion: "source.toolkit.fluxcd.io/v1beta2"
kind: "Bucket"
spec: {
endpoint: parameter.url
bucketName: parameter.oss.bucketName
Expand All @@ -86,15 +91,22 @@ template: {
}
}
if parameter.repoType == "oci" {
kind: "OCIRepository"
apiVersion: "source.toolkit.fluxcd.io/v1beta2"
kind: "OCIRepository"
spec: {
url: parameter.url
if parameter.oci.provider != _|_ {
provider: parameter.oci.provider
}
if parameter.oci.tag != _|_ {
ref: tag: parameter.oci.tag
}
}
if parameter.oci.semver != _|_ {
ref: semver: parameter.oci.semver
}
if parameter.oci.digest != _|_ {
ref: digest: parameter.oci.digest
}
_secret
_sourceCommonArgs
}
Expand All @@ -104,7 +116,7 @@ template: {

if parameter.imageRepository != _|_ {
imageRepo: {
apiVersion: "image.toolkit.fluxcd.io/v1beta1"
apiVersion: "image.toolkit.fluxcd.io/v1beta2"
kind: "ImageRepository"
metadata: {
name: context.name
Expand All @@ -120,7 +132,7 @@ template: {
}

imagePolicy: {
apiVersion: "image.toolkit.fluxcd.io/v1beta1"
apiVersion: "image.toolkit.fluxcd.io/v1beta2"
kind: "ImagePolicy"
metadata: {
name: context.name
Expand Down Expand Up @@ -244,10 +256,16 @@ template: {
sourceName?: string

git?: {
// +usage=The Git reference to checkout and monitor for changes, defaults to master branch
branch: string
// +usage=Determines which git client library to use. Defaults to GitHub, it will pick go-git. AzureDevOps will pick libgit2.
provider?: *"GitHub" | "AzureDevOps"
// +usage=The Git branch to checkout and monitor for changes, defaults to main branch
branch?: *"main" | string
// +usage=The Git commit to checkout and monitor for changes, takes precedence over all reference fields
commit?: string
// +usage=The Git reference name to checkout and monitor for changes, takes precendence over branch, tag and semver
name?: string
// +usage=Semver tag expression to checkout and monitor for changes, takes precedence over tag
semver?: string
// +usage=The Git tag to checkout and monitor for changes, takes precedence over branch
tag?: string
}
oss?: {
// +usage=The bucket's name, required if repoType is oss
Expand All @@ -257,12 +275,15 @@ template: {
// +usage=The bucket region, optional
region?: string
}
oci?: {
oci?: {
// +usage=The OIDC provider used for authentication purposes.The generic provider can be used for public repositories or when static credentials are used for authentication, either with spec.secretRef or spec.serviceAccountName
provider: *"generic" | "azure" | "aws" | "gcp"
// +usage=The image tag
tag: *"latest" | string

tag?: string
// +usage=The image digest, takes precedence over all fields.
digest?: string
// +usage=Semver tag expression to checkout and monitor for changes, takes precedence over tag
semver?: string
}
//+usage=Path to the directory containing the kustomization.yaml file, or the set of plain YAMLs a kustomization.yaml should be generated for.
path: string
Expand Down
2 changes: 1 addition & 1 deletion addons/fluxcd/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: fluxcd
version: 2.3.6
version: 3.0.0
description: Extended workload to do continuous and progressive delivery
icon: https://raw.githubusercontent.com/cncf/artwork/master/projects/flux/horizontal/color/flux-horizontal-color.png
url: https://fluxcd.io
Expand Down
2 changes: 1 addition & 1 deletion addons/fluxcd/resources/components/helm-controller.cue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ helmController: {
dependsOn: ["fluxcd-ns"]
properties: {
imagePullPolicy: "IfNotPresent"
image: _base + "fluxcd/helm-controller:v0.28.1"
image: _base + "fluxcd/helm-controller:v0.36.0"
env: [
{
name: "RUNTIME_NAMESPACE"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ imageAutomationController: {
dependsOn: ["fluxcd-ns"]
properties: {
imagePullPolicy: "IfNotPresent"
image: _base + "fluxcd/image-automation-controller:v0.28.0"
image: _base + "fluxcd/image-automation-controller:v0.36.0"
env: [
{
name: "RUNTIME_NAMESPACE"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ imageReflectorController: {
dependsOn: ["fluxcd-ns"]
properties: {
imagePullPolicy: "IfNotPresent"
image: _base + "fluxcd/image-reflector-controller:v0.23.1"
image: _base + "fluxcd/image-reflector-controller:v0.30.0"
env: [
{
name: "RUNTIME_NAMESPACE"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ kustomizeController: {
dependsOn: ["fluxcd-ns"]
properties: {
imagePullPolicy: "IfNotPresent"
image: _base + "fluxcd/kustomize-controller:v0.32.0"
image: _base + "fluxcd/kustomize-controller:v1.1.0"
env: [
{
name: "RUNTIME_NAMESPACE"
Expand Down
2 changes: 1 addition & 1 deletion addons/fluxcd/resources/components/source-controller.cue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ sourceController: {
dependsOn: ["fluxcd-ns"]
properties: {
imagePullPolicy: "IfNotPresent"
image: _base + "fluxcd/source-controller:v0.33.0"
image: _base + "fluxcd/source-controller:v1.1.0"
env: [
{
name: "RUNTIME_NAMESPACE"
Expand Down
42 changes: 22 additions & 20 deletions addons/fluxcd/resources/crds/bucket.cue
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,16 @@ bucketCRD: {
apiVersion: "apiextensions.k8s.io/v1"
kind: "CustomResourceDefinition"
metadata: {
annotations: "controller-gen.kubebuilder.io/version": "v0.8.0"
annotations: "controller-gen.kubebuilder.io/version": "v0.12.0"
labels: {
"app.kubernetes.io/component": "source-controller"
"app.kubernetes.io/instance": "flux-system"
"app.kubernetes.io/part-of": "flux"
"kustomize.toolkit.fluxcd.io/name": "flux-system"
"kustomize.toolkit.fluxcd.io/namespace": "flux-system"
"app.kubernetes.io/component": "source-controller"
"app.kubernetes.io/instance": "flux-system"
"app.kubernetes.io/part-of": "flux"
"app.kubernetes.io/version": "v2.1.0"
}
name: "buckets.source.toolkit.fluxcd.io"
}
spec: {
conversion: strategy: "None"
group: "source.toolkit.fluxcd.io"
names: {
kind: "Bucket"
Expand Down Expand Up @@ -192,10 +190,10 @@ bucketCRD: {
description: "Conditions holds the conditions for the Bucket."
items: {
description: """
Condition contains details for one aspect of the current state of this API Resource. --- This struct is intended for direct use as an array at the field path .status.conditions. For example,
type FooStatus struct{ // Represents the observations of a foo's current state. // Known .status.conditions.type are: \"Available\", \"Progressing\", and \"Degraded\" // +patchMergeKey=type // +patchStrategy=merge // +listType=map // +listMapKey=type Conditions []metav1.Condition `json:\"conditions,omitempty\" patchStrategy:\"merge\" patchMergeKey:\"type\" protobuf:\"bytes,1,rep,name=conditions\"`
// other fields }
"""
Condition contains details for one aspect of the current state of this API Resource. --- This struct is intended for direct use as an array at the field path .status.conditions. For example,
type FooStatus struct{ // Represents the observations of a foo's current state. // Known .status.conditions.type are: \"Available\", \"Progressing\", and \"Degraded\" // +patchMergeKey=type // +patchStrategy=merge // +listType=map // +listMapKey=type Conditions []metav1.Condition `json:\"conditions,omitempty\" patchStrategy:\"merge\" patchMergeKey:\"type\" protobuf:\"bytes,1,rep,name=conditions\"`
// other fields }
"""

properties: {
lastTransitionTime: {
Expand Down Expand Up @@ -357,9 +355,10 @@ bucketCRD: {
type: "boolean"
}
interval: {
description: "Interval at which to check the Endpoint for updates."
pattern: "^([0-9]+(\\.[0-9]+)?(ms|s|m|h))+$"
type: "string"
description: "Interval at which the Bucket Endpoint is checked for updates. This interval is approximate and may be subject to jitter to ensure efficient use of resources."

pattern: "^([0-9]+(\\.[0-9]+)?(ms|s|m|h))+$"
type: "string"
}
provider: {
default: "generic"
Expand Down Expand Up @@ -416,8 +415,9 @@ bucketCRD: {
artifact: {
description: "Artifact represents the last successful Bucket reconciliation."
properties: {
checksum: {
description: "Checksum is the SHA256 checksum of the Artifact file."
digest: {
description: "Digest is the digest of the file in the form of '<algorithm>:<checksum>'."
pattern: "^[a-z0-9]+(?:[.+_-][a-z0-9]+)*:[a-zA-Z0-9=_-]+$"
type: "string"
}
lastUpdateTime: {
Expand Down Expand Up @@ -453,7 +453,9 @@ bucketCRD: {
}
}
required: [
"lastUpdateTime",
"path",
"revision",
"url",
]
type: "object"
Expand All @@ -462,10 +464,10 @@ bucketCRD: {
description: "Conditions holds the conditions for the Bucket."
items: {
description: """
Condition contains details for one aspect of the current state of this API Resource. --- This struct is intended for direct use as an array at the field path .status.conditions. For example,
type FooStatus struct{ // Represents the observations of a foo's current state. // Known .status.conditions.type are: \"Available\", \"Progressing\", and \"Degraded\" // +patchMergeKey=type // +patchStrategy=merge // +listType=map // +listMapKey=type Conditions []metav1.Condition `json:\"conditions,omitempty\" patchStrategy:\"merge\" patchMergeKey:\"type\" protobuf:\"bytes,1,rep,name=conditions\"`
// other fields }
"""
Condition contains details for one aspect of the current state of this API Resource. --- This struct is intended for direct use as an array at the field path .status.conditions. For example,
type FooStatus struct{ // Represents the observations of a foo's current state. // Known .status.conditions.type are: \"Available\", \"Progressing\", and \"Degraded\" // +patchMergeKey=type // +patchStrategy=merge // +listType=map // +listMapKey=type Conditions []metav1.Condition `json:\"conditions,omitempty\" patchStrategy:\"merge\" patchMergeKey:\"type\" protobuf:\"bytes,1,rep,name=conditions\"`
// other fields }
"""

properties: {
lastTransitionTime: {
Expand Down
Loading