Skip to content

Commit 18a3325

Browse files
authored
Merge pull request fluxcd#2234 from fluxcd/oci-ga
Update OCIRepository examples to v1 (GA)
2 parents 2999296 + dcb9231 commit 18a3325

File tree

3 files changed

+93
-100
lines changed

3 files changed

+93
-100
lines changed

content/en/flux/cheatsheets/oci-artifacts.md

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ and publish the resulting manifests as OCI artifacts for Flux to consume.
2323
### Authoring artifacts
2424

2525
On the client-side, the Flux CLI offers commands for packaging Kubernetes configs into OCI artifacts and
26-
pushing these artifact to container registries.
26+
pushing these artifacts to container registries.
2727

2828
The Flux CLI commands for managing OCI artifacts are:
2929
- `flux push artifact`
@@ -62,7 +62,7 @@ and you can apply the OCI artifact content on the cluster (Flux `Kustomization`)
6262
Example:
6363

6464
```yaml
65-
apiVersion: source.toolkit.fluxcd.io/v1beta2
65+
apiVersion: source.toolkit.fluxcd.io/v1
6666
kind: OCIRepository
6767
metadata:
6868
name: podinfo
@@ -96,13 +96,16 @@ defining Helm releases with charts stored in container registries.
9696
Example:
9797
9898
```yaml
99-
apiVersion: source.toolkit.fluxcd.io/v1beta2
99+
apiVersion: source.toolkit.fluxcd.io/v1
100100
kind: OCIRepository
101101
metadata:
102102
name: podinfo
103103
namespace: default
104104
spec:
105105
interval: 10m
106+
layerSelector:
107+
mediaType: "application/vnd.cncf.helm.chart.content.v1.tar+gzip"
108+
operation: copy
106109
url: oci://ghcr.io/stefanprodan/charts/podinfo
107110
ref:
108111
semver: ">=6.5.0"
@@ -192,7 +195,7 @@ The output is similar to:
192195
Pull the latest build on the staging cluster:
193196

194197
```yaml
195-
apiVersion: source.toolkit.fluxcd.io/v1beta2
198+
apiVersion: source.toolkit.fluxcd.io/v1
196199
kind: OCIRepository
197200
metadata:
198201
name: podinfo
@@ -255,7 +258,7 @@ flux tag artifact oci://ghcr.io/stefanprodan/manifests/podinfo:$(git tag --point
255258
Deploy the latest stable build on the production cluster:
256259

257260
```yaml
258-
apiVersion: source.toolkit.fluxcd.io/v1beta2
261+
apiVersion: source.toolkit.fluxcd.io/v1
259262
kind: OCIRepository
260263
metadata:
261264
name: podinfo
@@ -270,7 +273,7 @@ spec:
270273
Or deploy the latest version by semver:
271274

272275
```yaml
273-
apiVersion: source.toolkit.fluxcd.io/v1beta2
276+
apiVersion: source.toolkit.fluxcd.io/v1
274277
kind: OCIRepository
275278
metadata:
276279
name: podinfo
@@ -312,7 +315,7 @@ flux create secret oci ghcr-auth \
312315
Then reference the secret in the `OCIRepository` with:
313316

314317
```yaml
315-
apiVersion: source.toolkit.fluxcd.io/v1beta2
318+
apiVersion: source.toolkit.fluxcd.io/v1
316319
kind: OCIRepository
317320
metadata:
318321
name: podinfo
@@ -370,7 +373,7 @@ cosign sign --key=cosign.key ghcr.io/stefanprodan/manifests/podinfo:$(git tag --
370373
Configure Flux to verify the artifacts using the Cosign public key from the Kubernetes secret:
371374

372375
```yaml
373-
apiVersion: source.toolkit.fluxcd.io/v1beta2
376+
apiVersion: source.toolkit.fluxcd.io/v1
374377
kind: OCIRepository
375378
metadata:
376379
name: podinfo
@@ -495,7 +498,7 @@ flux create secret notation notation-cfg \
495498
Configure Flux to verify the artifacts using the Notary trust policy and certificate:
496499

497500
```yaml
498-
apiVersion: source.toolkit.fluxcd.io/v1beta2
501+
apiVersion: source.toolkit.fluxcd.io/v1
499502
kind: OCIRepository
500503
metadata:
501504
name: app-manifests
@@ -726,7 +729,7 @@ spec:
726729
Then add the policy marker to the `OCIRepository` manifest in Git:
727730

728731
```yaml
729-
apiVersion: source.toolkit.fluxcd.io/v1beta2
732+
apiVersion: source.toolkit.fluxcd.io/v1
730733
kind: OCIRepository
731734
metadata:
732735
name: podinfo
@@ -766,32 +769,30 @@ spec:
766769
name: podinfo-chart
767770
policy:
768771
semver:
769-
range: 6.1.x
772+
range: 6.x
770773
```
771774

772-
Then add the policy marker to the `HelmRelease` manifest in Git:
775+
Then add the policy marker to the `OCIRepositry` manifest in Git:
773776

774777
```yaml
775-
apiVersion: helm.toolkit.fluxcd.io/v2
776-
kind: HelmRelease
778+
apiVersion: source.toolkit.fluxcd.io/v1
779+
kind: OCIRepository
777780
metadata:
778781
name: podinfo
779-
namespace: flux-system
782+
namespace: default
780783
spec:
781784
interval: 10m
782-
targetNamespace: default
783-
chart:
784-
spec:
785-
chart: podinfo
786-
version: 6.1.0 # {"$imagepolicy": "flux-system:podinfo-chart:tag"}
787-
sourceRef:
788-
kind: HelmRepository
789-
name: podinfo
785+
layerSelector:
786+
mediaType: "application/vnd.cncf.helm.chart.content.v1.tar+gzip"
787+
operation: copy
788+
url: oci://ghcr.io/stefanprodan/charts/podinfo
789+
ref:
790+
tag: 6.5.0 # {"$imagepolicy": "flux-system:podinfo-chart:tag"}
790791
```
791792

792793
Based on the above configuration, Flux will scan the container registry every five minutes,
793794
and when it finds a newer Helm chart version, it will update the
794-
`HelmRelease.spec.chart.spec.chart.version` and will push the change to Git.
795+
`OCIRepository.spec.ref.tag` and will push the change to Git.
795796

796797
### Diagram: OCI artifacts reconciliation
797798

content/en/flux/faq.md

Lines changed: 67 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -240,57 +240,50 @@ For security and performance reasons, it is advised to disallow the usage of
240240
[remote bases](https://github.com/kubernetes-sigs/kustomize/blob/a7f4db7fb41e17b2c826a524f545e6174b4dc6ac/examples/remoteBuild.md)
241241
in Kustomize overlays. To enforce this setting, platform admins can set the `--no-remote-bases=true` flag for kustomize-controller.
242242

243-
**Note:** This flag prevents the usage of remote bases only, i.e. a Git repository or a sub directory.
244-
It does not affect the usage of remote targets pointing to a single file.
245-
246243
When using remote bases, the manifests are fetched over HTTPS from their remote source on every reconciliation e.g.:
247244

248245
```yaml
249-
# infra/kyverno/kustomization.yaml
246+
# apps/podinfo/kustomization.yaml
250247
apiVersion: kustomize.config.k8s.io/v1beta1
251248
kind: Kustomization
252249
resources:
253-
- https://github.com/stefanprodan/podinfo/deploy/overlays/dev?ref=master
250+
- https://github.com/stefanprodan/podinfo/kustomize?ref=master
254251
```
255252

256253
To take advantage of Flux's verification and caching features,
257254
you can replace the `kustomization.yaml` with a Flux source definition:
258255

259256
```yaml
260-
apiVersion: source.toolkit.fluxcd.io/v1beta2
257+
apiVersion: source.toolkit.fluxcd.io/v1
261258
kind: OCIRepository
262259
metadata:
263-
name: kyverno
264-
namespace: flux-system
260+
name: podinfo
261+
namespace: apps
265262
spec:
266263
interval: 60m
267-
url: oci://ghcr.io/kyverno/manifests/kyverno
268-
ref: # pull the latest patch release evey hour
269-
semver: 1.8.x
270-
verify: # enable Cosign keyless verification
271-
provider: cosign
264+
url: oci://ghcr.io/stefanprodan/manifests/podinfo
265+
ref: # pull the latest stable version every hour
266+
semver: ">=1.0.0"
272267
```
273268

274-
Then to reconcile the manifests on a cluster, you'll use the ones from the verified source:
269+
Then, to reconcile the manifests on a cluster, you'll use the ones from the Flux source:
275270

276271
```yaml
277272
apiVersion: kustomize.toolkit.fluxcd.io/v1
278273
kind: Kustomization
279274
metadata:
280-
name: kyverno
281-
namespace: flux-system
275+
name: podinfo
276+
namespace: apps
282277
spec:
283-
interval: 360m
278+
interval: 60m
279+
retryInterval: 5m
284280
prune: true
285281
wait: true
286-
timeout: 5m
282+
timeout: 3m
287283
sourceRef:
288284
kind: OCIRepository
289-
name: kyverno
290-
path: ./
291-
kubeConfig:
292-
secretRef:
293-
name: staging-cluster
285+
name: podinfo
286+
path: ./kustomize
294287
```
295288

296289
### Should I be using Kustomize Helm chart plugin?
@@ -301,58 +294,53 @@ Kustomize plugins which shell-out to arbitrary binaries insides the kustomize-co
301294
Instead of using Kustomize to deploy charts, e.g.:
302295

303296
```yaml
304-
# infra/kyverno/kustomization.yaml
297+
# infra/metrics-server/kustomization.yaml
305298
apiVersion: kustomize.config.k8s.io/v1beta1
306299
kind: Kustomization
307-
namespace: kyverno
300+
namespace: monitoring
308301
resources:
309-
- kyverno-namespace.yaml
302+
- monitoring-namespace.yaml
310303
helmCharts:
311-
- name: kyverno
304+
- name: metrics-server
312305
valuesInline:
313-
networkPolicy:
314-
enabled: true
315-
releaseName: kyverno
316-
version: 2.6.0
317-
repo: https://kyverno.github.io/kyverno/
306+
args:
307+
- --kubelet-insecure-tls
308+
releaseName: metrics-server
309+
version: 3.12.0
310+
repo: https://kubernetes-sigs.github.io/metrics-server/
318311
```
319312

320313
You can take advantage of Flux's OCI and native Helm features,
321314
by replacing the `kustomization.yaml` with a Flux Helm definition:
322315

323316
```yaml
324317
apiVersion: source.toolkit.fluxcd.io/v1
325-
kind: HelmRepository
318+
kind: OCIRepository
326319
metadata:
327-
name: kyverno
328-
namespace: flux-system
320+
name: metrics-server
321+
namespace: monitoring
329322
spec:
330-
interval: 6h
331-
url: oci://ghcr.io/kyverno/charts
332-
type: oci
323+
interval: 1h
324+
layerSelector:
325+
mediaType: "application/vnd.cncf.helm.chart.content.v1.tar+gzip"
326+
operation: copy
327+
url: oci://ghcr.io/controlplaneio-fluxcd/charts/metrics-server
328+
ref:
329+
semver: "3.x" # auto upgrade to the latest minor version
333330
---
334331
apiVersion: helm.toolkit.fluxcd.io/v2
335332
kind: HelmRelease
336333
metadata:
337-
name: kyverno
338-
namespace: flux-system
334+
name: metrics-server
335+
namespace: monitoring
339336
spec:
340-
interval: 6h
341-
releaseName: kyverno
342-
targetNamespace: kyverno
343-
install:
344-
createNamespace: true
345-
chart:
346-
spec:
347-
chart: kyverno
348-
version: 2.6.0
349-
interval: 6h
350-
sourceRef:
351-
kind: HelmRepository
352-
name: kyverno
337+
interval: 1h
338+
chartRef:
339+
kind: OCIRepository
340+
name: metrics-server
353341
values:
354-
networkPolicy:
355-
enabled: true
342+
args:
343+
- --kubelet-insecure-tls
356344
```
357345

358346
### What is the behavior of Kustomize used by Flux?
@@ -442,38 +430,42 @@ Create a Helm release with `kubectl`:
442430
cat << EOF | kubectl apply -f -
443431
---
444432
apiVersion: source.toolkit.fluxcd.io/v1
445-
kind: HelmRepository
433+
kind: OCIRepository
446434
metadata:
447-
name: bitnami
448-
namespace: flux-system
435+
name: kube-prometheus-stack
436+
namespace: monitoring
449437
spec:
450-
interval: 30m
451-
url: https://charts.bitnami.com/bitnami
438+
interval: 1h
439+
layerSelector:
440+
mediaType: "application/vnd.cncf.helm.chart.content.v1.tar+gzip"
441+
operation: copy
442+
url: oci://ghcr.io/prometheus-community/charts/kube-prometheus-stack
443+
ref:
444+
semver: "72.x"
452445
---
453446
apiVersion: helm.toolkit.fluxcd.io/v2
454447
kind: HelmRelease
455448
metadata:
456-
name: metrics-server
457-
namespace: kube-system
449+
name: kube-prometheus-stack
450+
namespace: monitoring
458451
spec:
459-
interval: 60m
460-
releaseName: metrics-server
461-
chart:
462-
spec:
463-
chart: metrics-server
464-
version: "^5.x"
465-
sourceRef:
466-
kind: HelmRepository
467-
name: bitnami
468-
namespace: flux-system
452+
interval: 1h
453+
timeout: 10m
454+
chartRef:
455+
kind: OCIRepository
456+
name: kube-prometheus-stack
457+
install:
458+
crds: Create
459+
upgrade:
460+
crds: CreateReplace
469461
values:
470-
apiService:
471-
create: true
462+
alertmanager:
463+
enabled: false
472464
EOF
473465
```
474466

475467
Based on the above definition, Flux will upgrade the release automatically
476-
when Bitnami publishes a new version of the metrics-server chart.
468+
when a new minor or patch version is available for the kube-prometheus-stack chart.
477469

478470
### How do I set local overrides to a Helm chart?
479471

content/en/flux/guides/helmreleases.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ A better option is to use an [OCI registry for chart storage](#oci-repository).
164164
Helm charts stored in an OCI registry, can be retrieved by declaring an `OCIRepository`.
165165

166166
```yaml
167-
apiVersion: source.toolkit.fluxcd.io/v1beta2
167+
apiVersion: source.toolkit.fluxcd.io/v1
168168
kind: OCIRepository
169169
metadata:
170170
name: podinfo

0 commit comments

Comments
 (0)