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

Commit 86fc6eb

Browse files
authored
Support for EnvFromSource in cluster spec (#283)
1 parent cf9dd72 commit 86fc6eb

File tree

6 files changed

+58
-0
lines changed

6 files changed

+58
-0
lines changed

api/v1beta1/flinkcluster_types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,10 @@ type FlinkClusterSpec struct {
413413
// containers.
414414
EnvVars []corev1.EnvVar `json:"envVars,omitempty"`
415415

416+
// Environment variables injected from a source, shared by all JobManager,
417+
// TaskManager and job containers.
418+
EnvFrom []corev1.EnvFromSource `json:"envFrom,omitempty"`
419+
416420
// Flink properties which are appened to flink-conf.yaml.
417421
FlinkProperties map[string]string `json:"flinkProperties,omitempty"`
418422

api/v1beta1/zz_generated.deepcopy.go

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/flinkoperator.k8s.io_flinkclusters.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,27 @@ spec:
3030
properties:
3131
batchSchedulerName:
3232
type: string
33+
envFrom:
34+
items:
35+
properties:
36+
configMapRef:
37+
properties:
38+
name:
39+
type: string
40+
optional:
41+
type: boolean
42+
type: object
43+
prefix:
44+
type: string
45+
secretRef:
46+
properties:
47+
name:
48+
type: string
49+
optional:
50+
type: boolean
51+
type: object
52+
type: object
53+
type: array
3354
envVars:
3455
items:
3556
properties:

controllers/flinkcluster_converter.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ func getDesiredJobManagerDeployment(
187187
ReadinessProbe: &readinessProbe,
188188
Resources: jobManagerSpec.Resources,
189189
Env: envVars,
190+
EnvFrom: flinkCluster.Spec.EnvFrom,
190191
VolumeMounts: volumeMounts,
191192
}}
192193

@@ -477,6 +478,7 @@ func getDesiredTaskManagerDeployment(
477478
ReadinessProbe: &readinessProbe,
478479
Resources: taskManagerSpec.Resources,
479480
Env: envVars,
481+
EnvFrom: flinkCluster.Spec.EnvFrom,
480482
VolumeMounts: volumeMounts,
481483
}}
482484
containers = append(containers, taskManagerSpec.Sidecars...)

controllers/flinkcluster_converter_test.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,10 @@ func TestGetDesiredClusterState(t *testing.T) {
239239
},
240240
FlinkProperties: map[string]string{"taskmanager.numberOfTaskSlots": "1"},
241241
EnvVars: []corev1.EnvVar{{Name: "FOO", Value: "abc"}},
242+
EnvFrom: []corev1.EnvFromSource{{ConfigMapRef: &corev1.ConfigMapEnvSource{
243+
LocalObjectReference: corev1.LocalObjectReference{
244+
Name: "FOOMAP",
245+
}}}},
242246
HadoopConfig: &v1beta1.HadoopConfig{
243247
ConfigMapName: "hadoop-configmap",
244248
MountPath: "/etc/hadoop/conf",
@@ -347,6 +351,15 @@ func TestGetDesiredClusterState(t *testing.T) {
347351
Value: "abc",
348352
},
349353
},
354+
EnvFrom: []corev1.EnvFromSource{
355+
{
356+
ConfigMapRef: &corev1.ConfigMapEnvSource{
357+
LocalObjectReference: corev1.LocalObjectReference{
358+
Name: "FOOMAP",
359+
},
360+
},
361+
},
362+
},
350363
Resources: corev1.ResourceRequirements{
351364
Requests: map[corev1.ResourceName]resource.Quantity{
352365
corev1.ResourceCPU: resource.MustParse("100m"),
@@ -601,6 +614,15 @@ func TestGetDesiredClusterState(t *testing.T) {
601614
Value: "abc",
602615
},
603616
},
617+
EnvFrom: []corev1.EnvFromSource{
618+
{
619+
ConfigMapRef: &corev1.ConfigMapEnvSource{
620+
LocalObjectReference: corev1.LocalObjectReference{
621+
Name: "FOOMAP",
622+
},
623+
},
624+
},
625+
},
604626
Resources: corev1.ResourceRequirements{
605627
Requests: map[corev1.ResourceName]resource.Quantity{
606628
corev1.ResourceCPU: resource.MustParse("200m"),

docs/crd.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ FlinkCluster
7878
|__ cancelRequested
7979
|__ podAnnotations
8080
|__ envVars
81+
|__ envFrom
8182
|__ flinkProperties
8283
|__ hadoopConfig
8384
|__ configMapName
@@ -266,6 +267,7 @@ FlinkCluster
266267
* **podAnnotations** (optional): Pod template annotations for the job.
267268
See [more info](https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/) about annotations.
268269
* **envVars** (optional): Environment variables shared by all JobManager, TaskManager and job containers.
270+
* **envFrom** (optional): Environment variables from ConfigMaps or Secrets shared by all JobManager, TaskManager and job containers.
269271
* **flinkProperties** (optional): Flink properties which are appened to flink-conf.yaml.
270272
* **hadoopConfig** (optional): Configs for Hadoop.
271273
* **configMapName**: The name of the ConfigMap which holds the Hadoop config files. The ConfigMap must be in the

0 commit comments

Comments
 (0)