Skip to content
This repository was archived by the owner on May 8, 2025. It is now read-only.

Commit 9272f09

Browse files
authored
add ns create flag (#348)
1 parent c94ff8d commit 9272f09

File tree

6 files changed

+35
-22
lines changed

6 files changed

+35
-22
lines changed

.circleci/release.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ main() {
5050
kustomize build flink-on-k8s-operator/config/default | tee flink-operator.yaml
5151
sed -i '1s/^/{{- if .Values.rbac.create }}\n/' flink-operator.yaml
5252
sed -i -e "\$a{{- end }}\n" flink-operator.yaml
53-
sed -i 's/flink-operator-system/{{ .Values.flinkOperatorNamespace }}/g' flink-operator.yaml
53+
sed -i 's/flink-operator-system/{{ .Values.flinkOperatorNamespace.name }}/g' flink-operator.yaml
5454
sed -i 's/replicas: 1/replicas: {{ .Values.replicas }}/g' flink-operator.yaml
5555
sed -i "s/$IMG/{{ .Values.operatorImage.name }}/g" flink-operator.yaml
5656
mv flink-operator.yaml helm-chart/flink-operator/templates/flink-operator.yaml

helm-chart/flink-operator/README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ The instructions to install the Flink operator chart:
88

99
1. Prepare a Flink operator image. You can either use a released image e.g., `gcr.io/flink-operator/flink-operator:latest` or follow the instructions [here](https://github.com/GoogleCloudPlatform/flink-on-k8s-operator/blob/master/docs/developer_guide.md#build-and-push-docker-image) to build and push an image from the source code.
1010

11-
2. Run the bash script `update_template.sh` to update the manifest files in templates from the Flink operator source repo (This step is only required if you want to install from the local chart repo).
11+
2. Run the bash script `update_template.sh` to update the manifest files in templates from the Flink operator source repo (This step is only required if you want to install from the local chart repo).
12+
You can set the following env vars to customize the script's behaviour -
13+
* `export IMG=<image-name>` - Operator image, defaults to `flink-operator:latest`
14+
* `export NS=<namespace-name>` - Namespace to install the operator in, defaults to `flink-operator-system`
1215

1316
3. Register CRD - Don't manually register CRD unless helm install below fails (You can skip this step if your helm version is v3).
1417

@@ -28,6 +31,11 @@ The instructions to install the Flink operator chart:
2831
helm install --name [RELEASE_NAME] . --set operatorImage.name=[IMAGE_NAME]
2932
```
3033

34+
If you're installing the chart into a preexisting namespace, make sure to set the namespace name and instruct the chart not create one like so:
35+
36+
```bash
37+
helm install --name [RELEASE_NAME] . --set operatorImage.name=[IMAGE_NAME],flinkOperatorNamespace.name=[NAMESPACE_NAME],flinkOperatorNamespace.create=false
38+
```
3139
## Uninstalling the Chart
3240

3341
To uninstall your release:

helm-chart/flink-operator/templates/flink-operator.yaml

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
{{- if .Values.rbac.create }}
2+
{{- if .Values.flinkOperatorNamespace.create }}
23
apiVersion: v1
34
kind: Namespace
45
metadata:
56
labels:
67
control-plane: controller-manager
7-
name: {{ .Values.flinkOperatorNamespace }}
8+
name: {{ .Values.flinkOperatorNamespace.name }}
9+
{{- end }}
810
---
911
apiVersion: admissionregistration.k8s.io/v1beta1
1012
kind: MutatingWebhookConfiguration
@@ -16,7 +18,7 @@ webhooks:
1618
caBundle: Cg==
1719
service:
1820
name: flink-operator-webhook-service
19-
namespace: {{ .Values.flinkOperatorNamespace }}
21+
namespace: {{ .Values.flinkOperatorNamespace.name }}
2022
path: /mutate-flinkoperator-k8s-io-v1beta1-flinkcluster
2123
failurePolicy: Fail
2224
name: mflinkcluster.flinkoperator.k8s.io
@@ -35,7 +37,7 @@ apiVersion: rbac.authorization.k8s.io/v1
3537
kind: Role
3638
metadata:
3739
name: flink-operator-leader-election-role
38-
namespace: {{ .Values.flinkOperatorNamespace }}
40+
namespace: {{ .Values.flinkOperatorNamespace.name }}
3941
rules:
4042
- apiGroups:
4143
- ""
@@ -256,15 +258,15 @@ apiVersion: rbac.authorization.k8s.io/v1
256258
kind: RoleBinding
257259
metadata:
258260
name: flink-operator-leader-election-rolebinding
259-
namespace: {{ .Values.flinkOperatorNamespace }}
261+
namespace: {{ .Values.flinkOperatorNamespace.name }}
260262
roleRef:
261263
apiGroup: rbac.authorization.k8s.io
262264
kind: Role
263265
name: flink-operator-leader-election-role
264266
subjects:
265267
- kind: ServiceAccount
266268
name: default
267-
namespace: {{ .Values.flinkOperatorNamespace }}
269+
namespace: {{ .Values.flinkOperatorNamespace.name }}
268270
---
269271
apiVersion: rbac.authorization.k8s.io/v1
270272
kind: ClusterRoleBinding
@@ -277,7 +279,7 @@ roleRef:
277279
subjects:
278280
- kind: ServiceAccount
279281
name: default
280-
namespace: {{ .Values.flinkOperatorNamespace }}
282+
namespace: {{ .Values.flinkOperatorNamespace.name }}
281283
---
282284
apiVersion: rbac.authorization.k8s.io/v1
283285
kind: ClusterRoleBinding
@@ -290,7 +292,7 @@ roleRef:
290292
subjects:
291293
- kind: ServiceAccount
292294
name: default
293-
namespace: {{ .Values.flinkOperatorNamespace }}
295+
namespace: {{ .Values.flinkOperatorNamespace.name }}
294296
---
295297
apiVersion: v1
296298
kind: Service
@@ -302,7 +304,7 @@ metadata:
302304
labels:
303305
control-plane: controller-manager
304306
name: flink-operator-controller-manager-metrics-service
305-
namespace: {{ .Values.flinkOperatorNamespace }}
307+
namespace: {{ .Values.flinkOperatorNamespace.name }}
306308
spec:
307309
ports:
308310
- name: https
@@ -315,7 +317,7 @@ apiVersion: v1
315317
kind: Service
316318
metadata:
317319
name: flink-operator-webhook-service
318-
namespace: {{ .Values.flinkOperatorNamespace }}
320+
namespace: {{ .Values.flinkOperatorNamespace.name }}
319321
spec:
320322
ports:
321323
- port: 443
@@ -330,7 +332,7 @@ metadata:
330332
app: flink-operator
331333
control-plane: controller-manager
332334
name: flink-operator-controller-manager
333-
namespace: {{ .Values.flinkOperatorNamespace }}
335+
namespace: {{ .Values.flinkOperatorNamespace.name }}
334336
spec:
335337
replicas: {{ .Values.replicas }}
336338
selector:
@@ -359,7 +361,7 @@ spec:
359361
- --watch-namespace=
360362
command:
361363
- /flink-operator
362-
image: {{ .Values.operatorImage.name }}
364+
image: {{ .Values.operatorImage.name.name }}
363365
imagePullPolicy: {{ .Values.operatorImage.pullPolicy }}
364366
name: flink-operator
365367
ports:
@@ -394,7 +396,7 @@ webhooks:
394396
caBundle: Cg==
395397
service:
396398
name: flink-operator-webhook-service
397-
namespace: {{ .Values.flinkOperatorNamespace }}
399+
namespace: {{ .Values.flinkOperatorNamespace.name }}
398400
path: /validate-flinkoperator-k8s-io-v1beta1-flinkcluster
399401
failurePolicy: Fail
400402
name: vflinkcluster.flinkoperator.k8s.io

helm-chart/flink-operator/templates/generate-cert.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ kind: ConfigMap
44
metadata:
55
creationTimestamp: null
66
name: cert-configmap
7-
namespace: {{ .Values.flinkOperatorNamespace }}
7+
namespace: {{ .Values.flinkOperatorNamespace.name }}
88
labels:
99
app.kubernetes.io/name: flink-operator
1010
app.kubernetes.io/component: cert-configmap
@@ -13,7 +13,7 @@ data:
1313
set -euxo pipefail
1414
service="flink-operator-webhook-service"
1515
secret="webhook-server-cert"
16-
namespace={{ .Values.flinkOperatorNamespace }}
16+
namespace={{ .Values.flinkOperatorNamespace.name }}
1717
csrName="${service}.${namespace}"
1818
tmpdir="$(mktemp -d)"
1919
echo "Creating certs in tmpdir ${tmpdir} "
@@ -59,7 +59,7 @@ kind: ConfigMap
5959
metadata:
6060
creationTimestamp: null
6161
name: webhook-configmap
62-
namespace: {{ .Values.flinkOperatorNamespace }}
62+
namespace: {{ .Values.flinkOperatorNamespace.name }}
6363
labels:
6464
app.kubernetes.io/name: flink-operator
6565
app.kubernetes.io/component: webhook-configmap
@@ -75,7 +75,7 @@ data:
7575
caBundle: $CA_PEM_B64
7676
service:
7777
name: flink-operator-webhook-service
78-
namespace: {{ .Values.flinkOperatorNamespace }}
78+
namespace: {{ .Values.flinkOperatorNamespace.name }}
7979
path: /mutate-flinkoperator-k8s-io-v1beta1-flinkcluster
8080
failurePolicy: Fail
8181
name: mflinkcluster.flinkoperator.k8s.io
@@ -100,7 +100,7 @@ data:
100100
caBundle: $CA_PEM_B64
101101
service:
102102
name: flink-operator-webhook-service
103-
namespace: {{ .Values.flinkOperatorNamespace }}
103+
namespace: {{ .Values.flinkOperatorNamespace.name }}
104104
path: /validate-flinkoperator-k8s-io-v1beta1-flinkcluster
105105
failurePolicy: Fail
106106
name: vflinkcluster.flinkoperator.k8s.io
@@ -120,7 +120,7 @@ kind: Job
120120
metadata:
121121
annotations:
122122
name: cert-job
123-
namespace: {{ .Values.flinkOperatorNamespace }}
123+
namespace: {{ .Values.flinkOperatorNamespace.name }}
124124
labels:
125125
app.kubernetes.io/name: flink-operator
126126
app.kubernetes.io/component: cert-job

helm-chart/flink-operator/update_template.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
#!/bin/bash
22

33
IMG="${IMG:-flink-operator:latest}"
4+
NS="${NS:-flink-operator-system}"
45

56
sed -e 's#image: .*#image: '"${IMG}"'#' ../../config/default/manager_image_patch.template >../../config/default/manager_image_patch.yaml
67
sed -i '/- \.\.\/crd/d' ../../config/default/kustomization.yaml
78
kubectl kustomize ../../config/default | tee templates/flink-operator.yaml
89
sed -i '1s/^/{{- if .Values.rbac.create }}\n/' templates/flink-operator.yaml
910
sed -i -e "\$a{{- end }}\n" templates/flink-operator.yaml
10-
sed -i 's/flink-operator-system/{{ .Values.flinkOperatorNamespace }}/g' templates/flink-operator.yaml
11+
sed -i 's/'"${NS}"'/{{ .Values.flinkOperatorNamespace.name }}/g' templates/flink-operator.yaml
1112
sed -i 's/replicas: 1/replicas: {{ .Values.replicas }}/g' templates/flink-operator.yaml
1213
sed -i "s/$IMG/{{ .Values.operatorImage.name }}/g" templates/flink-operator.yaml
1314
sed -i 's/--watch-namespace=/--watch-namespace={{ .Values.watchNamespace }}/' templates/flink-operator.yaml

helm-chart/flink-operator/values.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# K8s namespace where Flink operator to be deployed
2-
flinkOperatorNamespace: "flink-operator-system"
2+
flinkOperatorNamespace:
3+
name: "flink-operator-system"
4+
create: true
35

46
# Watch custom resources in the namespace, ignore other namespaces. If empty, all namespaces will be watched.
57
watchNamespace:

0 commit comments

Comments
 (0)