Class KubernetesRuntime
- java.lang.Object
-
- org.apache.pulsar.functions.runtime.kubernetes.KubernetesRuntime
-
- All Implemented Interfaces:
Runtime
public class KubernetesRuntime extends java.lang.Object implements Runtime
Kubernetes based runtime for running functions. This runtime provides the usual methods to start/stop/getfunctionstatus interfaces to control the kubernetes job running function. We first create a headless service and then a statefulset for starting function pods Each function instance runs as a pod itself. The reason using statefulset as opposed to a regular deployment is that functions require a unique instance_id for each instance. The service abstraction is used for getting functionstatus.
-
-
Field Summary
Fields Modifier and Type Field Description static java.util.regex.PatternVALID_POD_NAME_REGEX
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static java.lang.StringcreateJobName(org.apache.pulsar.functions.proto.Function.FunctionDetails functionDetails, java.lang.String jobName)voiddeleteService()voiddeleteStatefulSet()static voiddoChecks(org.apache.pulsar.functions.proto.Function.FunctionDetails functionDetails, java.lang.String overridenJobName)java.util.concurrent.CompletableFuture<org.apache.pulsar.functions.proto.InstanceCommunication.MetricsData>getAndResetMetrics()java.lang.ThrowablegetDeathException()protected java.util.List<java.lang.String>getExecutorCommand()java.util.concurrent.CompletableFuture<org.apache.pulsar.functions.proto.InstanceCommunication.FunctionStatus>getFunctionStatus(int instanceId)java.util.concurrent.CompletableFuture<org.apache.pulsar.functions.proto.InstanceCommunication.MetricsData>getMetrics(int instanceId)java.lang.StringgetPrometheusMetrics()booleanisAlive()voidjoin()voidreinitialize()java.util.concurrent.CompletableFuture<java.lang.Void>resetMetrics()voidstart()The core logic that creates a service first followed by statefulset.voidstop()
-
-
-
Method Detail
-
start
public void start() throws java.lang.ExceptionThe core logic that creates a service first followed by statefulset.
-
reinitialize
public void reinitialize()
- Specified by:
reinitializein interfaceRuntime
-
join
public void join() throws java.lang.Exception
-
stop
public void stop() throws java.lang.Exception
-
getDeathException
public java.lang.Throwable getDeathException()
- Specified by:
getDeathExceptionin interfaceRuntime
-
getFunctionStatus
public java.util.concurrent.CompletableFuture<org.apache.pulsar.functions.proto.InstanceCommunication.FunctionStatus> getFunctionStatus(int instanceId)
- Specified by:
getFunctionStatusin interfaceRuntime
-
getAndResetMetrics
public java.util.concurrent.CompletableFuture<org.apache.pulsar.functions.proto.InstanceCommunication.MetricsData> getAndResetMetrics()
- Specified by:
getAndResetMetricsin interfaceRuntime
-
resetMetrics
public java.util.concurrent.CompletableFuture<java.lang.Void> resetMetrics()
- Specified by:
resetMetricsin interfaceRuntime
-
getMetrics
public java.util.concurrent.CompletableFuture<org.apache.pulsar.functions.proto.InstanceCommunication.MetricsData> getMetrics(int instanceId)
- Specified by:
getMetricsin interfaceRuntime
-
getPrometheusMetrics
public java.lang.String getPrometheusMetrics() throws java.io.IOException- Specified by:
getPrometheusMetricsin interfaceRuntime- Throws:
java.io.IOException
-
deleteStatefulSet
public void deleteStatefulSet() throws java.lang.InterruptedException- Throws:
java.lang.InterruptedException
-
deleteService
public void deleteService() throws java.lang.InterruptedException- Throws:
java.lang.InterruptedException
-
getExecutorCommand
protected java.util.List<java.lang.String> getExecutorCommand()
-
createJobName
public static java.lang.String createJobName(org.apache.pulsar.functions.proto.Function.FunctionDetails functionDetails, java.lang.String jobName)
-
doChecks
public static void doChecks(org.apache.pulsar.functions.proto.Function.FunctionDetails functionDetails, java.lang.String overridenJobName)
-
-