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



##########
File path: 
flink-kubernetes/src/main/java/org/apache/flink/kubernetes/kubeclient/decorators/EnvSecretsDecorator.java
##########
@@ -0,0 +1,62 @@
+/*
+ * 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.
+ */
+public class EnvSecretsDecorator extends AbstractKubernetesStepDecorator {
+
+       private final AbstractKubernetesParameters kubernetesComponentConf;
+
+       public EnvSecretsDecorator(AbstractKubernetesParameters 
kubernetesComponentConf) {
+               this.kubernetesComponentConf = 
checkNotNull(kubernetesComponentConf);
+       }
+
+       @Override
+       public FlinkPod decorateFlinkPod(FlinkPod flinkPod) {
+               final Container basicMainContainer = new 
ContainerBuilder(flinkPod.getMainContainer())
+                       .addAllToEnv(getSecretEnvs())
+                       .build();
+
+               return new FlinkPod.Builder(flinkPod)
+                       .withMainContainer(basicMainContainer)
+                       .build();
+       }
+
+       private List<EnvVar> getSecretEnvs() {
+               return kubernetesComponentConf.getEnvironmentsFromSecrets()

Review comment:
       ```suggestion
                return 
kubernetesComponentConf.getEnvironmentsFromSecrets().stream()
   ```

##########
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:
       ```suggestion
                                "the form of 
env:FOO_ENV,secret:foo_secret,key:foo_key;env:BAR_ENV,secret:bar_secret,key:bar_key.");
   ```




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