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

Commit 4e98987

Browse files
authored
Include Flink-Job-Cluster Helm Chart (#292)
1 parent 16516f6 commit 4e98987

File tree

9 files changed

+431
-0
lines changed

9 files changed

+431
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ The operator is still under active development, there is no Helm chart available
8181
* [Run Apache Beam Python jobs](docs/beam_guide.md)
8282
* [Use GCS connector](images/flink/README.md)
8383
* [Test with Apache Kafka](docs/kafka_test_guide.md)
84+
* [Create Flink job clusters with Helm Chart](docs/flink_job_cluster_guide.md)
8485

8586
### Tech talks
8687

docs/flink_job_cluster_guide.md

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
# Create Flink job clusters with Helm Chart
2+
3+
## Overview
4+
5+
This Helm Chart is an addition to the [existing](https://github.com/GoogleCloudPlatform/flink-on-k8s-operator/tree/master/config/samples) way of deploying Flink job clusters.
6+
7+
### Why use the Helm Chart?
8+
A typical Helm chart will usually include all of the manifests which you would manually apply with kubectl as templates, along with a ```values.yaml``` file for quick management of user preferences, so it becomes a one-step process to manage all of these resources as a single resource. Since Flink job clusters are currently deployed with just one YAML file, it might seem like the helm chart is unnecessary. However, the more components are added in the future, such as a ```PodMonitor``` or ```Services```, the easier it will be to manage those manifests from a central ```values.yaml```. Helm also supports various deployment checks before and after deployment so it integrates well with CI/CD pipelines. Some of these benefits are listed below:
9+
10+
- Easy configuration as you just have to configure or enable features in the ```values.yaml``` without much knowledge of the entire chart
11+
- You can use helm operations such as ```helm --dry run``` to check for any errors before deployment
12+
- Automated rollback to a previous functioning release with the ```--atomic``` flag
13+
- Manual rollbacks to previous revisions possible with ```helm rollback```
14+
- Helm includes release versioning which can be checked by using the ```helm list <namespace>``` command
15+
16+
## Prerequisites
17+
18+
19+
- Fink Operator Image Version: ```gcr.io/flink-operator/flink-operator:v1beta1-6``` follow these [instructions](https://github.com/GoogleCloudPlatform/flink-on-k8s-operator/tree/master/helm-chart/flink-operator) to deploy the Operator
20+
- Flink Image Version: ```flink:1.9.3``` or ```flink:latest```
21+
- [Helm](https://helm.sh/docs/helm/helm_install/) version 2.x or 3.x
22+
23+
Optional:
24+
- [Prometheus-Operator](https://github.com/GoogleCloudPlatform/flink-on-k8s-operator/blob/master/docs/user_guide.md#monitoring-with-prometheus) to use the custom resource ```PodMonitor``` in order to scrape flink-job-cluster metrics
25+
26+
27+
## Installing the Chart
28+
29+
The instructions to install the Flink Job Cluster chart:
30+
31+
1. Clone the repository to your local machine, which has access to your running kubernetes cluster.
32+
```bash
33+
git clone https://github.com/GoogleCloudPlatform/flink-on-k8s-operator.git
34+
```
35+
2. Navigate to the following folder: ```/flink-on-k8s-operator/helm-chart```
36+
37+
3. Use the following command to dry-run the Flink job cluster chart:
38+
```bash
39+
helm install --dry-run --namespace=<namespace> flink-job-cluster ./flink-job-cluster -f ./flink-job-cluster/values.yaml
40+
```
41+
The ```dry-run``` flag will render the templated yaml files. It is used to debug your chart. You'll be notified if there is any error in the chart configuration.
42+
43+
4. Use the following command to install the Flink job cluster chart:
44+
```bash
45+
helm install --namespace=<namespace> flink-job-cluster ./flink-job-cluster -f ./flink-job-cluster/values.yaml
46+
```
47+
48+
Afterwards, you should see the following output in your console:
49+
```bash
50+
NAME: flink-job-cluster
51+
LAST DEPLOYED: Tue Aug 4 10:39:10 2020
52+
NAMESPACE: <namespace>
53+
STATUS: deployed
54+
REVISION: 1
55+
TEST SUITE: None
56+
```
57+
***Note*** the ```values.file``` in ```/flink-on-k8s-operator/helm-chart/flink-job-cluster/``` is just an example configuration. You can use your own values.yaml if you wish and edit the parts that you want to change. The current values.yaml has the minimum configuration requirements enabled for the Flink job cluster to start successfully.
58+
59+
## Uninstalling the Chart
60+
61+
To uninstall your release:
62+
63+
1. Use the following command to list the Flink job cluster release:
64+
```bash
65+
helm list --namespace=<namespace>
66+
```
67+
2. Find your release name and delete it:
68+
```bash
69+
helm delete <release_name> --namespace=<namespace>
70+
```
71+
72+
## Check the Flink job cluster
73+
74+
After using the helm command, the following resources will be deployed
75+
76+
- Flink job (1x)
77+
- Flink job manager (1x)
78+
- Flink task manager (2x)
79+
80+
You can check the status of your deployment by using
81+
```bash
82+
kubectl get deployments --namespace=<namespace>
83+
```
84+
85+
## Flink Operator Releases
86+
87+
You can check which images of the Operator are available at [GoogleCloudPlatform](https://console.cloud.google.com/gcr/images/flink-operator/GLOBAL/flink-operator?gcrImageListsize=30)
88+
89+
## Monitoring
90+
91+
The Flink job cluster comes with a PodMonitor resource, which is the counter part to a ServiceMonitor.
92+
The PodMonitor will use pod labels and configure prometheus to scrape the Flink job cluster metrics. Reason for using the PodMonitor is simple, the Flink job cluster does not deploy services.
93+
94+
You can use the following [dashboard](https://grafana.com/grafana/dashboards/10369) in your grafana to monitor the flink-job-cluster.
95+
96+
## Run Jobs with InitContainer
97+
98+
You have the option to download job jars to be executed as jobs, directly into the Flink job cluster pods.
99+
There is already an [example](https://github.com/GoogleCloudPlatform/flink-on-k8s-operator/blob/master/config/samples/flinkoperator_v1beta1_remotejobjar.yaml.) on how to run the Flink job cluster with a remote job jar.
100+
101+
## Run Jobs without InitContainer
102+
103+
If you do not want to use a remote job jar, you can simply use the Flink image e.g. ```flink:1.9.3``` and copy your built jar file into that image to create your custom Flink image. This way you can directly start the job without using an InitContainer. Just use your custom Flink image as ```image``` in the values.yaml, and make sure to set the correct path for the job to look for the JAR file.
104+
105+
```yaml
106+
image:
107+
repository: <your_repository>/<your_custom_flink_image>
108+
tag: 1.9.3
109+
110+
job:
111+
# job will look for a JAR file at ./examples/streaming/WordCount.jar and execute it
112+
# className has to be valid and used in the provided JAR File
113+
jarFile: ./examples/streaming/WordCount.jar
114+
```
115+
116+
## Check Running Jobs
117+
118+
You can check running jobs by using the following command:
119+
120+
```kubectl get jobs -n <namespace>```
121+
122+
## Updating Job
123+
124+
1. Build your new/updated JAR file which will be executed by the Flink job cluster
125+
2. Prepare a new custom Flink Image which has your JAR file included, for example at: /JARFiles/<JAR_FILE>
126+
3. Adjust the path for the jar file in ```values.yaml``` at job.jarFile from "./examples/streaming/WordCount.jar" to "/JARFiles/<JAR_FILE>"
127+
3. Upload your custom Flink Image to your registry
128+
4. Specify your custom Flink Image in the helm-chart ```values.yaml``` under the ```image``` section
129+
5. Navigate to ```/flink-on-k8s-operator/helm-chart``` and use the helm command to update your running Flink job cluster.
130+
```bash
131+
helm upgrade --namespace=<namespace> flink-job-cluster ./flink-job-cluster -f ./flink-job-cluster/values.yaml
132+
```
133+
134+
## Roadmap
135+
136+
We are planning to extend the chart by adding the possibility to use [strimzi.io](https://strimzi.io/) KafkaUsers. This way, we can automatically spin up new KafkaUsers when deploying a Flink job cluster.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*~
18+
# Various IDEs
19+
.project
20+
.idea/
21+
*.tmproj
22+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apiVersion: v1
2+
appVersion: "1.0"
3+
description: flinkjobcluster deployment
4+
name: flink-job-cluster
5+
version: 0.1.51
6+
contributors:
7+
- name: javier moreno molina
8+
9+
- name: tayfun yalcin
10+
11+
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Helm Chart for Flink Job Cluster
2+
3+
Please follow the Flink job cluster Helm Chart [guide](docs/flink_job_cluster_guide) to deploy the helm chart.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{{/* vim: set filetype=mustache: */}}
2+
{{/*
3+
Expand the name of the chart.
4+
*/}}
5+
{{- define "flink-job-cluster.name" -}}
6+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
7+
{{- end -}}
8+
9+
{{/*
10+
Create a default fully qualified app name.
11+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
12+
If release name contains chart name it will be used as a full name.
13+
*/}}
14+
{{- define "flink-job-cluster.fullname" -}}
15+
{{- if .Values.fullnameOverride -}}
16+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
17+
{{- else -}}
18+
{{- $name := default .Chart.Name .Values.nameOverride -}}
19+
{{- if contains $name .Release.Name -}}
20+
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
21+
{{- else -}}
22+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
23+
{{- end -}}
24+
{{- end -}}
25+
{{- end -}}
26+
27+
{{/*
28+
Create chart name and version as used by the chart label.
29+
*/}}
30+
{{- define "flink-job-cluster.chart" -}}
31+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
32+
{{- end -}}
33+
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
apiVersion: flinkoperator.k8s.io/v1beta1
2+
kind: FlinkCluster
3+
metadata:
4+
name: {{ template "flink-job-cluster.fullname" . }}
5+
labels:
6+
app: {{ template "flink-job-cluster.name" . }}
7+
chart: {{ template "flink-job-cluster.chart" . }}
8+
release: {{ .Release.Name }}
9+
spec:
10+
image:
11+
name: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
12+
envVars:
13+
{{ toYaml .Values.envVars | indent 4 }}
14+
jobManager:
15+
accessScope: {{ .Values.jobManager.accessScope }}
16+
ports:
17+
ui: {{ .Values.jobManager.ports.ui }}
18+
{{- if .Values.jobManager.volumes }}
19+
volumes:
20+
{{ toYaml .Values.jobManager.volumes | indent 6}}
21+
{{- end }}
22+
{{- if .Values.jobManager.volumeMounts }}
23+
volumeMounts:
24+
{{ toYaml .Values.jobManager.volumeMounts | indent 6}}
25+
{{- end }}
26+
{{- if .Values.jobManager.metrics.enabled }}
27+
extraPorts:
28+
{{ toYaml .Values.jobManager.metrics.extraPorts | indent 6 }}
29+
{{- end }}
30+
resources:
31+
{{ toYaml .Values.jobManager.resources | indent 6 }}
32+
podAnnotations:
33+
{{- with .Values.podAnnotations }}
34+
{{- toYaml . | nindent 6 }}
35+
{{- end }}
36+
taskManager:
37+
replicas: {{ .Values.taskManager.replicas }}
38+
{{- if .Values.taskManager.volumes }}
39+
volumes:
40+
{{ toYaml .Values.taskManager.volumes | indent 6}}
41+
{{- end }}
42+
{{- if .Values.taskManager.volumeMounts }}
43+
volumeMounts:
44+
{{ toYaml .Values.taskManager.volumeMounts | indent 6}}
45+
{{- end }}
46+
{{- if .Values.taskManager.metrics.enabled }}
47+
extraPorts:
48+
{{ toYaml .Values.taskManager.metrics.extraPorts | indent 6 }}
49+
{{- end }}
50+
resources:
51+
{{ toYaml .Values.taskManager.resources | indent 6 }}
52+
podAnnotations:
53+
{{- with .Values.podAnnotations }}
54+
{{- toYaml . | nindent 6 }}
55+
{{- end }}
56+
job:
57+
jarFile: {{ .Values.job.jarFile }}
58+
className: {{ .Values.job.className }}
59+
args: ["--input", "./README.txt"]
60+
parallelism: {{ .Values.job.parallelism }}
61+
restartPolicy: {{ .Values.job.restartPolicy }}
62+
{{- if .Values.job.volumes }}
63+
volumes:
64+
{{ toYaml .Values.job.volumes | indent 6}}
65+
{{- end }}
66+
{{- if .Values.job.volumeMounts }}
67+
volumeMounts:
68+
{{ toYaml .Values.job.volumeMounts | indent 6}}
69+
{{- end }}
70+
{{- if .Values.job.initContainers.enabled }}
71+
initContainers:
72+
- name: {{ .Chart.Name}}-python-blob-downloader
73+
image: "{{ .Values.job.initContainers.image }}:{{ .Values.job.initContainers.tag }}"
74+
command: ["/bin/sh","-c","--"]
75+
args: ["/app/exec-python.sh"]
76+
env:
77+
- name: STORAGE_CONNECTION_STRING
78+
valueFrom:
79+
secretKeyRef:
80+
name: {{ .Values.job.initContainers.Storage.secretName }}
81+
key: {{ .Values.job.initContainers.Storage.secretNameKey }}
82+
- name: CONTAINER_NAME
83+
value: {{ .Values.job.initContainers.Storage.containerName }}
84+
- name: BLOB_NAME
85+
value: {{ .Values.job.initContainers.Storage.blobName }}
86+
{{- end }}
87+
podAnnotations:
88+
{{- with .Values.podAnnotations }}
89+
{{- toYaml . | nindent 6 }}
90+
{{- end }}
91+
flinkProperties:
92+
{{ toYaml .Values.flinkProperties | indent 4}}
93+
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{{- if .Values.podMonitor.enabled -}}
2+
apiVersion: monitoring.coreos.com/v1
3+
kind: PodMonitor
4+
metadata:
5+
name: {{ template "flink-job-cluster.fullname" . }}
6+
{{- if .Values.podMonitor.podMonitorSelectorLabels }}
7+
labels:
8+
{{ toYaml .Values.podMonitor.podMonitorSelectorLabels | indent 4 }}
9+
{{- end }}
10+
spec:
11+
podTargetLabels:
12+
{{ toYaml .Values.podMonitor.podTargetLabels | indent 6 }}
13+
selector:
14+
matchLabels:
15+
app: flink
16+
podMetricsEndpoints:
17+
{{ toYaml .Values.podMonitor.podMetricsEndpoints | indent 4 }}
18+
{{- end -}}
19+

0 commit comments

Comments
 (0)