tillrohrmann commented on a change in pull request #12899:
URL: https://github.com/apache/flink/pull/12899#discussion_r471985089



##########
File path: 
flink-kubernetes/src/main/java/org/apache/flink/kubernetes/configuration/KubernetesConfigOptions.java
##########
@@ -221,6 +221,21 @@
        /** Defines the configuration key of that external resource in 
Kubernetes. This is used as a suffix in an actual config. */
        public static final String 
EXTERNAL_RESOURCE_KUBERNETES_CONFIG_KEY_SUFFIX = "kubernetes.config-key";
 
+       public static final ConfigOption<Map<String, String>> 
KUBERNETES_SECRETS =
+               key("kubernetes.secrets")
+                       .mapType()
+                       .noDefaultValue()
+                       .withDescription("The user-specified secrets that will 
be mounted into Flink container. The value should be in " +
+                               "the form of 
foo:/opt/secrets-foo,bar:/opt/secrets-bar.");
+
+       public static final ConfigOption<List<Map<String, String>>> 
KUBERNETES_ENV_SECRET_KEY_REF =
+               key("kubernetes.env.secretKeyRef")
+                       .mapType()
+                       .asList()
+                       .noDefaultValue()
+                       .withDescription("The user-specified secrets to set env 
variables in Flink container. The value should be in " +
+                               "the form of 
env:FOO_ENV,secret:foo_secret,key:foo_key;env:BAR_ENV,secret:bar_secret,key:bar_key.");

Review comment:
       Same here with `TextElement.code` and 
`env:FOO_ENV,secret:foo_secret,key:foo_key;env:BAR_ENV,secret:bar_secret,key:bar_key`

##########
File path: 
flink-kubernetes/src/main/java/org/apache/flink/kubernetes/configuration/KubernetesConfigOptions.java
##########
@@ -221,6 +221,21 @@
        /** Defines the configuration key of that external resource in 
Kubernetes. This is used as a suffix in an actual config. */
        public static final String 
EXTERNAL_RESOURCE_KUBERNETES_CONFIG_KEY_SUFFIX = "kubernetes.config-key";
 
+       public static final ConfigOption<Map<String, String>> 
KUBERNETES_SECRETS =
+               key("kubernetes.secrets")
+                       .mapType()
+                       .noDefaultValue()
+                       .withDescription("The user-specified secrets that will 
be mounted into Flink container. The value should be in " +
+                               "the form of 
foo:/opt/secrets-foo,bar:/opt/secrets-bar.");

Review comment:
       ```suggestion
                        .withDescription(
                            Description.builder()
                                .text("The user-specified secrets that will be 
mounted into Flink container. The value should be in " +
                                        "the form of %s.", 
TextElement.code("foo:/opt/secrets-foo,bar:/opt/secrets-bar"))
                                    .build());
   ```

##########
File path: 
flink-kubernetes/src/main/java/org/apache/flink/kubernetes/kubeclient/resources/KubernetesSecretEnvVar.java
##########
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.kubernetes.kubeclient.resources;
+
+import io.fabric8.kubernetes.api.model.EnvVar;
+import io.fabric8.kubernetes.api.model.EnvVarBuilder;
+
+import java.util.Map;
+
+/**
+ * Represent EnvVar resource in kubernetes.

Review comment:
       ```suggestion
    * Represents EnvVar resource in Kubernetes.
   ```

##########
File path: 
flink-kubernetes/src/main/java/org/apache/flink/kubernetes/kubeclient/decorators/EnvSecretsDecorator.java
##########
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.kubernetes.kubeclient.decorators;
+
+import org.apache.flink.kubernetes.kubeclient.FlinkPod;
+import 
org.apache.flink.kubernetes.kubeclient.parameters.AbstractKubernetesParameters;
+import org.apache.flink.kubernetes.kubeclient.resources.KubernetesSecretEnvVar;
+
+import io.fabric8.kubernetes.api.model.Container;
+import io.fabric8.kubernetes.api.model.ContainerBuilder;
+import io.fabric8.kubernetes.api.model.EnvVar;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+import static org.apache.flink.util.Preconditions.checkNotNull;
+
+/**
+ * support setting environment variables via Secrets.

Review comment:
       ```suggestion
    * Support setting environment variables via Secrets.
   ```

##########
File path: 
flink-kubernetes/src/main/java/org/apache/flink/kubernetes/kubeclient/decorators/MountSecretsDecorator.java
##########
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.kubernetes.kubeclient.decorators;
+
+import org.apache.flink.kubernetes.kubeclient.FlinkPod;
+import 
org.apache.flink.kubernetes.kubeclient.parameters.AbstractKubernetesParameters;
+
+import io.fabric8.kubernetes.api.model.Container;
+import io.fabric8.kubernetes.api.model.ContainerBuilder;
+import io.fabric8.kubernetes.api.model.Pod;
+import io.fabric8.kubernetes.api.model.PodBuilder;
+import io.fabric8.kubernetes.api.model.Volume;
+import io.fabric8.kubernetes.api.model.VolumeBuilder;
+import io.fabric8.kubernetes.api.model.VolumeMount;
+import io.fabric8.kubernetes.api.model.VolumeMountBuilder;
+
+import static org.apache.flink.util.Preconditions.checkNotNull;
+
+/**
+ * support mounting Secrets on the JobManager or TaskManager pod..

Review comment:
       ```suggestion
    * Support mounting Secrets on the JobManager or TaskManager pod..
   ```

##########
File path: 
flink-kubernetes/src/main/java/org/apache/flink/kubernetes/kubeclient/parameters/KubernetesParameters.java
##########
@@ -110,4 +110,14 @@
         * The local directory to locate the custom Hadoop configuration.
         */
        Optional<String> getLocalHadoopConfigurationDirectory();
+
+       /**
+        * A collection of Secrets and path that are mounted to the JobManager 
and TaskManager Container(s).

Review comment:
       ```suggestion
         * A collection of secret and path pairs that are mounted to the 
JobManager and TaskManager container(s).
   ```

##########
File path: 
flink-kubernetes/src/main/java/org/apache/flink/kubernetes/kubeclient/parameters/KubernetesParameters.java
##########
@@ -110,4 +110,14 @@
         * The local directory to locate the custom Hadoop configuration.
         */
        Optional<String> getLocalHadoopConfigurationDirectory();
+
+       /**
+        * A collection of Secrets and path that are mounted to the JobManager 
and TaskManager Container(s).
+        */
+       Map<String, String> getSecretNamesToMountPaths();
+
+       /**
+        * A collection of customized environments that are attached to the 
JobManager and TaskManager Container(s).

Review comment:
       ```suggestion
         * A collection of customized environments that are attached to the 
JobManager and TaskManager container(s).
   ```

##########
File path: 
flink-kubernetes/src/main/java/org/apache/flink/kubernetes/configuration/KubernetesConfigOptions.java
##########
@@ -221,6 +221,21 @@
        /** Defines the configuration key of that external resource in 
Kubernetes. This is used as a suffix in an actual config. */
        public static final String 
EXTERNAL_RESOURCE_KUBERNETES_CONFIG_KEY_SUFFIX = "kubernetes.config-key";
 
+       public static final ConfigOption<Map<String, String>> 
KUBERNETES_SECRETS =
+               key("kubernetes.secrets")
+                       .mapType()
+                       .noDefaultValue()
+                       .withDescription("The user-specified secrets that will 
be mounted into Flink container. The value should be in " +
+                               "the form of 
foo:/opt/secrets-foo,bar:/opt/secrets-bar.");
+
+       public static final ConfigOption<List<Map<String, String>>> 
KUBERNETES_ENV_SECRET_KEY_REF =
+               key("kubernetes.env.secretKeyRef")
+                       .mapType()
+                       .asList()
+                       .noDefaultValue()
+                       .withDescription("The user-specified secrets to set env 
variables in Flink container. The value should be in " +
+                               "the form of 
env:FOO_ENV,secret:foo_secret,key:foo_key;env:BAR_ENV,secret:bar_secret,key:bar_key.");

Review comment:
       To me it is not very clear how to use this configuration option without 
more context or even a small example which we could add to 
`native_kubernetes.md`. Moreover, we should add a link to 
https://kubernetes.io/docs/concepts/configuration/secret/ for reference.

##########
File path: 
flink-kubernetes/src/main/java/org/apache/flink/kubernetes/configuration/KubernetesConfigOptions.java
##########
@@ -221,6 +221,21 @@
        /** Defines the configuration key of that external resource in 
Kubernetes. This is used as a suffix in an actual config. */
        public static final String 
EXTERNAL_RESOURCE_KUBERNETES_CONFIG_KEY_SUFFIX = "kubernetes.config-key";
 
+       public static final ConfigOption<Map<String, String>> 
KUBERNETES_SECRETS =
+               key("kubernetes.secrets")
+                       .mapType()
+                       .noDefaultValue()
+                       .withDescription("The user-specified secrets that will 
be mounted into Flink container. The value should be in " +
+                               "the form of 
foo:/opt/secrets-foo,bar:/opt/secrets-bar.");

Review comment:
       I think it would be good to add a bit more description (might even want 
to add this description to `native_kubernetes.md`) for how to configure the 
secrets. At least we should add a link to the K8s documentation 
https://kubernetes.io/docs/concepts/configuration/secret/.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to