Skip to content

Commit 75f659d

Browse files
committed
Add example to controller spec
1 parent 51f0794 commit 75f659d

File tree

2 files changed

+129
-2
lines changed

2 files changed

+129
-2
lines changed

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,6 @@ set in the Git repository manifest.
260260

261261
The kustomize controller can post message to Slack or Discord whenever a kustomization status changes.
262262

263-
![pipeline](docs/diagrams/kustomize-controller-pipeline.png)
264-
265263
Alerting can be configured by creating a profile that targets a list of kustomizations:
266264

267265
```yaml

docs/spec/README.md

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ that describes a pipeline such as:
3939
- **alert** if something went wrong
4040
- **notify** if the cluster state changed
4141

42+
![pipeline](../diagrams/kustomize-controller-pipeline.png)
43+
4244
The controller the runs these pipelines relies on
4345
[source-controller](https://github.com/fluxcd/source-controller)
4446
for providing the raw manifests from Git repositories or any
@@ -62,3 +64,130 @@ Alerting can be configured with a Kubernetes custom resource
6264
that specifies a webhook address, and a group of pipelines to be monitored.
6365

6466
The API design of the controller can be found at [kustomize.fluxcd.io/v1alpha1](v1alpha1/README.md).
67+
68+
## Example
69+
70+
After installing kustomize-controller and its companion source-controller, we
71+
can create a series of pipelines for deploying Istio, and an application made of
72+
multiple services.
73+
74+
Create a source that points to where the Istio control plane manifests are,
75+
and a kustomization for installing/upgrading Istio:
76+
77+
```yaml
78+
apiVersion: source.fluxcd.io/v1alpha1
79+
kind: GitRepository
80+
metadata:
81+
name: istio
82+
namespace: kustomize-system
83+
spec:
84+
interval: 5m
85+
url: https://github.com/stefanprodan/gitops-istio
86+
ref:
87+
branch: master
88+
---
89+
apiVersion: kustomize.fluxcd.io/v1alpha1
90+
kind: Kustomization
91+
metadata:
92+
name: istio
93+
namespace: kustomize-system
94+
spec:
95+
interval: 10m
96+
path: "./istio/"
97+
generate: true
98+
sourceRef:
99+
kind: GitRepository
100+
name: istio
101+
healthChecks:
102+
- kind: Deployment
103+
name: istiod
104+
namespace: istio-system
105+
timeout: 2m
106+
```
107+
108+
Create a source for the app repo, a kustomization for each service defining depends-on relationships:
109+
110+
```yaml
111+
apiVersion: source.fluxcd.io/v1alpha1
112+
kind: GitRepository
113+
metadata:
114+
name: webapp
115+
namespace: kustomize-system
116+
spec:
117+
interval: 1m
118+
url: https://github.com/stefanprodan/podinfo-deploy
119+
ref:
120+
branch: master
121+
---
122+
apiVersion: kustomize.fluxcd.io/v1alpha1
123+
kind: Kustomization
124+
metadata:
125+
name: webapp-common
126+
namespace: kustomize-system
127+
spec:
128+
dependsOn:
129+
- istio
130+
interval: 5m
131+
path: "./webapp/common/"
132+
prune: "part-of=webapp"
133+
sourceRef:
134+
kind: GitRepository
135+
name: webapp
136+
validate: client
137+
---
138+
apiVersion: kustomize.fluxcd.io/v1alpha1
139+
kind: Kustomization
140+
metadata:
141+
name: webapp-backend
142+
namespace: kustomize-system
143+
spec:
144+
dependsOn:
145+
- webapp-common
146+
interval: 5m
147+
path: "./webapp/backend/"
148+
prune: "part-of=webapp,component=backend"
149+
sourceRef:
150+
kind: GitRepository
151+
name: webapp
152+
validate: server
153+
healthChecks:
154+
- kind: Deployment
155+
name: backend
156+
namespace: webapp
157+
---
158+
apiVersion: kustomize.fluxcd.io/v1alpha1
159+
kind: Kustomization
160+
metadata:
161+
name: webapp-frontend
162+
namespace: kustomize-system
163+
spec:
164+
dependsOn:
165+
- webapp-backend
166+
interval: 5m
167+
path: "./webapp/frontend/"
168+
prune: "part-of=webapp,component=frontend"
169+
sourceRef:
170+
kind: GitRepository
171+
name: webapp
172+
validate: server
173+
```
174+
175+
Configure alerting for all pipelines in the `kustomize-system` namespace:
176+
177+
```yaml
178+
apiVersion: kustomize.fluxcd.io/v1alpha1
179+
kind: Profile
180+
metadata:
181+
name: default
182+
namespace: kustomize-system
183+
spec:
184+
alert:
185+
type: slack
186+
verbosity: info
187+
address: https://hooks.slack.com/services/YOUR/SLACK/WEBHOOK
188+
username: kustomize-controller
189+
channel: general
190+
kustomizations:
191+
- '*'
192+
```
193+

0 commit comments

Comments
 (0)