pulsar-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] srkukarni commented on a change in pull request #2855: Secretprovider interfaces and some default implementations
Date Sat, 27 Oct 2018 23:53:30 GMT
srkukarni commented on a change in pull request #2855: Secretprovider interfaces and some default
URL: https://github.com/apache/pulsar/pull/2855#discussion_r228730064

 File path: pulsar-functions/secrets/src/main/java/org/apache/pulsar/functions/secretsproviderconfigurator/KubernetesSecretsProviderConfigurator.java
 @@ -0,0 +1,100 @@
+ * 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
+ * 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.Gson;
+import com.google.gson.reflect.TypeToken;
+import io.kubernetes.client.models.V1Container;
+import io.kubernetes.client.models.V1EnvVar;
+import io.kubernetes.client.models.V1EnvVarSource;
+import io.kubernetes.client.models.V1SecretKeySelector;
+import org.apache.commons.lang3.StringUtils;
+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
+ * We use kubernetes in built secrets and bind them as environment variables within the function
+ * to ensure that the secrets are availble to the function at runtime. Then we plug in the
+ * EnvironmentBasedSecretsConfig as the secrets provider who knows how to read these environment
+ */
+public class KubernetesSecretsProviderConfigurator implements SecretsProviderConfigurator
+    @Override
+    public String getSecretsProviderClassName(Function.FunctionDetails functionDetails) {
+        switch (functionDetails.getRuntime()) {
+            case JAVA:
+                return EnvironmentBasedSecretsProvider.class.getName();
+            case PYTHON:
+                return "secretsprovider.EnvironmentBasedSecretsProvider";
+            default:
+                throw new RuntimeException("Unknown function runtime " + functionDetails.getRuntime());
+        }
+    }
+    @Override
+    public Map<String, String> getSecretsProviderConfig(Function.FunctionDetails functionDetails)
+        return null;
+    }
+    // Kubernetes secrets can be exposed as volume mounts or as environment variables in
the pods. We are currently using the
+    // environment variables way. Essentially the secretName/secretPath is attached as secretRef
to the environment variables
+    // of a pod and kubernetes magically makes the secret pointed to by this combination
available as a env variable.
+    @Override
+    public void configureKubernetesRuntimeSecretsProvider(V1Container container, Function.FunctionDetails
functionDetails) {
 Review comment:
   Not sure about that. The provider doesn't really know how the podspec is being structured
by the runtime. For instance in the current implementation, there are two containers being
created and this provider will not know about those details. All it needs to know is the container
where the secrets need to be attached

This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:

With regards,
Apache Git Services

View raw message