Kubernetes Resources
On this page
The Ververica Platform creates various Kubernetes resources to support Apache FlinkĀ® clusters. For example, Kubernetes jobs, deployments, and services are used to run and expose the JobManagers and TaskManagers.
The Kubernetes pods that back these resources can be configured via simplified pod options or full-fledged pod templates.
Overview
The Kubernetes resources created for a Flink cluster can be customized as part of the kubernetes section.
1kind: SessionCluster
2spec:
3 kubernetes:
4 labels: <Map<String, String>>
5 pods: <KubernetesPodOptions>
6 jobManagerPodTemplate: <V1PodTemplateSpec>
7 taskManagerPodTemplate: <V1PodTemplateSpec>The labels attribute allows specifying additional labels to the Kubernetes deployments, jobs, and services created for Flink clusters, with precedence given to system-defined labels.
The pods attribute allows customization of common Kubernetes options that apply to both JobManager and TaskManager pods.
The jobManagerPodTemplate and taskManagerPodTemplate allow you to individually customize the JobManager and/or TaskManager pods with full flexibility by exposing the Kubernetes V1PodTemplateSpec API object.
In both cases, the attributes you specify will be merged with the system configuration.
It is only possible to either specify the pods attribute or the jobManagerPodTemplate and taskManagerPodTemplate attributes.
Kubernetes Pod Options
User-provided Kubernetes pod options under pods apply to both the JobManager and TaskManager pods and expose common configuration options.
1kind: SessionCluster
2spec:
3 kubernetes:
4 pods:
5 annotations:
6 key: value
7 labels:
8 key: value
9 nodeSelector:
10 key: value
11 affinity: <V1Affinity>
12 tolerations:
13 - <V1Toleration>
14 imagePullSecrets:
15 - name: secretName
16 volumeMounts:
17 - name: volumeAndMountName
18 volume: <V1Volume>
19 volumeMount: <V1VolumeMount>
20 envVars:
21 - name: envVarName
22 value: envVarValue
23 valueFrom: <V1EnvVarSource>
24 securityContext: <V1PodSecurityContext>Kubernetes API objects such as V1Volume are only validated lazily at Flink cluster creation time.
Annotations
The annotations configured as part of the Kubernetes options are added to the annotations of the created JobManager and TaskManager pods.
1kind: SessionCluster
2spec:
3 kubernetes:
4 pods:
5 annotations:
6 key: valueAll provided annotations are subject to the restrictions enforced by the Kubernetes API.
Labels
The labels configured as part of the Kubernetes options are added to the labels of the created JobManager and TaskManager pods.
1kind: SessionCluster
2spec:
3 kubernetes:
4 pods:
5 labels:
6 key: valueAll provided labels are subject to the restrictions enforced by the Kubernetes API.
The labels app, component, deploymentId, deploymentName, jobId, system, sessionClusterId, sessionClusterName, and vvpNamespace are reserved by Ververica Platform.
Node Selector
The node selector configured as part of the Kubernetes options is added to the node selector of the created JobManager and TaskManager pods.
1kind: SessionCluster
2spec:
3 kubernetes:
4 pods:
5 nodeSelector:
6 key: valueAffinity
The affinity configured as part of the Kubernetes options is added set as the affinity of the created JobManager and TaskManager pods.
1kind: SessionCluster
2spec:
3 kubernetes:
4 pods:
5 affinity: <V1Affinity>V1Affinityrefers to the respective Kubernetes API object Kubernetes API objects such as V1Affinity are only validated lazily at Flink cluster creation time.
Tolerations
The tolerations configured as part of the Kubernetes options are added to the tolerations of the created JobManager and TaskManager pods.
1kind: SessionCluster
2spec:
3 kubernetes:
4 pods:
5 tolerations:
6 - <V1Toleration>V1Tolerationrefers to the respective Kubernetes API object. Kubernetes API objects such as V1Toleration are validated lazily at Flink cluster creation time.
Image Pull Secrets
The image pull secrets configured as part of the Kubernetes options are added to the image pull secrets of the created JobManager and TaskManager pods.
1kind: SessionCluster
2spec:
3 kubernetes:
4 pods:
5 imagePullSecrets:
6 - name: secretNameAll provided secret names are subject to the restrictions enforced by the Kubernetes API. If a referenced secret does not exist, the Flink cluster will fail to start.
Volume Mounts
The volume and volume mount configured as part of the Kubernetes options are added to the volumes of the created JobManager and TaskManager pods and mounted in the respective Flink containers.
1kind: SessionCluster
2spec:
3 kubernetes:
4 pods:
5 volumeMounts:
6 - name: volumeAndMountName
7 volume: <V1Volume>
8 volumeMount: <V1VolumeMount>V1Volumerefers to the respective Kubernetes API object. V1VolumeMountrefers to the respective Kubernetes API object.
Kubernetes API objects such as V1Volume or V1VolumeMount are only validated lazily at Flink cluster creation time. The name of the configured volume and volume mount must match the provided volumeAndMountName.
Example: Mounting a Secret
1kind: SessionCluster
2spec:
3 kubernetes:
4 pods:
5 volumeMounts:
6 - name: my-secret
7 volume:
8 name: my-secret
9 secret:
10 secretName: my-secret
11 volumeMount:
12 name: my-secret
13 mountPath: /var/run/secrets/some-secretEnvironment Variables
The environment variables configured as part of the Kubernetes options are added to the environment variables of the JobManager and TaskManager containers.
1kind: SessionCluster
2spec:
3 kubernetes:
4 pods:
5 envVars:
6 - name: envVarName
7 value: envVarValue
8 valueFrom: <V1EnvVarSource>You can either configure value directly or a V1EnvVarSource. Kubernetes API objects such as V1EnvVarSource are only validated lazily at Flink cluster creation time. If a referenced environment variable source does not exist, the Flink cluster will fail to start.
Example: Setting Environment Variables
1kind: SessionCluster
2spec:
3 kubernetes:
4 pods:
5 envVars:
6 - name: ENV
7 value: testing
8 - name: POD_IP
9 valueFrom:
10 fieldRef:
11 fieldPath: status.podIPPod Security Context
The security context configured as part of the Kubernetes options is set as the security contet of the created JobManager and TaskManager pods.
1kind: SessionCluster
2spec:
3 kubernetes:
4 pods:
5 securityContext: <V1PodSecurityContext>V1PodSecurityContextrefers to the respective Kubernetes API object Kubernetes API objects such as V1PodSecurityContext are only validated lazily at Flink cluster creation time.
Flink Pod Templates (Recommended)
User-provided Kubernetes pod templates under jobManagerPodTemplate and taskManagerPodTemplateapply to the JobManager and TaskManager pods individually and provide full flexibility by exposing the complete V1PodTemplateSpec API.
1kind: SessionCluster
2spec:
3 kubernetes:
4 jobManagerPodTemplate: <V1PodTemplateSpec>
5 taskManagerPodTemplate: <V1PodTemplateSpec>The templates are used by Ververica Platform during deployment of Flink clusters. System-level configuration is applied on top of the user-provided templates.
Overall correctness of the resulting pod specs is only validated lazily at Flink cluster creation time, but each provided V1PodTemplateSpec is validated eagerly for structural correctness.
Container Names
Flink clusters launched by Ververica Platform for SessionClusters create two pods, one for the JobManager and one for the TaskManager. The following containers are executed as part of the pods.
In order to modify the configuration of these containers, you have to include them in the provided pod templates (#examples). The configuration is subject to the merge rules outlined below.
Merge Rules and System Reserved Fields
Some attributes provided as part of the pod templates cannot be overwritten by user-provided options. The following table describes how user-provided options are merged.
The rules for containers only apply to containers named flink-jobmanager, flink-taskmanager, and result-fetcher.
All omitted fields are fully configurable.
You can set validation of non empty spec.serviceAccountName with the global setting vvp.accessControl.serviceAccountNameEnforcementEnabled=true. SessionCluster should have spec.serviceAccountName defined in jobManagerPodTemplate and taskManagerPodTemplate. Validation requires format session-${namespace}-${sessionClusterName}.
Examples
Below we show some examples of configuring specific Kubernetes properties.
Add Pod Labels
The following example adds a env: testing label to all pods.
1kind: SessionCluster
2spec:
3 kubernetes:
4 jobManagerPodTemplate:
5 metadata:
6 labels:
7 env: testing
8 taskManagerPodTemplate:
9 metadata:
10 labels:
11 env: testingSet Image Pull Policy
The following example sets imagePullPolicy: IfNotPresent for all containers.
1kind: SessionCluster
2spec:
3 kubernetes:
4 jobManagerPodTemplate:
5 spec:
6 containers:
7 - name: flink-jobmanager
8 imagePullPolicy: IfNotPresent
9 - name: result-fetcher
10 imagePullPolicy: IfNotPresent
11 taskManagerPodTemplate:
12 spec:
13 containers:
14 - name: flink-taskmanager
15 imagePullPolicy: IfNotPresent
16 - name: result-fetcher
17 imagePullPolicy: IfNotPresentAdd Sidecar Containers
The following example adds an additional sidecar container named my-logging-sidecar to both the JobManager and TaskManager pods.
1kind: SessionCluster
2spec:
3 kubernetes:
4 jobManagerPodTemplate:
5 spec:
6 containers:
7 - name: my-logging-sidecar
8 image: registry.acme.org/logging:3.2.1
9 taskManagerPodTemplate:
10 spec:
11 containers:
12 - name: my-logging-sidecar
13 image: registry.acme.org/logging:3.2.1Request Ephemeral TaskManager Storage
The following example requests ephemeral storage for TaskManager containers.
1kind: SessionCluster
2spec:
3 kubernetes:
4 taskManagerPodTemplate:
5 spec:
6 containers:
7 - name: flink-taskmanager
8 resources:
9 requests:
10 ephemeral-storage: "2Gi"
11 limits:
12 ephemeral-storage: "4Gi"