@@ -14,7 +14,7 @@ upgrade the Helm releases to their latest chart version based on semver ranges.
1414
1515## Prerequisites
1616
17- You will need a Kubernetes cluster version 1.28 or newer.
17+ You will need a Kubernetes cluster version 1.33 or newer.
1818For a quick local test, you can use [ Kubernetes kind] ( https://kind.sigs.k8s.io/docs/user/quick-start/ ) .
1919Any other Kubernetes setup will work as well though.
2020
@@ -122,7 +122,7 @@ spec:
122122 - host : podinfo.staging
123123` ` `
124124
125- Note that with ` version: ">=1.0.0-alpha"` we configure Flux to automatically upgrade
125+ Note that with ` version: ">=1.0.0-alpha"` we configure Flux to automatically upgrade
126126the `HelmRelease` to the latest chart version including alpha, beta and pre-releases.
127127
128128In **apps/production/** dir we have a Kustomize patch with the production specific values :
@@ -164,31 +164,41 @@ The infrastructure is structured into:
164164 └── kustomization.yaml
165165```
166166
167- In **infrastructure/controllers/** dir we have the Flux `HelmRepository` and `HelmRelease` definitions such as:
167+ In **infrastructure/controllers/** dir we have the Flux definitions such as:
168168
169169```yaml
170+ apiVersion: source.toolkit.fluxcd.io/v1
171+ kind: OCIRepository
172+ metadata:
173+ name: cert-manager
174+ namespace: cert-manager
175+ spec:
176+ interval: 24h
177+ url: oci://quay.io/jetstack/charts/cert-manager
178+ layerSelector:
179+ mediaType: "application/vnd.cncf.helm.chart.content.v1.tar+gzip"
180+ operation: copy
181+ ref:
182+ semver: "1.x"
183+ ---
170184apiVersion: helm.toolkit.fluxcd.io/v2
171185kind: HelmRelease
172186metadata:
173187 name: cert-manager
174188 namespace: cert-manager
175189spec:
176- interval: 30m
177- chart:
178- spec:
179- chart: cert-manager
180- version: "1.x"
181- sourceRef:
182- kind: HelmRepository
183- name: cert-manager
184- namespace: cert-manager
185- interval: 12h
190+ interval: 12h
191+ chartRef:
192+ kind: OCIRepository
193+ name: cert-manager
186194 values:
187- installCRDs: true
195+ crds:
196+ enabled: true
197+ keep: false
188198```
189199
190- Note that with ` interval: 12h ` we configure Flux to pull the Helm repository index every twelfth hours to check for updates .
191- If the new chart version that matches the ` 1.x ` semver range is found , Flux will upgrade the release.
200+ Note that in the ` OCIRepository ` we configure Flux to check for new chart versions every 24 hours.
201+ If a newer chart is found that matches the ` semver: 1.x` constraint , Flux will upgrade the release accordingly .
192202
193203In ** infrastructure/configs/** dir we have Kubernetes custom resources, such as the Let's Encrypt issuer:
194204
@@ -235,7 +245,7 @@ spec:
235245Note that with ` dependsOn` we tell Flux to first install or upgrade the controllers and only then the configs.
236246This ensures that the Kubernetes CRDs are registered on the cluster, before Flux applies any custom resources.
237247
238- # # Bootstrap staging and production
248+ # ## Clusters
239249
240250The clusters dir contains the Flux configuration :
241251
@@ -258,20 +268,24 @@ metadata:
258268 name: apps
259269 namespace: flux-system
260270spec:
261- interval: 10m0s
262271 dependsOn:
263272 - name: infra-configs
273+ interval: 1h
274+ retryInterval: 2m
275+ timeout: 5m
264276 sourceRef:
265- kind: GitRepository
266- name: flux-system
267- path: ./apps/ staging
277+ kind: ExternalArtifact
278+ name: apps
279+ path: ./staging
268280 prune: true
269281 wait: true
270282` ` `
271283
272- Note that with `path : ./apps/ staging` we configure Flux to sync the staging Kustomize overlay and
284+ Note that with `path : ./staging` we configure Flux to sync the apps staging Kustomize overlay and
273285with `dependsOn` we tell Flux to create the infrastructure items before deploying the apps.
274286
287+ # # Bootstrap staging and production
288+
275289Fork this repository on your personal GitHub account and export your GitHub access token, username and repo name :
276290
277291` ` ` sh
@@ -290,6 +304,7 @@ Set the kubectl context to your staging cluster and bootstrap Flux:
290304
291305` ` ` sh
292306flux bootstrap github \
307+ --components-extra=source-watcher \
293308 --context=staging \
294309 --owner=${GITHUB_USER} \
295310 --repository=${GITHUB_REPO} \
@@ -307,9 +322,9 @@ Watch for the Helm releases being installed on staging:
307322$ watch flux get helmreleases --all-namespaces
308323
309324NAMESPACE NAME REVISION SUSPENDED READY MESSAGE
310- cert-manager cert-manager v1.11.0 False True Release reconciliation succeeded
311- ingress-nginx ingress-nginx 4.4.2 False True Release reconciliation succeeded
312- podinfo podinfo 6.3.0 False True Release reconciliation succeeded
325+ cert-manager cert-manager 1.19.1 False True Helm install succeeded
326+ ingress-nginx ingress-nginx 4.13.4 False True Helm install succeeded
327+ podinfo podinfo 6.9.2 False True Helm install succeeded
313328` ` `
314329
315330Verify that the demo app can be accessed via ingress :
@@ -320,14 +335,15 @@ $ kubectl -n ingress-nginx port-forward svc/ingress-nginx-controller 8080:80 &
320335$ curl -H "Host: podinfo.staging" http://localhost:8080
321336{
322337 "hostname": "podinfo-59489db7b5-lmwpn",
323- "version": "6.2.3 "
338+ "version": "6.9.2 "
324339}
325340` ` `
326341
327342Bootstrap Flux on production by setting the context and path to your production cluster :
328343
329344` ` ` sh
330345flux bootstrap github \
346+ --components-extra=source-watcher \
331347 --context=production \
332348 --owner=${GITHUB_USER} \
333349 --repository=${GITHUB_REPO} \
@@ -341,11 +357,11 @@ Watch the production reconciliation:
341357` ` ` console
342358$ flux get kustomizations --watch
343359
344- NAME REVISION SUSPENDED READY MESSAGE
345- apps main/696182e False True Applied revision: main/696182e
346- flux-system main/696182e False True Applied revision: main/696182e
347- infra-configs main/696182e False True Applied revision: main/696182e
348- infra-controllers main/696182e False True Applied revision: main/696182e
360+ NAME REVISION READY MESSAGE
361+ flux-system main@sha1:a7be7dff True Applied revision: main@sha1:a7be7dff
362+ infra-controllers latest@sha256:c0ac3648 True Applied revision: latest@sha256:c0ac3648
363+ infra-configs latest@sha256:c0ac3648 True Applied revision: latest@sha256:c0ac3648
364+ apps latest@sha256:26785ee4 True Applied revision: latest@sha256:26785ee4
349365` ` `
350366
351367# # Add clusters
@@ -366,6 +382,7 @@ mkdir -p clusters/dev
366382Copy the sync manifests from staging :
367383
368384` ` ` sh
385+ cp clusters/staging/artifacts.yaml clusters/dev
369386cp clusters/staging/infrastructure.yaml clusters/dev
370387cp clusters/staging/apps.yaml clusters/dev
371388` ` `
@@ -383,6 +400,7 @@ Set the kubectl context and path to your dev cluster and bootstrap Flux:
383400
384401` ` ` sh
385402flux bootstrap github \
403+ --components-extra=source-watcher \
386404 --context=dev \
387405 --owner=${GITHUB_USER} \
388406 --repository=${GITHUB_REPO} \
@@ -391,57 +409,6 @@ flux bootstrap github \
391409 --path=clusters/dev
392410` ` `
393411
394- # # Identical environments
395-
396- If you want to spin up an identical environment, you can bootstrap a cluster
397- e.g. `production-clone` and reuse the `production` definitions.
398-
399- Bootstrap the `production-clone` cluster :
400-
401- ` ` ` sh
402- flux bootstrap github \
403- --context=production-clone \
404- --owner=${GITHUB_USER} \
405- --repository=${GITHUB_REPO} \
406- --branch=main \
407- --personal \
408- --path=clusters/production-clone
409- ` ` `
410-
411- Pull the changes locally :
412-
413- ` ` ` sh
414- git pull origin main
415- ` ` `
416-
417- Create a `kustomization.yaml` inside the `clusters/production-clone` dir :
418-
419- ` ` ` yaml
420- apiVersion: kustomize.config.k8s.io/v1beta1
421- kind: Kustomization
422- resources:
423- - flux-system
424- - ../production/infrastructure.yaml
425- - ../production/apps.yaml
426- ` ` `
427-
428- Note that besides the `flux-system` kustomize overlay, we also include
429- the `infrastructure` and `apps` manifests from the production dir.
430-
431- Push the changes to the main branch :
432-
433- ` ` ` sh
434- git add -A && git commit -m "add production clone" && git push
435- ` ` `
436-
437- Tell Flux to deploy the production workloads on the `production-clone` cluster :
438-
439- ` ` ` sh
440- flux reconcile kustomization flux-system \
441- --context=production-clone \
442- --with-source
443- ` ` `
444-
445412# # Testing
446413
447414Any change to the Kubernetes manifests or to the repository structure should be validated in CI before
0 commit comments