Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: fluxcd/kustomize-controller
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.29.0
Choose a base ref
...
head repository: fluxcd/kustomize-controller
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v0.30.0
Choose a head ref

Commits on Oct 4, 2022

  1. support alternative kustomization file names

    `KustomizeGenerator.WriteFile` now detects alternative kustomization
    file names such as `kustomization.yml` and `Kustomization`.
    
    closes #737
    
    Signed-off-by: Max Jonas Werner <max@e13.dev>
    makkes committed Oct 4, 2022

    Verified

    This commit was signed with the committer’s verified signature.
    makkes Max Jonas Werner
    Copy the full SHA
    c3c4cc1 View commit details
  2. Merge pull request #738 from fluxcd/alternative-kustomization-files

    Support alternative kustomization file names
    makkes authored Oct 4, 2022

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    5c8aa7a View commit details

Commits on Oct 6, 2022

  1. Refactor: Extract decrytor to internal package

    Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
    stefanprodan committed Oct 6, 2022

    Verified

    This commit was signed with the committer’s verified signature.
    stefanprodan Stefan Prodan
    Copy the full SHA
    06ce60f View commit details

Commits on Oct 7, 2022

  1. Merge pull request #739 from fluxcd/refactor-decryptor

    Refactor: Extract decrytor to internal package
    stefanprodan authored Oct 7, 2022

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    99b2eae View commit details
  2. Refactor: Extract generator to internal package

    Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
    stefanprodan committed Oct 7, 2022

    Verified

    This commit was signed with the committer’s verified signature.
    stefanprodan Stefan Prodan
    Copy the full SHA
    731188e View commit details
  3. Merge pull request #740 from fluxcd/refactor-generator

    Refactor: Extract generator to internal package
    stefanprodan authored Oct 7, 2022

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    3086ae4 View commit details
  4. Refactor: Use impersonation from fluxcd/pkg/runtime/client

    Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
    stefanprodan committed Oct 7, 2022

    Verified

    This commit was signed with the committer’s verified signature.
    stefanprodan Stefan Prodan
    Copy the full SHA
    06e91e0 View commit details
  5. Merge pull request #742 from fluxcd/refactor-impersonation

    Refactor: Use impersonation from `fluxcd/pkg/runtime/client`
    stefanprodan authored Oct 7, 2022

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    ce46ec8 View commit details

Commits on Oct 10, 2022

  1. Refactor: Acquire artifacts with fluxcd/pkg/http/fetch

    Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
    stefanprodan committed Oct 10, 2022

    Verified

    This commit was signed with the committer’s verified signature.
    stefanprodan Stefan Prodan
    Copy the full SHA
    3090eff View commit details
  2. Merge pull request #743 from fluxcd/refactor-artifact-fetcher

    Refactor: Acquire artifacts with `fluxcd/pkg/http/fetch`
    stefanprodan authored Oct 10, 2022

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    cfe3539 View commit details

Commits on Oct 11, 2022

  1. Refactor: Move inventory helpers to internal package

    Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
    stefanprodan committed Oct 11, 2022

    Verified

    This commit was signed with the committer’s verified signature.
    stefanprodan Stefan Prodan
    Copy the full SHA
    484cbcc View commit details
  2. Merge pull request #744 from fluxcd/refactor-inventory

    Refactor: Move inventory helpers to internal package
    stefanprodan authored Oct 11, 2022

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    52be7c8 View commit details

Commits on Oct 14, 2022

  1. Refactor: Adopt Flux runtime conditions and status standards

    Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
    stefanprodan committed Oct 14, 2022

    Verified

    This commit was signed with the committer’s verified signature.
    stefanprodan Stefan Prodan
    Copy the full SHA
    7799bb0 View commit details
  2. Add kstatus conformance tests

    Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
    stefanprodan committed Oct 14, 2022

    Verified

    This commit was signed with the committer’s verified signature.
    stefanprodan Stefan Prodan
    Copy the full SHA
    1357acb View commit details
  3. Switch to serial patcher for status updates

    Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
    stefanprodan committed Oct 14, 2022

    Verified

    This commit was signed with the committer’s verified signature.
    stefanprodan Stefan Prodan
    Copy the full SHA
    933a8db View commit details
  4. Add ProgressingWithRetry reason to Reconciling condition

    ProgressingWithRetry signals that the controller is going to retry the last failed reconciliation at a later time.
    
    Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
    stefanprodan committed Oct 14, 2022

    Verified

    This commit was signed with the committer’s verified signature.
    stefanprodan Stefan Prodan
    Copy the full SHA
    3bbd729 View commit details

Commits on Oct 17, 2022

  1. Report each action in Reconciling condition

    Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
    stefanprodan committed Oct 17, 2022

    Verified

    This commit was signed with the committer’s verified signature.
    stefanprodan Stefan Prodan
    Copy the full SHA
    747a2c9 View commit details

Commits on Oct 18, 2022

  1. Add Reconciling status condition to API docs

    Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
    stefanprodan committed Oct 18, 2022

    Verified

    This commit was signed with the committer’s verified signature.
    stefanprodan Stefan Prodan
    Copy the full SHA
    2f81a39 View commit details
  2. Merge pull request #745 from fluxcd/status-refactoring

    Refactor: Adopt Flux runtime conditions and status standards
    stefanprodan authored Oct 18, 2022

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    0f131a0 View commit details

Commits on Oct 19, 2022

  1. Refactor: Remove docs which overlap with Flux website

    Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
    stefanprodan committed Oct 19, 2022

    Verified

    This commit was signed with the committer’s verified signature.
    stefanprodan Stefan Prodan
    Copy the full SHA
    3e935d0 View commit details
  2. Merge pull request #746 from fluxcd/refact-docs

    Refactor: Remove docs which overlap with Flux website
    stefanprodan authored Oct 19, 2022

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    0c7d631 View commit details
  3. Optimise memory usage of artifact operations

    - update fluxcd/pkg/tar to v0.2.0 (fluxcd/pkg#377)
    - update fluxcd/pkg/http/fetch to v0.2.0 (fluxcd/pkg#378)
    
    Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
    stefanprodan committed Oct 19, 2022

    Verified

    This commit was signed with the committer’s verified signature.
    stefanprodan Stefan Prodan
    Copy the full SHA
    5c30abc View commit details
  4. Merge pull request #747 from fluxcd/fetch-tar-mem

    Optimise the memory usage of artifact operations
    stefanprodan authored Oct 19, 2022

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    def45c5 View commit details

Commits on Oct 21, 2022

  1. api: allow configuration of h unit for timeouts

    To allow waiting for `HelmRelease` resources with an exceptionally
    high timeout of `1h` or more.
    
    Related to: fluxcd/helm-controller#549
    
    Signed-off-by: Hidde Beydals <hello@hidde.co>
    hiddeco committed Oct 21, 2022

    Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    4835ece View commit details
  2. Merge pull request #749 from fluxcd/api-widen-timeout-validation

    api: allow configuration of `h` unit for timeouts
    stefanprodan authored Oct 21, 2022

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    85c9728 View commit details
  3. Update dependencies

    - `k8s.io/*` v0.25.3
    - `aws-sdk-go-v2/service/kms` v1.18.13
    - `fluxcd/source-controller/api` v0.31.0
    - `fluxcd/image-reflector-controller/api` v0.22.1
    - `golang.org/x/text` v0.4.0 (fix CVE-2022-32149)
    
    Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
    stefanprodan committed Oct 21, 2022

    Verified

    This commit was signed with the committer’s verified signature.
    stefanprodan Stefan Prodan
    Copy the full SHA
    ecb5e3c View commit details
  4. Merge pull request #750 from fluxcd/kube-1.25.3

    Update dependencies
    stefanprodan authored Oct 21, 2022

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    4aec2a6 View commit details
  5. Release v0.30.0

    Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
    stefanprodan committed Oct 21, 2022

    Verified

    This commit was signed with the committer’s verified signature.
    stefanprodan Stefan Prodan
    Copy the full SHA
    acc533f View commit details
  6. Merge pull request #751 from fluxcd/release-v0.30.0

    Release v0.30.0
    stefanprodan authored Oct 21, 2022

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    4a391bd View commit details
Showing with 3,130 additions and 3,493 deletions.
  1. +36 −0 CHANGELOG.md
  2. +26 −304 README.md
  3. +5 −2 api/go.mod
  4. +16 −7 api/go.sum
  5. +0 −74 api/v1beta1/kustomization_types.go
  6. +4 −0 api/v1beta2/condition_types.go
  7. +2 −90 api/v1beta2/kustomization_types.go
  8. +1 −17 api/v1beta2/zz_generated.deepcopy.go
  9. +9 −7 config/crd/bases/kustomize.toolkit.fluxcd.io_kustomizations.yaml
  10. +2 −2 config/default/kustomization.yaml
  11. +1 −1 config/manager/kustomization.yaml
  12. +1 −1 controllers/kustomization_acl_test.go
  13. +389 −395 controllers/kustomization_controller.go
  14. +6 −1,576 controllers/kustomization_decryptor_test.go
  15. +1 −1 controllers/kustomization_dependson_test.go
  16. +0 −127 controllers/kustomization_fetcher.go
  17. +1 −1 controllers/kustomization_fetcher_test.go
  18. +19 −14 controllers/kustomization_force_test.go
  19. +1 −1 controllers/kustomization_fuzzer_test.go
  20. +0 −200 controllers/kustomization_impersonation.go
  21. +3 −4 controllers/kustomization_impersonation_test.go
  22. +1 −1 controllers/kustomization_inventory_test.go
  23. +17 −3 controllers/kustomization_prune_test.go
  24. +6 −6 controllers/kustomization_transformer_test.go
  25. +3 −3 controllers/kustomization_validation_test.go
  26. +2 −2 controllers/kustomization_varsub_test.go
  27. +107 −38 controllers/kustomization_wait_test.go
  28. +53 −104 controllers/suite_test.go
  29. +4 −46 docs/api/kustomize.md
  30. +15 −153 docs/spec/README.md
  31. +2 −0 docs/spec/v1beta2/README.md
  32. +92 −60 docs/spec/v1beta2/kustomization.md
  33. +39 −34 go.mod
  34. +81 −80 go.sum
  35. +21 −21 controllers/kustomization_decryptor.go → internal/decryptor/decryptor.go
  36. +1,600 −0 internal/decryptor/decryptor_test.go
  37. +3 −0 internal/decryptor/testdata/age.txt
  38. +117 −0 internal/decryptor/testdata/pgp.asc
  39. +75 −0 internal/generator/build.go
  40. +9 −9 controllers/kustomization_generator_test.go → internal/generator/build_test.go
  41. +24 −76 controllers/kustomization_generator.go → internal/generator/generator.go
  42. +95 −0 internal/generator/generator_test.go
  43. +4 −0 internal/generator/testdata/different-filenames/Kustomization/Kustomization
  44. +19 −0 internal/generator/testdata/different-filenames/Kustomization/deployment.yaml
  45. +19 −0 internal/generator/testdata/different-filenames/yaml/deployment.yaml
  46. +4 −0 internal/generator/testdata/different-filenames/yaml/kustomization.yaml
  47. +19 −0 internal/generator/testdata/different-filenames/yml/deployment.yaml
  48. +4 −0 internal/generator/testdata/different-filenames/yml/kustomization.yml
  49. 0 {controllers → internal/generator}/testdata/panic/kustomization.yaml
  50. 0 {controllers → internal/generator}/testdata/panic/secret.age.yaml
  51. 0 {controllers → internal/generator}/testdata/relbase/clusters/base/configmap.yaml
  52. 0 {controllers → internal/generator}/testdata/relbase/clusters/base/kustomization.yaml
  53. 0 {controllers → internal/generator}/testdata/relbase/clusters/patches.yaml
  54. 0 {controllers → internal/generator}/testdata/relbase/clusters/staging/flux-system/kustomization.yaml
  55. 0 {controllers → internal/generator}/testdata/relbase/clusters/staging/flux-system/secret.yaml
  56. 0 {controllers → internal/generator}/testdata/remote/kustomization.yaml
  57. +20 −4 controllers/kustomization_varsub.go → internal/generator/varsub.go
  58. +17 −15 controllers/kustomization_inventory.go → internal/inventory/inventory.go
  59. +93 −0 internal/inventory/inventory_test.go
  60. +12 −0 internal/inventory/testdata/inventory1.yaml
  61. +20 −0 internal/inventory/testdata/inventory2.yaml
  62. +10 −14 main.go
36 changes: 36 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -2,6 +2,42 @@

All notable changes to this project are documented in this file.

## 0.30.0

**Release date:** 2022-10-21

This prerelease comes with new status condition named `Reconciling` which improves
the observability for the actions performed by the controller during a reconciliation run.
The `Kustomization.status.conditions` have been aligned with Kubernetes
standard conditions and kstatus.

In addition, the controller memory usage was reduced by 90% when performing artifact
operations and can now better handle the reconciliation of large sources in-parallel.

Improvements:
- Optimise the memory usage of artifact operations
[#747](https://github.com/fluxcd/kustomize-controller/pull/747)
- Refactor: Adopt Flux runtime conditions and status standards
[#745](https://github.com/fluxcd/kustomize-controller/pull/745)
- Refactor: Remove docs which overlap with Flux website
[#746](https://github.com/fluxcd/kustomize-controller/pull/746)
- Refactor: Move inventory helpers to internal package
[#744](https://github.com/fluxcd/kustomize-controller/pull/744)
- Refactor: Acquire artifacts with `fluxcd/pkg/http/fetch`
[#743](https://github.com/fluxcd/kustomize-controller/pull/743)
- Refactor: Use impersonation from `fluxcd/pkg/runtime/client`
[#742](https://github.com/fluxcd/kustomize-controller/pull/742)
- Refactor: Extract generator to internal package
[#740](https://github.com/fluxcd/kustomize-controller/pull/740)
- Refactor: Extract decrytor to internal package
[#739](https://github.com/fluxcd/kustomize-controller/pull/739)
- Support alternative kustomization file names
[#738](https://github.com/fluxcd/kustomize-controller/pull/738)
- API: allow configuration of `h` unit for timeouts
[#749](https://github.com/fluxcd/kustomize-controller/pull/749)
- Update dependencies
[#750](https://github.com/fluxcd/kustomize-controller/pull/750)

## 0.29.0

**Release date:** 2022-09-29
330 changes: 26 additions & 304 deletions README.md
Original file line number Diff line number Diff line change
@@ -6,328 +6,50 @@
[![license](https://img.shields.io/github/license/fluxcd/kustomize-controller.svg)](https://github.com/fluxcd/kustomize-controller/blob/main/LICENSE)
[![release](https://img.shields.io/github/release/fluxcd/kustomize-controller/all.svg)](https://github.com/fluxcd/kustomize-controller/releases)

The kustomize-controller is a Kubernetes operator, specialized in running
continuous delivery pipelines for infrastructure and workloads
The kustomize-controller is a [Flux](https://github.com/fluxcd/flux2) component,
specialized in running continuous delivery pipelines for infrastructure and workloads
defined with Kubernetes manifests and assembled with Kustomize.

The cluster desired state is described through a Kubernetes Custom Resource named `Kustomization`.
Based on the creation, mutation or removal of a `Kustomization` resource in the cluster,
the controller performs actions to reconcile the cluster current state with the desired state.

![overview](docs/diagrams/kustomize-controller-overview.png)

Features:
## Features

* watches for `Kustomization` objects
* fetches artifacts produced by [source-controller](https://github.com/fluxcd/source-controller) from `Source` objects
* watches `Source` objects for revision changes
* generates the `kustomization.yaml` file if needed
* generates Kubernetes manifests with kustomize build
* decrypts Kubernetes secrets with Mozilla SOPS
* validates the build output with server-side apply dry-run
* applies the generated manifests on the cluster
* generates Kubernetes manifests with Kustomize SDK
* decrypts Kubernetes secrets with Mozilla SOPS and KMS
* validates the generated manifests with Kubernetes server-side apply dry-run
- detects drift between the desired and state and cluster state
- corrects drift by patching objects with Kubernetes server-side apply
* prunes the Kubernetes objects removed from source
* checks the health of the deployed workloads
* runs `Kustomizations` in a specific order, taking into account the depends-on relationship
* notifies whenever a `Kustomization` status changes

Specifications:
## Specifications

* [API](docs/spec/v1beta2/README.md)
* [Controller](docs/spec/README.md)

## Usage

The kustomize-controller is part of a composable [GitOps toolkit](https://fluxcd.io/flux/components/)
and depends on [source-controller](https://github.com/fluxcd/source-controller)
to acquire the Kubernetes manifests from Git repositories and S3 compatible storage buckets.

### Install the toolkit controllers

Download the flux CLI:

```bash
curl -s https://fluxcd.io/install.sh | sudo bash
```

Install the toolkit controllers in the `flux-system` namespace:

```bash
flux install
```

### Define a Git repository source

Create a source object that points to a Git repository containing Kubernetes and Kustomize manifests:

```yaml
apiVersion: source.toolkit.fluxcd.io/v1beta1
kind: GitRepository
metadata:
name: podinfo
namespace: flux-system
spec:
interval: 1m
url: https://github.com/stefanprodan/podinfo
ref:
branch: master
```
For private repositories, SSH or token based authentication can be
[configured with Kubernetes secrets](https://github.com/fluxcd/source-controller/blob/master/docs/spec/v1beta1/gitrepositories.md).
Save the above file and apply it on the cluster.
You can wait for the source controller to assemble an artifact from the head of the repo master branch with:
```bash
kubectl -n flux-system wait gitrepository/podinfo --for=condition=ready
```

The source controller will check for new commits in the master branch every minute. You can force a git sync with:

```bash
kubectl -n flux-system annotate --overwrite gitrepository/podinfo reconcile.fluxcd.io/requestedAt="$(date +%s)"
```

### Define a kustomization

Create a kustomization object that uses the git repository defined above:

```yaml
apiVersion: kustomize.toolkit.fluxcd.io/v1beta2
kind: Kustomization
metadata:
name: podinfo-dev
namespace: flux-system
spec:
interval: 5m
path: "./deploy/overlays/dev/"
prune: true
sourceRef:
kind: GitRepository
name: podinfo
healthChecks:
- kind: Deployment
name: frontend
namespace: dev
- kind: Deployment
name: backend
namespace: dev
timeout: 80s
```
> **Note** that if your repository contains only plain Kubernetes manifests, the controller will
> [automatically generate](docs/spec/v1beta1/kustomization.md#generate-kustomizationyaml)
> a kustomization.yaml file inside the specified path.
A detailed explanation of the Kustomization object and its fields
can be found in the [specification doc](docs/spec/v1beta1/README.md).
Based on the above definition, the kustomize-controller fetches the Git repository content from source-controller,
generates Kubernetes manifests by running kustomize build inside `./deploy/overlays/dev/`,
and validates them with a dry-run apply. If the manifests pass validation, the controller will apply them
on the cluster and starts the health assessment of the deployed workload. If the health checks are passing, the
Kustomization object status transitions to a ready state.

![workflow](docs/diagrams/kustomize-controller-flow.png)

You can wait for the kustomize controller to complete the deployment with:

```bash
kubectl -n flux-system wait kustomization/podinfo-dev --for=condition=ready
```

When the controller finishes the reconciliation, it will log the applied objects:

```bash
kubectl -n flux-system logs deploy/kustomize-controller | jq .
```

```json
{
"level": "info",
"ts": "2020-09-17T07:27:11.921Z",
"logger": "controllers.Kustomization",
"msg": "Kustomization applied in 1.436096591s",
"kustomization": "flux-system/podinfo-dev",
"output": {
"namespace/dev": "created",
"service/dev/frontend": "created",
"deployment/dev/frontend": "created",
"horizontalpodautoscaler/dev/frontend": "created",
"service/dev/backend": "created",
"deployment/dev/backend": "created",
"horizontalpodautoscaler/dev/backend": "created"
}
}
```

You can trigger a kustomization reconciliation any time with:

```bash
kubectl -n flux-system annotate --overwrite kustomization/podinfo-dev \
fluxcd.io/reconcileAt="$(date +%s)"
```

When the source controller pulls a new Git revision, the kustomize controller will detect that the
source revision changed, and will reconcile those changes right away.

If the kustomization reconciliation fails, the controller sets the ready condition to `false` and logs the error:

```yaml
status:
conditions:
- lastTransitionTime: "2020-09-17T07:27:58Z"
message: 'namespaces dev not found'
reason: ReconciliationFailed
status: "False"
type: Ready
```

```json
{
"kustomization": "flux-system/podinfo-dev",
"error": "Error when creating 'Service/dev/frontend': namespaces dev not found"
}
```

### Control the execution order

When running a kustomization, you may need to make sure other kustomizations have been
successfully applied beforehand. A kustomization can specify a list of dependencies with `spec.dependsOn`.
When combined with health assessment, a kustomization will run after all its dependencies health checks are passing.

For example, a service mesh proxy injector should be running before deploying applications inside the mesh:

```yaml
apiVersion: kustomize.toolkit.fluxcd.io/v1beta2
kind: Kustomization
metadata:
name: istio
namespace: flux-system
spec:
interval: 10m
path: "./istio/system/"
sourceRef:
kind: GitRepository
name: istio
healthChecks:
- kind: Deployment
name: istiod
namespace: istio-system
timeout: 2m
---
apiVersion: kustomize.toolkit.fluxcd.io/v1beta2
kind: Kustomization
metadata:
name: podinfo-dev
namespace: flux-system
spec:
dependsOn:
- name: istio
interval: 5m
path: "./deploy/overlays/dev/"
prune: true
sourceRef:
kind: GitRepository
name: podinfo
```

### Deploy releases to production

For production deployments, instead of synchronizing with a branch you can use a semver range to target stable releases:

```yaml
apiVersion: source.toolkit.fluxcd.io/v1beta1
kind: GitRepository
metadata:
name: podinfo-releases
namespace: flux-system
spec:
interval: 5m
url: https://github.com/stefanprodan/podinfo
ref:
semver: ">=4.0.0 <5.0.0"
```

With `ref.semver` we configure source controller to pull the Git tags and create an artifact from the most recent tag
that matches the semver range.

Create a production kustomization and reference the git source that follows the latest semver release:

```yaml
apiVersion: kustomize.toolkit.fluxcd.io/v1beta2
kind: Kustomization
metadata:
name: podinfo-production
namespace: flux-system
spec:
interval: 10m
path: "./deploy/overlays/production/"
sourceRef:
kind: GitRepository
name: podinfo-releases
```

Based on the above definition, the kustomize controller will apply the kustomization that matches the semver range
set in the Git repository.

### Configure alerting

The kustomize controller emits Kubernetes events whenever a kustomization status changes.

You can use the [notification-controller](https://github.com/fluxcd/notification-controller) to forward these events
to Slack, Microsoft Teams, Discord or Rocket chart.

Create a notification provider for Slack:

```yaml
apiVersion: notification.toolkit.fluxcd.io/v1beta1
kind: Provider
metadata:
name: slack
namespace: flux-system
spec:
type: slack
channel: alerts
secretRef:
name: slack-url
---
apiVersion: v1
kind: Secret
metadata:
name: slack-url
namespace: flux-system
data:
address: <encoded-url>
```

Create an alert for a list of GitRepositories and Kustomizations:

```yaml
apiVersion: notification.toolkit.fluxcd.io/v1beta1
kind: Alert
metadata:
name: on-call
namespace: flux-system
spec:
providerRef:
name: slack
eventSeverity: info
eventSources:
- kind: GitRepository
name: podinfo-releases
- kind: Kustomization
name: podinfo-production
```
## Guides

Multiple alerts can be used to send notifications to different channels or Slack organizations.
* [Get started with Flux](https://fluxcd.io/flux/get-started/)
* [Setup Notifications](https://fluxcd.io/flux/guides/notifications/)
* [Manage Kubernetes secrets with Flux and Mozilla SOPS](https://fluxcd.io/flux/guides/mozilla-sops/)
* [How to build, publish and consume OCI Artifacts with Flux](https://fluxcd.io/flux/cheatsheets/oci-artifacts/)
* [Flux and Kustomize FAQ](https://fluxcd.io/flux/faq/#kustomize-questions)

The event severity can be set to `info` or `error`.
When the severity is set to `error`, the controller will alert on any error encountered during the
reconciliation process. This includes kustomize build and validation errors, apply errors and
health check failures.
## Roadmap

![error alert](docs/diagrams/slack-error-alert.png)
The roadmap for the Flux family of projects can be found at <https://fluxcd.io/roadmap/>.

When the verbosity is set to `info`, the controller will alert if:
* a Kubernetes object was created, updated or deleted
* heath checks are passing
* a dependency is delaying the execution
* an error occurs
## Contributing

![info alert](docs/diagrams/slack-info-alert.png)
This project is Apache 2.0 licensed and accepts contributions via GitHub pull requests.
To start contributing please see the [development guide](DEVELOPMENT.md).
Loading