jerrypeng commented on a change in pull request #8098:
URL: https://github.com/apache/pulsar/pull/8098#discussion_r492890528



##########
File path: 
pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdFunctions.java
##########
@@ -627,6 +627,8 @@ protected void validateFunctionConfigs(FunctionConfig 
functionConfig) {
         protected Integer instanceIdOffset = 0;
         @Parameter(names = "--runtime", description = "either THREAD or 
PROCESS. Only applies for Java functions")
         protected String runtime;
+        @Parameter(names = "--environment-based-secrets-provider", description 
= "Should we use environment based secret provider")

Review comment:
       I think there is already too arguments for the CLI.  Lets try to create 
something more generic.  Instead of creating an argument for a specific 
provider, can we create an argument to allow users to specify the secret 
provider type?  In the future, if we add more providers, I don't want to keep 
add one-of arguments.  For example, can we create a enum?
   
   Enum SecretsProviderType {
   ENV,
   DEFAULT,
   ...
   }
   
   based on the enum determine

##########
File path: 
pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdFunctions.java
##########
@@ -627,6 +627,8 @@ protected void validateFunctionConfigs(FunctionConfig 
functionConfig) {
         protected Integer instanceIdOffset = 0;
         @Parameter(names = "--runtime", description = "either THREAD or 
PROCESS. Only applies for Java functions")
         protected String runtime;
+        @Parameter(names = "--environment-based-secrets-provider", description 
= "Should we use environment based secret provider")

Review comment:
       Actually we should just let the user to specify class of the secrets 
configurator to use.  That is simplest and generic.
   
   --secrets-provider-configurator-classname

##########
File path: 
pulsar-functions/localrun/src/main/java/org/apache/pulsar/functions/LocalRunner.java
##########
@@ -418,11 +428,24 @@ private void 
startThreadedMode(org.apache.pulsar.functions.proto.Function.Functi
                                            int parallelism, int 
instanceIdOffset, String serviceUrl,
                                            String stateStorageServiceUrl, 
AuthenticationConfig authConfig,
                                            String userCodeFile) throws 
Exception {
+        SecretsProvider secretsProvider;
+        if (secretsProviderClassName != null) {
+            if 
(secretsProviderClassName.equals(ClearTextSecretsProvider.class.getName())) {

Review comment:
       Just create an instance using the class name. Use method:
   
   
https://github.com/apache/pulsar/blob/master/pulsar-common/src/main/java/org/apache/pulsar/common/util/Reflections.java#L64

##########
File path: 
pulsar-functions/secrets/src/main/java/org/apache/pulsar/functions/secretsproviderconfigurator/NameAndConfigBasedSecretsProviderConfigurator.java
##########
@@ -0,0 +1,70 @@
+/**
+ * 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.pulsar.functions.secretsproviderconfigurator;
+
+import com.google.gson.reflect.TypeToken;
+import io.kubernetes.client.openapi.models.V1PodSpec;
+import org.apache.pulsar.functions.proto.Function;
+import 
org.apache.pulsar.functions.secretsprovider.EnvironmentBasedSecretsProvider;
+
+import java.lang.reflect.Type;
+import java.util.Map;
+
+/**
+ * This file defines the SecretsProviderConfigurator that will be used by 
default for running in Kubernetes.

Review comment:
       These comments don't make sense for this class

##########
File path: 
pulsar-functions/secrets/src/main/java/org/apache/pulsar/functions/secretsproviderconfigurator/NameAndConfigBasedSecretsProviderConfigurator.java
##########
@@ -0,0 +1,70 @@
+/**
+ * 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.pulsar.functions.secretsproviderconfigurator;
+
+import com.google.gson.reflect.TypeToken;
+import io.kubernetes.client.openapi.models.V1PodSpec;
+import org.apache.pulsar.functions.proto.Function;
+import 
org.apache.pulsar.functions.secretsprovider.EnvironmentBasedSecretsProvider;
+
+import java.lang.reflect.Type;
+import java.util.Map;
+
+/**
+ * This file defines the SecretsProviderConfigurator that will be used by 
default for running in Kubernetes.
+ * As such this implementation is strictly when workers are configured to use 
kubernetes runtime.
+ * We use kubernetes in built secrets and bind them as environment variables 
within the function container
+ * to ensure that the secrets are available to the function at runtime. Then 
we plug in the
+ * EnvironmentBasedSecretsConfig as the secrets provider who knows how to read 
these environment variables.
+ */
+public class NameAndConfigBasedSecretsProviderConfigurator implements 
SecretsProviderConfigurator {

Review comment:
       There is not really point to have this class. Just refactor 
ProcessRuntime to take in a SecretsProvider like ThreadRuntime




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