gaborgsomogyi commented on code in PR #712:
URL:
https://github.com/apache/flink-kubernetes-operator/pull/712#discussion_r1415671557
##########
helm/flink-kubernetes-operator/templates/flink-operator.yaml:
##########
@@ -130,6 +141,10 @@ spec:
- name: flink-artifacts-volume
mountPath: /opt/flink/artifacts
{{- end }}
+ {{- if .Values.tls.create }}
+ - name: flink-operator-cert-secret
+ mountPath: /opt/flink/artifacts/operator-cert
Review Comment:
AFAIK when there is an overlap in the mounts then one of them is going to be
hidden (Either `/opt/flink/artifacts` or `/opt/flink/artifacts/operator-cert`).
Maybe `/opt/flink/certs` would be a better choice.
##########
flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/service/AbstractFlinkService.java:
##########
@@ -1075,4 +1106,59 @@ protected void
updateStatusAfterClusterDeletion(FlinkDeploymentStatus status) {
status.getJobStatus().setState(JobStatus.FINISHED.name());
}
}
+
+ private Configuration getOperatorRestConfig(Configuration origConfig)
throws IOException {
+ Configuration conf = new Configuration(origConfig);
+ EnvUtils.get(EnvUtils.ENV_OPERATOR_TRUSTSTORE_PATH)
+ .ifPresent(
+ path -> {
+ if (Files.notExists(Paths.get(path))) {
+ return;
+ }
+ conf.set(
+ SecurityOptions.SSL_REST_TRUSTSTORE,
+
EnvUtils.getRequired(EnvUtils.ENV_OPERATOR_TRUSTSTORE_PATH));
+ conf.set(
+
SecurityOptions.SSL_REST_TRUSTSTORE_PASSWORD,
+
EnvUtils.getRequired(EnvUtils.ENV_OPERATOR_KEYSTORE_PASSWORD));
+ if
(SecurityOptions.isRestSSLAuthenticationEnabled(conf)
+ &&
EnvUtils.get(EnvUtils.ENV_OPERATOR_KEYSTORE_PATH)
+ .isPresent()) {
+ conf.set(
+ SecurityOptions.SSL_REST_KEYSTORE,
+
EnvUtils.getRequired(EnvUtils.ENV_OPERATOR_KEYSTORE_PATH));
+ conf.set(
+
SecurityOptions.SSL_REST_KEYSTORE_PASSWORD,
+ EnvUtils.getRequired(
+
EnvUtils.ENV_OPERATOR_KEYSTORE_PASSWORD));
+ conf.set(
+ SecurityOptions.SSL_REST_KEY_PASSWORD,
+ EnvUtils.getRequired(
+
EnvUtils.ENV_OPERATOR_KEYSTORE_PASSWORD));
+ } else {
+
conf.removeConfig(SecurityOptions.SSL_REST_KEYSTORE);
+
conf.removeConfig(SecurityOptions.SSL_REST_KEYSTORE_PASSWORD);
+ }
+ conf.removeConfig(SecurityOptions.SSL_TRUSTSTORE);
+
conf.removeConfig(SecurityOptions.SSL_TRUSTSTORE_PASSWORD);
+ conf.removeConfig(SecurityOptions.SSL_KEYSTORE);
+
conf.removeConfig(SecurityOptions.SSL_KEYSTORE_PASSWORD);
+ });
+ return conf;
+ }
+
+ private boolean isValidRuntimeException(Configuration conf,
RuntimeException e) {
+ final Optional<String> trustStorePath =
EnvUtils.get(EnvUtils.ENV_OPERATOR_TRUSTSTORE_PATH);
+ // The ClusterDescriptors always try and create a RestClient from the
config
+ // that would be given to the deployment. When SSL is enabled it will
throw
+ // a ClusterRetrieveException as the operator does not have the certs
where they
+ // would be mounted on the client
+ if (SecurityOptions.isRestSSLEnabled(conf)
+ && trustStorePath.isPresent()
+ && Files.exists(Paths.get(trustStorePath.get()))
+ && e.getCause() instanceof ClusterRetrieveException) {
+ return true;
+ }
+ return false;
Review Comment:
I don't understand this functionality at all🤔 How I can imagine this feature
from high level perspective is the following:
* One configs certs for the operator
* One configs either unsecure or secure connection per job
* Operator picks up the job config
* If unsecure then opens an unsecure REST client
* If secure then opens an secure REST client
* If any connection fails then we shouldn't catch exceptions
If you can elaborate it would be helpful.
##########
flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/service/AbstractFlinkService.java:
##########
@@ -1075,4 +1106,59 @@ protected void
updateStatusAfterClusterDeletion(FlinkDeploymentStatus status) {
status.getJobStatus().setState(JobStatus.FINISHED.name());
}
}
+
+ private Configuration getOperatorRestConfig(Configuration origConfig)
throws IOException {
+ Configuration conf = new Configuration(origConfig);
+ EnvUtils.get(EnvUtils.ENV_OPERATOR_TRUSTSTORE_PATH)
+ .ifPresent(
+ path -> {
+ if (Files.notExists(Paths.get(path))) {
+ return;
+ }
+ conf.set(
+ SecurityOptions.SSL_REST_TRUSTSTORE,
+
EnvUtils.getRequired(EnvUtils.ENV_OPERATOR_TRUSTSTORE_PATH));
+ conf.set(
+
SecurityOptions.SSL_REST_TRUSTSTORE_PASSWORD,
+
EnvUtils.getRequired(EnvUtils.ENV_OPERATOR_KEYSTORE_PASSWORD));
+ if
(SecurityOptions.isRestSSLAuthenticationEnabled(conf)
+ &&
EnvUtils.get(EnvUtils.ENV_OPERATOR_KEYSTORE_PATH)
+ .isPresent()) {
+ conf.set(
+ SecurityOptions.SSL_REST_KEYSTORE,
+
EnvUtils.getRequired(EnvUtils.ENV_OPERATOR_KEYSTORE_PATH));
+ conf.set(
+
SecurityOptions.SSL_REST_KEYSTORE_PASSWORD,
+ EnvUtils.getRequired(
+
EnvUtils.ENV_OPERATOR_KEYSTORE_PASSWORD));
+ conf.set(
+ SecurityOptions.SSL_REST_KEY_PASSWORD,
+ EnvUtils.getRequired(
+
EnvUtils.ENV_OPERATOR_KEYSTORE_PASSWORD));
+ } else {
+
conf.removeConfig(SecurityOptions.SSL_REST_KEYSTORE);
+
conf.removeConfig(SecurityOptions.SSL_REST_KEYSTORE_PASSWORD);
+ }
+ conf.removeConfig(SecurityOptions.SSL_TRUSTSTORE);
+
conf.removeConfig(SecurityOptions.SSL_TRUSTSTORE_PASSWORD);
+ conf.removeConfig(SecurityOptions.SSL_KEYSTORE);
+
conf.removeConfig(SecurityOptions.SSL_KEYSTORE_PASSWORD);
+ });
+ return conf;
+ }
+
+ private boolean isValidRuntimeException(Configuration conf,
RuntimeException e) {
+ final Optional<String> trustStorePath =
EnvUtils.get(EnvUtils.ENV_OPERATOR_TRUSTSTORE_PATH);
+ // The ClusterDescriptors always try and create a RestClient from the
config
+ // that would be given to the deployment. When SSL is enabled it will
throw
+ // a ClusterRetrieveException as the operator does not have the certs
where they
+ // would be mounted on the client
+ if (SecurityOptions.isRestSSLEnabled(conf)
+ && trustStorePath.isPresent()
+ && Files.exists(Paths.get(trustStorePath.get()))
+ && e.getCause() instanceof ClusterRetrieveException) {
+ return true;
+ }
+ return false;
Review Comment:
I don't understand this functionality at all🤔 How I can imagine this feature
from high level perspective is the following:
* One configs certs for the operator
* One configs either unsecure or secure connection per job
* Operator picks up the job config
* If unsecure then opens an unsecure REST client
* If secure then opens an secure REST client
* If any connection fails then we shouldn't catch exceptions
If you can elaborate it would be helpful.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]