addisonj commented on a change in pull request #5400: [functions] Allow 
functions to pass runtime specific options
URL: https://github.com/apache/pulsar/pull/5400#discussion_r344417791
 
 

 ##########
 File path: 
pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/BasicKubernetesManifestCustomizer.java
 ##########
 @@ -0,0 +1,107 @@
+/**
+ * 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.runtime;
+
+import io.kubernetes.client.models.*;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+
+import com.google.gson.Gson;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.pulsar.functions.proto.Function;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * An implementation of the {@link KubernetesManifestCustomizer} that allows
+ * for some basic customization of namespace, labels, annotations, node 
selectors,
+ * and tolerations.
+ *
+ * With the right RBAC permissions for the functions worker, these should be 
safe to
+ * modify (for example, a service account must have permissions in the 
specified jobNamespace)
+ *
+ */
+public class BasicKubernetesManifestCustomizer implements 
KubernetesManifestCustomizer {
+
+    @Getter
+    @Setter
+    @NoArgsConstructor
+    static private class RuntimeOpts {
+        private String jobNamespace;
+        private Map<String, String> extraLabels;
+        private Map<String, String> extraAnnotations;
+        private Map<String, String> nodeSelectorLabels;
+        private List<V1Toleration> tolerations;
+    }
+
+    private RuntimeOpts opts;
+
+    @Override
+    public void init(Function.FunctionDetails funcDetails, String 
staticConfig) {
 
 Review comment:
   Not in the implementation, but our use case for this is basically to have 
certain tenants to be mapped to specific namespaces and what not, so in that 
case, we could pass some configuration that would contain this mapping (rather 
than having to hardcode it in our implementation)

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to