diff --git a/packages/system/fluxcd/Makefile b/packages/system/fluxcd/Makefile index 2aca5f05..907ab40a 100644 --- a/packages/system/fluxcd/Makefile +++ b/packages/system/fluxcd/Makefile @@ -1,7 +1,11 @@ NAME=fluxcd NAMESPACE=cozy-$(NAME) +include ../../../scripts/package.mk + apply-locally: helm upgrade -i -n $(NAMESPACE) $(NAME) . -include ../../../scripts/package.mk +update: + rm -rf charts + helm pull oci://ghcr.io/controlplaneio-fluxcd/charts/flux-instance --untar --untardir charts diff --git a/packages/system/fluxcd/charts/flux-instance/.helmignore b/packages/system/fluxcd/charts/flux-instance/.helmignore new file mode 100644 index 00000000..f24ae1c9 --- /dev/null +++ b/packages/system/fluxcd/charts/flux-instance/.helmignore @@ -0,0 +1,24 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ +helmdocs.gotmpl diff --git a/packages/system/fluxcd/charts/flux-instance/Chart.yaml b/packages/system/fluxcd/charts/flux-instance/Chart.yaml new file mode 100644 index 00000000..8994b5cd --- /dev/null +++ b/packages/system/fluxcd/charts/flux-instance/Chart.yaml @@ -0,0 +1,28 @@ +annotations: + artifacthub.io/license: AGPL-3.0 + artifacthub.io/links: | + - name: Documentation + url: https://fluxcd.control-plane.io/operator + - name: Chart Source + url: https://github.com/controlplaneio-fluxcd/charts + - name: Upstream Project + url: https://github.com/controlplaneio-fluxcd/flux-operator +apiVersion: v2 +appVersion: v0.9.0 +description: 'A Helm chart for deploying a Flux instance managed by Flux Operator. ' +home: https://github.com/controlplaneio-fluxcd +icon: https://raw.githubusercontent.com/cncf/artwork/main/projects/flux/icon/color/flux-icon-color.png +keywords: +- flux +- fluxcd +- gitops +kubeVersion: '>=1.22.0-0' +maintainers: +- email: flux-enterprise@control-plane.io + name: ControlPlane Flux Team +name: flux-instance +sources: +- https://github.com/controlplaneio-fluxcd/flux-operator +- https://github.com/controlplaneio-fluxcd/charts +type: application +version: 0.9.0 diff --git a/packages/system/fluxcd/charts/flux-instance/README.md b/packages/system/fluxcd/charts/flux-instance/README.md new file mode 100644 index 00000000..68dbba33 --- /dev/null +++ b/packages/system/fluxcd/charts/flux-instance/README.md @@ -0,0 +1,52 @@ +# flux-instance + +![Version: 0.9.0](https://img.shields.io/badge/Version-0.9.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: v0.9.0](https://img.shields.io/badge/AppVersion-v0.9.0-informational?style=flat-square) + +This chart is a thin wrapper around the `FluxInstance` custom resource, which is +used by the [Flux Operator](https://github.com/controlplaneio-fluxcd/flux-operator) +to install, configure and automatically upgrade Flux. + +## Prerequisites + +- Kubernetes 1.22+ +- Helm 3.8+ + +## Installing the Chart + +To deploy Flux in the `flux-system` namespace: + +```console +helm -n flux-system install flux oci://ghcr.io/controlplaneio-fluxcd/charts/flux-instance +``` + +For more information on the available configuration options, +see the [Flux Instance documentation](https://fluxcd.control-plane.io/operator/fluxinstance/). + +## Uninstalling the Chart + +To uninstall Flux without affecting the resources it manages: + +```console +helm -n flux-system uninstall flux +``` + +## Values + +| Key | Type | Default | Description | +|-----|------|---------|-------------| +| commonAnnotations | object | `{}` | Common annotations to add to all deployed objects including pods. | +| commonLabels | object | `{}` | Common labels to add to all deployed objects including pods. | +| fullnameOverride | string | `"flux"` | | +| instance.cluster | object | `{"domain":"cluster.local","multitenant":false,"networkPolicy":true,"tenantDefaultServiceAccount":"default","type":"kubernetes"}` | Cluster https://fluxcd.control-plane.io/operator/fluxinstance/#cluster-configuration | +| instance.components | list | `["source-controller","kustomize-controller","helm-controller","notification-controller"]` | Components https://fluxcd.control-plane.io/operator/fluxinstance/#components-configuration | +| instance.distribution | object | `{"artifact":"oci://ghcr.io/controlplaneio-fluxcd/flux-operator-manifests:latest","imagePullSecret":"","registry":"ghcr.io/fluxcd","version":"2.x"}` | Distribution https://fluxcd.control-plane.io/operator/fluxinstance/#distribution-configuration | +| instance.kustomize.patches | list | `[]` | Kustomize patches https://fluxcd.control-plane.io/operator/fluxinstance/#kustomize-patches | +| instance.sharding | object | `{"key":"sharding.fluxcd.io/key","shards":[]}` | Sharding https://fluxcd.control-plane.io/operator/fluxinstance/#sharding-configuration | +| instance.storage | object | `{"class":"","size":""}` | Storage https://fluxcd.control-plane.io/operator/fluxinstance/#storage-configuration | +| instance.sync | object | `{"kind":"GitRepository","path":"","pullSecret":"","ref":"","url":""}` | Sync https://fluxcd.control-plane.io/operator/fluxinstance/#sync-configuration | +| nameOverride | string | `""` | | + +## Source Code + +* +* diff --git a/packages/system/fluxcd/charts/flux-instance/templates/NOTES.txt b/packages/system/fluxcd/charts/flux-instance/templates/NOTES.txt new file mode 100644 index 00000000..b09e5e52 --- /dev/null +++ b/packages/system/fluxcd/charts/flux-instance/templates/NOTES.txt @@ -0,0 +1 @@ +Documentation at https://fluxcd.control-plane.io/operator/ diff --git a/packages/system/fluxcd/charts/flux-instance/templates/_helpers.tpl b/packages/system/fluxcd/charts/flux-instance/templates/_helpers.tpl new file mode 100644 index 00000000..f04148b5 --- /dev/null +++ b/packages/system/fluxcd/charts/flux-instance/templates/_helpers.tpl @@ -0,0 +1,51 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "flux-instance.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "flux-instance.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "flux-instance.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "flux-instance.labels" -}} +helm.sh/chart: {{ include "flux-instance.chart" . }} +{{ include "flux-instance.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "flux-instance.selectorLabels" -}} +app.kubernetes.io/name: {{ include "flux-instance.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} diff --git a/packages/system/fluxcd/charts/flux-instance/templates/instance.yaml b/packages/system/fluxcd/charts/flux-instance/templates/instance.yaml new file mode 100644 index 00000000..ebcd0629 --- /dev/null +++ b/packages/system/fluxcd/charts/flux-instance/templates/instance.yaml @@ -0,0 +1,43 @@ +apiVersion: fluxcd.controlplane.io/v1 +kind: FluxInstance +metadata: + name: {{ include "flux-instance.fullname" . }} + namespace: {{ .Release.Namespace }} + labels: + {{- include "flux-instance.labels" . | nindent 4 }} + {{- with .Values.commonLabels }} + {{- toYaml . | nindent 4 }} + {{- end }} + {{- with .Values.commonAnnotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + distribution: + version: {{ .Values.instance.distribution.version }} + registry: {{ .Values.instance.distribution.registry }} + artifact: {{ .Values.instance.distribution.artifact }} + {{- if .Values.instance.distribution.imagePullSecret }} + imagePullSecret: {{ .Values.instance.distribution.imagePullSecret }} + {{- end }} + components: {{ .Values.instance.components | toYaml | nindent 4 }} + cluster: {{ .Values.instance.cluster | toYaml | nindent 4 }} + kustomize: {{ .Values.instance.kustomize | toYaml | nindent 4 }} + {{- if .Values.instance.sync.url }} + sync: + kind: {{ .Values.instance.sync.kind }} + url: {{ .Values.instance.sync.url }} + ref: {{ .Values.instance.sync.ref }} + path: {{ .Values.instance.sync.path }} + {{- if .Values.instance.sync.pullSecret }} + pullSecret: {{ .Values.instance.sync.pullSecret }} + {{- end }} + {{- end }} + {{- if .Values.instance.storage.size }} + storage: {{ .Values.instance.storage | toYaml | nindent 4 }} + {{- end }} + {{- if .Values.instance.sharding.shards }} + sharding: + key: {{ .Values.instance.sharding.key }} + shards: {{ .Values.instance.sharding.shards | toYaml | nindent 4 }} + {{- end }} diff --git a/packages/system/fluxcd/charts/flux-instance/values.schema.json b/packages/system/fluxcd/charts/flux-instance/values.schema.json new file mode 100644 index 00000000..a3cd648c --- /dev/null +++ b/packages/system/fluxcd/charts/flux-instance/values.schema.json @@ -0,0 +1,153 @@ +{ + "$schema": "https://json-schema.org/draft/2019-09/schema", + "properties": { + "commonAnnotations": { + "properties": {}, + "type": "object" + }, + "commonLabels": { + "properties": {}, + "type": "object" + }, + "fullnameOverride": { + "type": "string" + }, + "instance": { + "properties": { + "cluster": { + "properties": { + "domain": { + "type": "string" + }, + "multitenant": { + "type": "boolean" + }, + "networkPolicy": { + "type": "boolean" + }, + "tenantDefaultServiceAccount": { + "type": "string" + }, + "type": { + "enum": [ + "kubernetes", + "openshift", + "aws", + "azure", + "gcp" + ], + "type": "string" + } + }, + "type": "object" + }, + "components": { + "items": { + "enum": [ + "source-controller", + "kustomize-controller", + "helm-controller", + "notification-controller", + "image-reflector-controller", + "image-automation-controller" + ], + "type": "string" + }, + "type": "array", + "uniqueItems": true + }, + "distribution": { + "properties": { + "artifact": { + "type": "string" + }, + "imagePullSecret": { + "type": "string" + }, + "registry": { + "type": "string" + }, + "version": { + "type": "string" + } + }, + "required": [ + "version", + "registry" + ], + "type": "object" + }, + "kustomize": { + "properties": { + "patches": { + "items": { + "type": "object" + }, + "type": "array" + } + }, + "type": "object" + }, + "sharding": { + "properties": { + "key": { + "type": "string" + }, + "shards": { + "items": { + "type": "string" + }, + "type": "array" + } + }, + "type": "object" + }, + "storage": { + "properties": { + "class": { + "type": "string" + }, + "size": { + "type": "string" + } + }, + "type": "object" + }, + "sync": { + "properties": { + "kind": { + "enum": [ + "GitRepository", + "OCIRepository", + "Bucket" + ], + "type": "string" + }, + "path": { + "type": "string" + }, + "pullSecret": { + "type": "string" + }, + "ref": { + "type": "string" + }, + "url": { + "type": "string" + } + }, + "type": "object" + } + }, + "required": [ + "distribution", + "cluster" + ], + "type": "object" + }, + "nameOverride": { + "type": "string" + } + }, + "type": "object" +} diff --git a/packages/system/fluxcd/charts/flux-instance/values.yaml b/packages/system/fluxcd/charts/flux-instance/values.yaml new file mode 100644 index 00000000..c6426a13 --- /dev/null +++ b/packages/system/fluxcd/charts/flux-instance/values.yaml @@ -0,0 +1,49 @@ +# Default values for flux-instance. + +nameOverride: "" +fullnameOverride: "flux" + +instance: + # -- Distribution https://fluxcd.control-plane.io/operator/fluxinstance/#distribution-configuration + distribution: # @schema required: true + version: "2.x" # @schema required: true + registry: "ghcr.io/fluxcd" # @schema required: true + artifact: "oci://ghcr.io/controlplaneio-fluxcd/flux-operator-manifests:latest" + imagePullSecret: "" + # -- Components https://fluxcd.control-plane.io/operator/fluxinstance/#components-configuration + components: # @schema item: string; uniqueItems: true; itemEnum: [source-controller,kustomize-controller,helm-controller,notification-controller,image-reflector-controller,image-automation-controller] + - source-controller + - kustomize-controller + - helm-controller + - notification-controller + # -- Cluster https://fluxcd.control-plane.io/operator/fluxinstance/#cluster-configuration + cluster: # @schema required: true + type: kubernetes # @schema enum:[kubernetes,openshift,aws,azure,gcp] + domain: "cluster.local" + networkPolicy: true + multitenant: false + tenantDefaultServiceAccount: "default" + # -- Storage https://fluxcd.control-plane.io/operator/fluxinstance/#storage-configuration + storage: # @schema required: false + class: "" + size: "" + # -- Sharding https://fluxcd.control-plane.io/operator/fluxinstance/#sharding-configuration + sharding: # @schema required: false + key: "sharding.fluxcd.io/key" + shards: [] # @schema item: string + # -- Sync https://fluxcd.control-plane.io/operator/fluxinstance/#sync-configuration + sync: # @schema required: false + kind: "GitRepository" # @schema enum:[GitRepository,OCIRepository,Bucket] + url: "" + ref: "" + path: "" + pullSecret: "" + kustomize: # @schema required: false + # -- Kustomize patches https://fluxcd.control-plane.io/operator/fluxinstance/#kustomize-patches + patches: [] # @schema item: object + +# -- Common annotations to add to all deployed objects including pods. +commonAnnotations: { } + +# -- Common labels to add to all deployed objects including pods. +commonLabels: { } diff --git a/packages/system/fluxcd/templates/flux-instance.yaml b/packages/system/fluxcd/templates/flux-instance.yaml deleted file mode 100644 index ce0fd133..00000000 --- a/packages/system/fluxcd/templates/flux-instance.yaml +++ /dev/null @@ -1,25 +0,0 @@ -apiVersion: fluxcd.controlplane.io/v1 -kind: FluxInstance -metadata: - name: flux -spec: - {{- with .Values.cluster }} - cluster: - {{- with .networkPolicy }} - networkPolicy: {{ . }} - {{- end }} - {{- with .domain }} - domain: {{ . }} - {{- end }} - {{- end }} - distribution: - version: {{ .Values.distribution.version }} - registry: {{ .Values.distribution.registry }} - components: - {{- if .Values.components }} - {{- toYaml .Values.components | nindent 4 }} - {{- end }} - kustomize: - {{- if .Values.kustomize }} - {{- toYaml .Values.kustomize | nindent 4 }} - {{- end }} diff --git a/packages/system/fluxcd/values.yaml b/packages/system/fluxcd/values.yaml index 9eba35ec..c766a685 100644 --- a/packages/system/fluxcd/values.yaml +++ b/packages/system/fluxcd/values.yaml @@ -1,47 +1,49 @@ -cluster: - networkPolicy: true -# domain: cozy.local -distribution: - version: 2.3.x - registry: ghcr.io/fluxcd -components: - - source-controller - - kustomize-controller - - helm-controller - - notification-controller - - image-reflector-controller - - image-automation-controller -kustomize: - patches: - - target: - kind: Deployment - name: "(kustomize-controller|helm-controller|source-controller)" - patch: | - - op: add - path: /spec/template/spec/containers/0/args/- - value: --concurrent=20 - - op: add - path: /spec/template/spec/containers/0/args/- - value: --requeue-dependency=5s - - op: replace - path: /spec/template/spec/containers/0/resources/limits - value: - cpu: 2000m - memory: 2048Mi - - target: - kind: Deployment - name: source-controller - patch: | - - op: add - path: /spec/template/spec/containers/0/args/- - value: --storage-adv-addr=source-controller.cozy-fluxcd.svc - - op: add - path: /spec/template/spec/containers/0/args/- - value: --events-addr=http://notification-controller.cozy-fluxcd.svc/ - - target: - kind: Deployment - name: (kustomize-controller|helm-controller|image-reflector-controller|image-automation-controller) - patch: | - - op: add - path: /spec/template/spec/containers/0/args/- - value: --events-addr=http://notification-controller.cozy-fluxcd.svc/ +flux-instance: + instance: + cluster: + networkPolicy: true + domain: cozy.local # -- default value is overriden in patches + distribution: + version: 2.3.x + registry: ghcr.io/fluxcd + components: + - source-controller + - kustomize-controller + - helm-controller + - notification-controller + - image-reflector-controller + - image-automation-controller + kustomize: + patches: + - target: + kind: Deployment + name: "(kustomize-controller|helm-controller|source-controller)" + patch: | + - op: add + path: /spec/template/spec/containers/0/args/- + value: --concurrent=20 + - op: add + path: /spec/template/spec/containers/0/args/- + value: --requeue-dependency=5s + - op: replace + path: /spec/template/spec/containers/0/resources/limits + value: + cpu: 2000m + memory: 2048Mi + - target: + kind: Deployment + name: source-controller + patch: | + - op: add + path: /spec/template/spec/containers/0/args/- + value: --storage-adv-addr=source-controller.cozy-fluxcd.svc + - op: add + path: /spec/template/spec/containers/0/args/- + value: --events-addr=http://notification-controller.cozy-fluxcd.svc/ + - target: + kind: Deployment + name: (kustomize-controller|helm-controller|image-reflector-controller|image-automation-controller) + patch: | + - op: add + path: /spec/template/spec/containers/0/args/- + value: --events-addr=http://notification-controller.cozy-fluxcd.svc/