Skip to content

Commit 10d3574

Browse files
authored
[fluxcd] Add flux-aio module and migration (#1698)
This change is extracted from - #1641 and reworked to work standalone requires: - #1705 ## What this PR does Adds a new `flux-aio` module and migration script to upgrade FluxCD to version 22. This introduces a new modular approach to FluxCD installation using the flux-aio OCI module. Changes: - Created new `flux-aio` package with Chart.yaml, Makefile, and CUE configuration - Added flux-aio module configuration using OCI module from `ghcr.io/stefanprodan/modules/flux-aio` - Generated large fluxcd.yaml template (11956+ lines) for FluxCD resources - Added migration script (migrations/21) to handle upgrade from version 21 to 22 - Updated installer to include flux-aio module - Added script `issue-flux-certificates.sh` for managing TLS certificates for cozystack-assets - Updated platform templates to support flux-aio module - Updated cozystack-assets service references ### Release note ```release-note [fluxcd] Add flux-aio module and migration ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Release Notes * **New Features** * Added TLS certificate support for Helm package repositories with automatic certificate provisioning. * **Chores** * Refactored FluxCD integration using Helm chart-based deployment. * Updated system to version 22 with automatic migration support. * Enhanced security dependencies (OpenSSL). <sub>✏️ Tip: You can customize this high-level summary in your review settings.</sub> <!-- end of auto-generated comment: release notes by coderabbit.ai -->
2 parents 61ec812 + 373a0d1 commit 10d3574

17 files changed

Lines changed: 12133 additions & 114 deletions

File tree

‎packages/core/flux-aio/Chart.yaml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
apiVersion: v2
2+
name: cozy-fluxcd
3+
version: 0.0.0 # Placeholder, the actual version will be automatically set during the build process

‎packages/core/flux-aio/Makefile‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
NAME=flux-aio
2+
NAMESPACE=cozy-$(NAME)
3+
4+
include ../../../scripts/common-envs.mk
5+
6+
show:
7+
cozypkg show -n $(NAMESPACE) $(NAME) --plain
8+
9+
apply:
10+
cozypkg show -n $(NAMESPACE) $(NAME) --plain | kubectl apply -f- --server-side --force-conflicts
11+
12+
diff:
13+
cozypkg show -n $(NAMESPACE) $(NAME) --plain | kubectl diff -f-
14+
15+
update:
16+
timoni bundle build -f flux-aio.cue > templates/fluxcd.yaml
17+
yq eval '(select(.kind == "Namespace") | .metadata.labels."pod-security.kubernetes.io/enforce") = "privileged"' -i templates/fluxcd.yaml
18+
sed -i templates/fluxcd.yaml \
19+
-e '/timoni/d' \
20+
-e 's|\.cluster\.local\.,||g' -e 's|\.cluster\.local\,||g' -e 's|\.cluster\.local\.||g' \
21+
-e '/value: .svc/a \ {{- include "cozy.kubernetes_envs" . | nindent 12 }}' \
22+
-e '/hostNetwork: true/i \ dnsPolicy: ClusterFirstWithHostNet'
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
bundle: {
2+
apiVersion: "v1alpha1"
3+
name: "flux-aio"
4+
instances: {
5+
"flux": {
6+
module: {
7+
url: "oci://ghcr.io/stefanprodan/modules/flux-aio"
8+
version: "latest"
9+
}
10+
namespace: "cozy-fluxcd"
11+
values: {
12+
securityProfile: "privileged"
13+
}
14+
}
15+
}
16+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{{- define "cozy.kubernetes_envs" }}
2+
{{- $cozyDeployment := lookup "apps/v1" "Deployment" "cozy-system" "cozystack" }}
3+
{{- $cozyContainers := dig "spec" "template" "spec" "containers" dict $cozyDeployment }}
4+
{{- range $cozyContainers }}
5+
{{- if eq .name "cozystack" }}
6+
{{- range .env }}
7+
{{- if has .name (list "KUBERNETES_SERVICE_HOST" "KUBERNETES_SERVICE_PORT") }}
8+
- {{ toJson . }}
9+
{{- end }}
10+
{{- end }}
11+
{{- end }}
12+
{{- end }}
13+
{{- end }}

‎packages/core/flux-aio/templates/fluxcd.yaml‎

Lines changed: 11957 additions & 0 deletions
Large diffs are not rendered by default.

‎packages/core/installer/images/cozystack/Dockerfile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ FROM alpine:3.22
3030

3131
RUN wget -O- https://github.com/cozystack/cozypkg/raw/refs/heads/main/hack/install.sh | sh -s -- -v 1.2.0
3232

33-
RUN apk add --no-cache make kubectl helm coreutils git jq
33+
RUN apk add --no-cache make kubectl helm coreutils git jq openssl
3434

3535
COPY --from=builder /src/scripts /cozystack/scripts
3636
COPY --from=builder /src/packages/core /cozystack/packages/core

‎packages/core/installer/templates/cozystack.yaml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ spec:
5454
env:
5555
- name: KUBERNETES_SERVICE_HOST
5656
value: localhost
57+
- name: INSTALL_FLUX
58+
value: "true"
5759
- name: KUBERNETES_SERVICE_PORT
5860
value: "7445"
5961
- name: K8S_AWAIT_ELECTION_ENABLED

‎packages/core/platform/bundles/distro-full.yaml‎

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,6 @@
22
{{- $clusterDomain := (index $cozyConfig.data "cluster-domain") | default "cozy.local" }}
33

44
releases:
5-
- name: fluxcd-operator
6-
releaseName: fluxcd-operator
7-
chart: cozy-fluxcd-operator
8-
namespace: cozy-fluxcd
9-
privileged: true
10-
dependsOn: []
11-
12-
- name: fluxcd
13-
releaseName: fluxcd
14-
chart: cozy-fluxcd
15-
namespace: cozy-fluxcd
16-
dependsOn: [fluxcd-operator,cilium]
17-
values:
18-
flux-instance:
19-
instance:
20-
cluster:
21-
domain: {{ $clusterDomain }}
22-
235
- name: cilium
246
releaseName: cilium
257
chart: cozy-cilium

‎packages/core/platform/bundles/distro-hosted.yaml‎

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,6 @@
22
{{- $clusterDomain := (index $cozyConfig.data "cluster-domain") | default "cozy.local" }}
33

44
releases:
5-
- name: fluxcd-operator
6-
releaseName: fluxcd-operator
7-
chart: cozy-fluxcd-operator
8-
namespace: cozy-fluxcd
9-
privileged: true
10-
dependsOn: []
11-
12-
- name: fluxcd
13-
releaseName: fluxcd
14-
chart: cozy-fluxcd
15-
namespace: cozy-fluxcd
16-
dependsOn: [fluxcd-operator]
17-
values:
18-
flux-instance:
19-
instance:
20-
cluster:
21-
domain: {{ $clusterDomain }}
22-
235
- name: cert-manager-crds
246
releaseName: cert-manager-crds
257
chart: cozy-cert-manager-crds

‎packages/core/platform/bundles/paas-full.yaml‎

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,6 @@
1111
{{- end }}
1212

1313
releases:
14-
- name: fluxcd-operator
15-
releaseName: fluxcd-operator
16-
chart: cozy-fluxcd-operator
17-
namespace: cozy-fluxcd
18-
privileged: true
19-
dependsOn: []
20-
21-
- name: fluxcd
22-
releaseName: fluxcd
23-
chart: cozy-fluxcd
24-
namespace: cozy-fluxcd
25-
dependsOn: [fluxcd-operator,cilium,kubeovn]
26-
values:
27-
flux-instance:
28-
instance:
29-
cluster:
30-
domain: {{ $clusterDomain }}
31-
3214
- name: cilium
3315
releaseName: cilium
3416
chart: cozy-cilium

0 commit comments

Comments
 (0)