Skip to content

Commit d44681b

Browse files
committed
Refactor fluxcd 2.3 update
Signed-off-by: Andrei Kvapil <[email protected]>
1 parent 931e39f commit d44681b

11 files changed

Lines changed: 124 additions & 76 deletions

File tree

‎packages/core/fluxcd/Makefile‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@ show:
77
helm template -n $(NAMESPACE) $(NAME) . --no-hooks --dry-run=server $(API_VERSIONS_FLAGS)
88

99
apply:
10-
helm template -n $(NAMESPACE) $(NAME) . --no-hooks -f valuesFile.yaml -f flux-customizations.yaml \
10+
helm template -n $(NAMESPACE) $(NAME) . --no-hooks \
1111
--dry-run=server $(API_VERSIONS_FLAGS) | kubectl apply -n $(NAMESPACE) -f-
1212

1313
diff:
14-
helm template -n $(NAMESPACE) $(NAME) . --no-hooks -f valuesFile.yaml -f flux-customizations.yaml \
14+
helm template -n $(NAMESPACE) $(NAME) . --no-hooks \
1515
--dry-run=server $(API_VERSIONS_FLAGS) | kubectl diff -n $(NAMESPACE) -f-
1616

1717
update:
1818
rm -rf charts
1919
helm pull oci://ghcr.io/controlplaneio-fluxcd/charts/flux-operator --untar --untardir charts
20+
patch -p1 --no-backup-if-mismatch < patches/hostNetwork.diff
21+
patch -p1 --no-backup-if-mismatch < patches/kubernetesEnvs.diff

‎packages/core/fluxcd/charts/flux-operator/templates/deployment.yaml‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,7 @@ spec:
5858
- name: MARKETPLACE_LICENSE
5959
value: {{ . }}
6060
{{- end }}
61-
{{- if .Values.extraEnvs }}
62-
{{- toYaml .Values.extraEnvs | nindent 12 }}
63-
{{- end }}
61+
{{- include "cozy.kubernetes_envs" . | nindent 12 }}
6462
securityContext:
6563
{{- toYaml .Values.securityContext | nindent 12 }}
6664
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"

‎packages/core/fluxcd/charts/flux-operator/values.schema.json‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,6 @@
7171
"properties": {},
7272
"type": "object"
7373
},
74-
"extraEnvs": {
75-
"items": {
76-
"type": "object"
77-
},
78-
"type": "array",
79-
"uniqueItems": true
80-
},
8174
"fullnameOverride": {
8275
"type": "string"
8376
},

‎packages/core/fluxcd/charts/flux-operator/values.yaml‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,3 @@ marketplace:
9090

9191
# -- If `true`, start flux-operator in hostNetwork mode.
9292
hostNetwork: false
93-
94-
# -- Add environment variables eg. for kubeprism KUBERNETES_SERVICE_HOST and _PORT
95-
extraEnvs: [ ]

‎packages/core/fluxcd/flux-customizations.yaml‎

Lines changed: 0 additions & 35 deletions
This file was deleted.
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
diff --git a/charts/flux-operator/README.md b/charts/flux-operator/README.md
2+
index 071e024..2fccc5f 100644
3+
--- a/charts/flux-operator/README.md
4+
+++ b/charts/flux-operator/README.md
5+
@@ -36,6 +36,7 @@ see the Flux Operator [documentation](https://fluxcd.control-plane.io/operator/)
6+
| commonAnnotations | object | `{}` | Common annotations to add to all deployed objects including pods. |
7+
| commonLabels | object | `{}` | Common labels to add to all deployed objects including pods. |
8+
| fullnameOverride | string | `""` | |
9+
+| hostNetwork | bool | `false` | If `true`, start flux-operator in hostNetwork mode. |
10+
| image | object | `{"pullSecrets":[],"repository":"ghcr.io/controlplaneio-fluxcd/flux-operator","tag":""}` | Container image settings. The image tag defaults to the chart appVersion. |
11+
| installCRDs | bool | `true` | Install and upgrade the custom resource definitions. |
12+
| livenessProbe | object | `{"httpGet":{"path":"/healthz","port":8081},"initialDelaySeconds":15,"periodSeconds":20}` | Container liveness probe settings. |
13+
diff --git a/charts/flux-operator/templates/deployment.yaml b/charts/flux-operator/templates/deployment.yaml
14+
index 2d75821..8ffd8d8 100644
15+
--- a/charts/flux-operator/templates/deployment.yaml
16+
+++ b/charts/flux-operator/templates/deployment.yaml
17+
@@ -40,6 +40,9 @@ spec:
18+
securityContext:
19+
{{- toYaml . | nindent 8 }}
20+
{{- end }}
21+
+ {{- if .Values.hostNetwork }}
22+
+ hostNetwork: true
23+
+ {{- end }}
24+
containers:
25+
- name: manager
26+
env:
27+
diff --git a/charts/flux-operator/values.schema.json b/charts/flux-operator/values.schema.json
28+
index 85e4d02..64270a7 100644
29+
--- a/charts/flux-operator/values.schema.json
30+
+++ b/charts/flux-operator/values.schema.json
31+
@@ -74,6 +74,10 @@
32+
"fullnameOverride": {
33+
"type": "string"
34+
},
35+
+ "hostNetwork": {
36+
+ "default": false,
37+
+ "type": "boolean"
38+
+ },
39+
"image": {
40+
"properties": {
41+
"pullSecrets": {
42+
diff --git a/charts/flux-operator/values.yaml b/charts/flux-operator/values.yaml
43+
index 59b8a23..7ecefc0 100644
44+
--- a/charts/flux-operator/values.yaml
45+
+++ b/charts/flux-operator/values.yaml
46+
@@ -87,3 +87,6 @@ tolerations: [ ] # @schema item: object ; uniqueItems: true
47+
marketplace:
48+
license: ""
49+
account: ""
50+
+
51+
+# -- If `true`, start flux-operator in hostNetwork mode.
52+
+hostNetwork: false
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
diff --git a/packages/core/fluxcd/charts/flux-operator/templates/deployment.yaml b/packages/core/fluxcd/charts/flux-operator/templates/deployment.yaml
2+
index 8ffd8d8..5ad96a8 100644
3+
--- a/charts/flux-operator/templates/deployment.yaml
4+
+++ b/charts/flux-operator/templates/deployment.yaml
5+
@@ -58,6 +58,7 @@ spec:
6+
- name: MARKETPLACE_LICENSE
7+
value: {{ . }}
8+
{{- end }}
9+
+ {{- include "cozy.kubernetes_envs" . | nindent 12 }}
10+
securityContext:
11+
{{- toYaml .Values.securityContext | nindent 12 }}
12+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
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/fluxcd/values.yaml‎

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
flux-operator:
2+
tolerations:
3+
- key: node.kubernetes.io/not-ready
4+
operator: Exists
5+
effect: NoSchedule
6+
hostNetwork: true
7+
18
fluxInstance:
29
# cluster:
310
# domain: cozy.local
@@ -10,4 +17,38 @@ fluxInstance:
1017
- helm-controller
1118
- notification-controller
1219
- image-reflector-controller
13-
- image-automation-controller
20+
- image-automation-controller
21+
kustomize:
22+
patches:
23+
- target:
24+
kind: Deployment
25+
name: "(kustomize-controller|helm-controller|source-controller)"
26+
patch: |
27+
- op: add
28+
path: /spec/template/spec/containers/0/args/-
29+
value: --concurrent=20
30+
- op: add
31+
path: /spec/template/spec/containers/0/args/-
32+
value: --requeue-dependency=5s
33+
- op: replace
34+
path: /spec/template/spec/containers/0/resources/limits
35+
value:
36+
cpu: 2000m
37+
memory: 2048Mi
38+
- target:
39+
kind: Deployment
40+
name: source-controller
41+
patch: |
42+
- op: add
43+
path: /spec/template/spec/containers/0/args/-
44+
value: --storage-adv-addr=source-controller.cozy-fluxcd.svc
45+
- op: add
46+
path: /spec/template/spec/containers/0/args/-
47+
value: --events-addr=http://notification-controller.cozy-fluxcd.svc/
48+
- target:
49+
kind: Deployment
50+
name: (kustomize-controller|helm-controller|image-reflector-controller|image-automation-controller)
51+
patch: |
52+
- op: add
53+
path: /spec/template/spec/containers/0/args/-
54+
value: --events-addr=http://notification-controller.cozy-fluxcd.svc/

‎packages/core/fluxcd/valuesFile.yaml‎

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)