mirror of
https://github.com/fluxcd/flux2.git
synced 2026-02-24 16:41:47 +00:00
Merge pull request #1332 from fluxcd/update-guide-v1alpha2
Update image automation guides to v1alpha2
This commit is contained in:
commit
e4d7450643
3 changed files with 67 additions and 83 deletions
|
|
@ -287,20 +287,24 @@ $ flux create image update my-app-auto \
|
||||||
--export > ./$AUTO_PATH/my-app-auto.yaml
|
--export > ./$AUTO_PATH/my-app-auto.yaml
|
||||||
$ cat my-app-auto.yaml
|
$ cat my-app-auto.yaml
|
||||||
---
|
---
|
||||||
apiVersion: image.toolkit.fluxcd.io/v1alpha1
|
apiVersion: image.toolkit.fluxcd.io/v1alpha2
|
||||||
kind: ImageUpdateAutomation
|
kind: ImageUpdateAutomation
|
||||||
metadata:
|
metadata:
|
||||||
name: my-app-auto
|
name: my-app-auto
|
||||||
namespace: flux-system
|
namespace: flux-system
|
||||||
spec:
|
spec:
|
||||||
checkout:
|
|
||||||
branch: main
|
|
||||||
gitRepositoryRef:
|
|
||||||
name: flux-system
|
|
||||||
commit:
|
|
||||||
authorEmail: fluxbot@example.com
|
|
||||||
authorName: FluxBot
|
|
||||||
interval: 5m0s
|
interval: 5m0s
|
||||||
|
sourceRef:
|
||||||
|
kind: GitRepository
|
||||||
|
name: flux-system
|
||||||
|
git:
|
||||||
|
checkout:
|
||||||
|
ref:
|
||||||
|
branch: main
|
||||||
|
commit:
|
||||||
|
author:
|
||||||
|
email: fluxbot@example.com
|
||||||
|
name: FluxBot
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Commit and check that the automation object works
|
#### Commit and check that the automation object works
|
||||||
|
|
@ -357,14 +361,8 @@ metadata:
|
||||||
annotations:
|
annotations:
|
||||||
fluxcd.io/automated: "true"
|
fluxcd.io/automated: "true"
|
||||||
fluxcd.io/tag.app: semver:^5.0
|
fluxcd.io/tag.app: semver:^5.0
|
||||||
selector:
|
|
||||||
matchLabels:
|
|
||||||
app: podinfo
|
|
||||||
spec:
|
spec:
|
||||||
template:
|
template:
|
||||||
metadata:
|
|
||||||
labels:
|
|
||||||
app: podinfo
|
|
||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: app
|
- name: app
|
||||||
|
|
@ -395,14 +393,8 @@ metadata:
|
||||||
annotations:
|
annotations:
|
||||||
fluxcd.io/automated: "true"
|
fluxcd.io/automated: "true"
|
||||||
fluxcd.io/tag.app: semver:^5.0
|
fluxcd.io/tag.app: semver:^5.0
|
||||||
selector:
|
|
||||||
matchLabels:
|
|
||||||
app: podinfo
|
|
||||||
spec:
|
spec:
|
||||||
template:
|
template:
|
||||||
metadata:
|
|
||||||
labels:
|
|
||||||
app: podinfo
|
|
||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: app
|
- name: app
|
||||||
|
|
@ -420,7 +412,7 @@ $ flux create image repository podinfo-image \
|
||||||
--export > ./$AUTO_PATH/podinfo-image.yaml
|
--export > ./$AUTO_PATH/podinfo-image.yaml
|
||||||
$ cat ./$AUTO_PATH/podinfo-image.yaml
|
$ cat ./$AUTO_PATH/podinfo-image.yaml
|
||||||
---
|
---
|
||||||
apiVersion: image.toolkit.fluxcd.io/v1alpha1
|
apiVersion: image.toolkit.fluxcd.io/v1alpha2
|
||||||
kind: ImageRepository
|
kind: ImageRepository
|
||||||
metadata:
|
metadata:
|
||||||
name: podinfo-image
|
name: podinfo-image
|
||||||
|
|
@ -525,7 +517,7 @@ Say you want to filter for only images that are from `main` branch, and pick the
|
||||||
`ImagePolicy` would look like this:
|
`ImagePolicy` would look like this:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
apiVersion: image.toolkit.fluxcd.io/v1alpha1
|
apiVersion: image.toolkit.fluxcd.io/v1alpha2
|
||||||
kind: ImagePolicy
|
kind: ImagePolicy
|
||||||
metadata:
|
metadata:
|
||||||
name: my-app-policy
|
name: my-app-policy
|
||||||
|
|
@ -569,7 +561,7 @@ example, you might put a target environment as well as the version in your image
|
||||||
Then you would use an `ImagePolicy` similar to this one:
|
Then you would use an `ImagePolicy` similar to this one:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
apiVersion: image.toolkit.fluxcd.io/v1alpha1
|
apiVersion: image.toolkit.fluxcd.io/v1alpha2
|
||||||
kind: ImagePolicy
|
kind: ImagePolicy
|
||||||
metadata:
|
metadata:
|
||||||
name: my-app-policy
|
name: my-app-policy
|
||||||
|
|
@ -600,7 +592,7 @@ $ flux create image policy my-app-policy \
|
||||||
--export > ./$AUTO_PATH/my-app-policy.yaml
|
--export > ./$AUTO_PATH/my-app-policy.yaml
|
||||||
$ cat ./$AUTO_PATH/my-app-policy.yaml
|
$ cat ./$AUTO_PATH/my-app-policy.yaml
|
||||||
---
|
---
|
||||||
apiVersion: image.toolkit.fluxcd.io/v1alpha1
|
apiVersion: image.toolkit.fluxcd.io/v1alpha2
|
||||||
kind: ImagePolicy
|
kind: ImagePolicy
|
||||||
metadata:
|
metadata:
|
||||||
name: my-app-policy
|
name: my-app-policy
|
||||||
|
|
@ -659,14 +651,8 @@ metadata:
|
||||||
annotations:
|
annotations:
|
||||||
fluxcd.io/automated: "true"
|
fluxcd.io/automated: "true"
|
||||||
fluxcd.io/tag.app: semver:^5.0 # <-- `.app` here
|
fluxcd.io/tag.app: semver:^5.0 # <-- `.app` here
|
||||||
selector:
|
|
||||||
matchLabels:
|
|
||||||
app: podinfo
|
|
||||||
spec:
|
spec:
|
||||||
template:
|
template:
|
||||||
metadata:
|
|
||||||
labels:
|
|
||||||
app: podinfo
|
|
||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: app # <-- targets `app` here
|
- name: app # <-- targets `app` here
|
||||||
|
|
@ -685,14 +671,8 @@ kind: Deployment
|
||||||
metadata:
|
metadata:
|
||||||
namespace: default
|
namespace: default
|
||||||
name: my-app
|
name: my-app
|
||||||
selector:
|
|
||||||
matchLabels:
|
|
||||||
app: podinfo
|
|
||||||
spec:
|
spec:
|
||||||
template:
|
template:
|
||||||
metadata:
|
|
||||||
labels:
|
|
||||||
app: podinfo
|
|
||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: app
|
- name: app
|
||||||
|
|
|
||||||
|
|
@ -138,7 +138,7 @@ flux create image repository podinfo \
|
||||||
The above command generates the following manifest:
|
The above command generates the following manifest:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
apiVersion: image.toolkit.fluxcd.io/v1alpha1
|
apiVersion: image.toolkit.fluxcd.io/v1alpha2
|
||||||
kind: ImageRepository
|
kind: ImageRepository
|
||||||
metadata:
|
metadata:
|
||||||
name: podinfo
|
name: podinfo
|
||||||
|
|
@ -177,7 +177,7 @@ flux create image policy podinfo \
|
||||||
The above command generates the following manifest:
|
The above command generates the following manifest:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
apiVersion: image.toolkit.fluxcd.io/v1alpha1
|
apiVersion: image.toolkit.fluxcd.io/v1alpha2
|
||||||
kind: ImagePolicy
|
kind: ImagePolicy
|
||||||
metadata:
|
metadata:
|
||||||
name: podinfo
|
name: podinfo
|
||||||
|
|
@ -258,23 +258,27 @@ flux create image update flux-system \
|
||||||
The above command generates the following manifest:
|
The above command generates the following manifest:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
apiVersion: image.toolkit.fluxcd.io/v1alpha1
|
apiVersion: image.toolkit.fluxcd.io/v1alpha2
|
||||||
kind: ImageUpdateAutomation
|
kind: ImageUpdateAutomation
|
||||||
metadata:
|
metadata:
|
||||||
name: flux-system
|
name: flux-system
|
||||||
namespace: flux-system
|
namespace: flux-system
|
||||||
spec:
|
spec:
|
||||||
checkout:
|
|
||||||
branch: main
|
|
||||||
gitRepositoryRef:
|
|
||||||
name: flux-system
|
|
||||||
commit:
|
|
||||||
authorEmail: fluxcdbot@users.noreply.github.com
|
|
||||||
authorName: fluxcdbot
|
|
||||||
messageTemplate: '{{range .Updated.Images}}{{println .}}{{end}}'
|
|
||||||
interval: 1m0s
|
interval: 1m0s
|
||||||
push:
|
sourceRef:
|
||||||
branch: main
|
kind: GitRepository
|
||||||
|
name: flux-system
|
||||||
|
git:
|
||||||
|
checkout:
|
||||||
|
ref:
|
||||||
|
branch: main
|
||||||
|
commit:
|
||||||
|
author:
|
||||||
|
email: fluxcdbot@users.noreply.github.com
|
||||||
|
name: fluxcdbot
|
||||||
|
messageTemplate: '{{range .Updated.Images}}{{println .}}{{end}}'
|
||||||
|
push:
|
||||||
|
branch: main
|
||||||
update:
|
update:
|
||||||
path: ./clusters/my-cluster
|
path: ./clusters/my-cluster
|
||||||
strategy: Setters
|
strategy: Setters
|
||||||
|
|
@ -387,21 +391,20 @@ images:
|
||||||
|
|
||||||
## Push updates to a different branch
|
## Push updates to a different branch
|
||||||
|
|
||||||
With `.spec.push.branch` you can configure Flux to push the image updates to different branch
|
With `.spec.git.push.branch` you can configure Flux to push the image updates to different branch
|
||||||
than the one used for checkout. If the specified branch doesn't exist, Flux will create it for you.
|
than the one used for checkout. If the specified branch doesn't exist, Flux will create it for you.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
apiVersion: image.toolkit.fluxcd.io/v1alpha1
|
|
||||||
kind: ImageUpdateAutomation
|
kind: ImageUpdateAutomation
|
||||||
metadata:
|
metadata:
|
||||||
name: flux-system
|
name: flux-system
|
||||||
spec:
|
spec:
|
||||||
checkout:
|
git:
|
||||||
branch: main
|
checkout:
|
||||||
gitRepositoryRef:
|
ref:
|
||||||
name: flux-system
|
branch: main
|
||||||
push:
|
push:
|
||||||
branch: image-updates
|
branch: flux-image-updates
|
||||||
```
|
```
|
||||||
|
|
||||||
You can use CI automation e.g. GitHub Actions such as
|
You can use CI automation e.g. GitHub Actions such as
|
||||||
|
|
@ -412,39 +415,40 @@ This way you can manually approve the image updates before they are applied on y
|
||||||
|
|
||||||
## Configure the commit message
|
## Configure the commit message
|
||||||
|
|
||||||
The `.spec.commit.messageTemplate` field is a string which is used as a template for the commit message.
|
The `.spec.git.commit.messageTemplate` field is a string which is used as a template for the commit message.
|
||||||
|
|
||||||
The message template is a [Go text template](https://golang.org/pkg/text/template/) that
|
The message template is a [Go text template](https://golang.org/pkg/text/template/) that
|
||||||
lets you range over the objects and images e.g.:
|
lets you range over the objects and images e.g.:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
apiVersion: image.toolkit.fluxcd.io/v1alpha1
|
|
||||||
kind: ImageUpdateAutomation
|
kind: ImageUpdateAutomation
|
||||||
metadata:
|
metadata:
|
||||||
name: flux-system
|
name: flux-system
|
||||||
spec:
|
spec:
|
||||||
commit:
|
git:
|
||||||
messageTemplate: |
|
commit:
|
||||||
Automated image update
|
messageTemplate: |
|
||||||
|
Automated image update
|
||||||
|
|
||||||
Automation name: {{ .AutomationObject }}
|
Automation name: {{ .AutomationObject }}
|
||||||
|
|
||||||
Files:
|
Files:
|
||||||
{{ range $filename, $_ := .Updated.Files -}}
|
{{ range $filename, $_ := .Updated.Files -}}
|
||||||
- {{ $filename }}
|
- {{ $filename }}
|
||||||
{{ end -}}
|
{{ end -}}
|
||||||
|
|
||||||
Objects:
|
Objects:
|
||||||
{{ range $resource, $_ := .Updated.Objects -}}
|
{{ range $resource, $_ := .Updated.Objects -}}
|
||||||
- {{ $resource.Kind }} {{ $resource.Name }}
|
- {{ $resource.Kind }} {{ $resource.Name }}
|
||||||
{{ end -}}
|
{{ end -}}
|
||||||
|
|
||||||
Images:
|
Images:
|
||||||
{{ range .Updated.Images -}}
|
{{ range .Updated.Images -}}
|
||||||
- {{.}}
|
- {{.}}
|
||||||
{{ end -}}
|
{{ end -}}
|
||||||
authorEmail: flux@example.com
|
author:
|
||||||
authorName: flux
|
email: fluxcdbot@users.noreply.github.com
|
||||||
|
name: fluxcdbot
|
||||||
```
|
```
|
||||||
|
|
||||||
## Trigger image updates with webhooks
|
## Trigger image updates with webhooks
|
||||||
|
|
@ -884,7 +888,7 @@ Create a directory in your control repository and save this `kustomization.yaml`
|
||||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
kind: Kustomization
|
kind: Kustomization
|
||||||
resources:
|
resources:
|
||||||
- git@github.com/fluxcd/flux2//manifests/integrations/registry-credentials-sync/azure
|
- https://github.com/fluxcd/flux2/manifests/integrations/registry-credentials-sync/azure?ref=main
|
||||||
patchesStrategicMerge:
|
patchesStrategicMerge:
|
||||||
- config-patches.yaml
|
- config-patches.yaml
|
||||||
```
|
```
|
||||||
|
|
|
||||||
|
|
@ -114,8 +114,8 @@ built from that branch.
|
||||||
Here is an example that filters for only images built from `main` branch, and selects the most
|
Here is an example that filters for only images built from `main` branch, and selects the most
|
||||||
recent according the timestamp (created with `date +%s`):
|
recent according the timestamp (created with `date +%s`):
|
||||||
|
|
||||||
```
|
```yaml
|
||||||
apiVersion: image.toolkit.fluxcd.io/v1alpha1
|
apiVersion: image.toolkit.fluxcd.io/v1alpha2
|
||||||
kind: ImagePolicy
|
kind: ImagePolicy
|
||||||
metadata:
|
metadata:
|
||||||
name: image-repo-policy
|
name: image-repo-policy
|
||||||
|
|
@ -133,8 +133,8 @@ spec:
|
||||||
|
|
||||||
If you don't care about the branch, that part can be a wildcard in the pattern:
|
If you don't care about the branch, that part can be a wildcard in the pattern:
|
||||||
|
|
||||||
```
|
```yaml
|
||||||
apiVersion: image.toolkit.fluxcd.io/v1alpha1
|
apiVersion: image.toolkit.fluxcd.io/v1alpha2
|
||||||
kind: ImagePolicy
|
kind: ImagePolicy
|
||||||
metadata:
|
metadata:
|
||||||
name: image-repo-policy
|
name: image-repo-policy
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue