Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial Application mode support #277

Merged
merged 11 commits into from
Feb 24, 2022
5 changes: 3 additions & 2 deletions apis/flinkcluster/v1beta1/flinkcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ const (

// JobMode defines the running mode for the job.
const (
JobModeBlocking = "Blocking"
JobModeDetached = "Detached"
JobModeBlocking = "Blocking"
JobModeApplication = "Application"
JobModeDetached = "Detached"
)

type JobMode string
Expand Down
4 changes: 3 additions & 1 deletion apis/flinkcluster/v1beta1/flinkcluster_validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,8 @@ func (v *Validator) validateJob(jobSpec *JobSpec) error {
return nil
}

if jobSpec.JarFile == nil && jobSpec.PyFile == nil && jobSpec.PyModule == nil {
applicationMode := jobSpec.Mode != nil && *jobSpec.Mode == JobModeApplication
if !applicationMode && jobSpec.JarFile == nil && jobSpec.PyFile == nil && jobSpec.PyModule == nil {
return fmt.Errorf("job jarFile or pythonFile or pythonModule is unspecified")
}

Expand Down Expand Up @@ -594,6 +595,7 @@ func (v *Validator) validateCleanupAction(
func (v *Validator) validateJobMode(property string, value JobMode) error {
switch value {
case JobModeBlocking:
case JobModeApplication:
case JobModeDetached:
default:
return fmt.Errorf("invalid %v: %v", property, value)
Expand Down
46 changes: 41 additions & 5 deletions config/samples/flinkoperator_v1beta1_remotejobjar.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,49 @@ spec:
flinkVersion: "1.14"
image:
name: flink:1.14.2
jobManager:
volumes:
- name: usrlib
volumeMounts:
- mountPath: /opt/flink/usrlib
name: usrlib
initContainers:
- name: downloader
image: curlimages/curl
command:
["sh", "-c", "cd /opt/flink/usrlib; curl -O ${FLINK_JOB_JAR_URI}"]
resources:
limits:
cpu: 100m
memory: 512Mi
volumeMounts:
- mountPath: /opt/flink/usrlib
name: usrlib
taskManager:
volumes:
- name: usrlib
volumeMounts:
- mountPath: /opt/flink/usrlib
name: usrlib
initContainers:
- name: downloader
image: curlimages/curl
command:
["sh", "-c", "cd /opt/flink/usrlib; curl -O ${FLINK_JOB_JAR_URI}"]
resources:
limits:
cpu: 100m
memory: 512Mi
volumeMounts:
- mountPath: /opt/flink/usrlib
name: usrlib
job:
mode: Application
cleanupPolicy:
afterJobSucceeds: DeleteCluster
afterJobFails: DeleteCluster
afterJobCancelled: DeleteCluster
jarFile: https://repo1.maven.org/maven2/org/apache/flink/flink-examples-streaming_2.12/1.14.3/flink-examples-streaming_2.12-1.14.3-WordCount.jar
className: org.apache.flink.streaming.examples.wordcount.WordCount
args: ["--input", "./README.txt"]
restartPolicy: Never
initContainers:
- name: downloader
image: curlimages/curl
command:
["sh", "-c", "cd ${FLINK_USR_LIB_DIR}; curl -O ${FLINK_JOB_JAR_URI}"]
2 changes: 1 addition & 1 deletion controllers/flinkcluster/flinkcluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func (handler *FlinkClusterHandler) reconcile(ctx context.Context,

log.Info("---------- 3. Compute the desired state ----------")

*desired = getDesiredClusterState(observed)
*desired = *getDesiredClusterState(observed)
if desired.ConfigMap != nil {
log.Info("Desired state", "ConfigMap", *desired.ConfigMap)
} else {
Expand Down
Loading