spec

package
v0.20.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 10, 2024 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Overview

Package spec define the specs

Index

Constants

View Source
const (
	EnvShardID                      = "SHARD_ID"
	FunctionsInstanceClasspath      = "pulsar.functions.instance.classpath"
	DefaultRunnerTag                = "2.10.0.0-rc10"
	DefaultGenericRunnerTag         = "0.1.0"
	DefaultRunnerPrefix             = "streamnative/"
	DefaultRunnerImage              = DefaultRunnerPrefix + "pulsar-all:" + DefaultRunnerTag
	DefaultJavaRunnerImage          = DefaultRunnerPrefix + "pulsar-functions-java-runner:" + DefaultRunnerTag
	DefaultPythonRunnerImage        = DefaultRunnerPrefix + "pulsar-functions-python-runner:" + DefaultRunnerTag
	DefaultGoRunnerImage            = DefaultRunnerPrefix + "pulsar-functions-go-runner:" + DefaultRunnerTag
	DefaultGenericNodejsRunnerImage = DefaultRunnerPrefix + "pulsar-functions-generic-nodejs-runner:" + DefaultGenericRunnerTag
	DefaultGenericPythonRunnerImage = DefaultRunnerPrefix + "pulsar-functions-generic-python-runner:" + DefaultGenericRunnerTag
	DefaultGenericRunnerImage       = DefaultRunnerPrefix + "pulsar-functions-generic-base-runner:" + DefaultGenericRunnerTag
	PulsarAdminExecutableFile       = "/pulsar/bin/pulsar-admin"
	WorkDir                         = "/pulsar/"

	RunnerImageHasPulsarctl = "pulsar-functions-(pulsarctl|sn|generic)-(java|python|go|nodejs|base)-runner"

	PulsarctlExecutableFile = "pulsarctl"
	DownloaderName          = "downloader"
	DownloaderVolume        = "downloader-volume"
	DownloaderImage         = DefaultRunnerPrefix + "pulsarctl:2.10.2.3"
	DownloadDir             = "/pulsar/download"

	CleanupContainerName = "cleanup"

	WindowFunctionConfigKeyName = "__WINDOWCONFIGS__"
	WindowFunctionExecutorClass = "org.apache.pulsar.functions.windowing.WindowFunctionExecutor"

	DefaultForAllowInsecure              = "false"
	DefaultForEnableHostNameVerification = "true"

	AppFunctionMesh   = "function-mesh"
	ComponentSource   = "source"
	ComponentSink     = "sink"
	ComponentFunction = "function"

	PackageNameFunctionPrefix = "function://"
	PackageNameSinkPrefix     = "sink://"
	PackageNameSourcePrefix   = "source://"

	HTTPPrefix  = "http://"
	HTTPSPrefix = "https://"

	AnnotationPrometheusScrape = "prometheus.io/scrape"
	AnnotationPrometheusPort   = "prometheus.io/port"
	AnnotationManaged          = "compute.functionmesh.io/managed"
	AnnotationNeedCleanup      = "compute.functionmesh.io/need-cleanup"

	// if labels contains below, we think it comes from function-mesh-worker-service
	LabelPulsarCluster           = "compute.functionmesh.io/pulsar-cluster"
	LabelPulsarClusterDeprecated = "pulsar-cluster"

	EnvGoFunctionConfigs = "GO_FUNCTION_CONF"

	DefaultRunnerUserID  int64 = 10000
	DefaultRunnerGroupID int64 = 10001

	OAuth2AuthenticationPlugin = "org.apache.pulsar.client.impl.auth.oauth2.AuthenticationOAuth2"
	TokenAuthenticationPlugin  = "org.apache.pulsar.client.impl.auth.AuthenticationToken"

	JavaLogConfigDirectory       = "/pulsar/conf/java-log/"
	JavaLogConfigFileXML         = "java_instance_log4j.xml"
	JavaLogConfigFileYAML        = "java_instance_log4j.yaml"
	DefaultJavaLogConfigPath     = JavaLogConfigDirectory + JavaLogConfigFileXML
	DefaultJavaLogConfigPathYAML = JavaLogConfigDirectory + JavaLogConfigFileYAML
	PythonLogConifgDirectory     = "/pulsar/conf/python-log/"
	PythonLogConfigFile          = "python_instance_logging.ini"
	DefaultPythonLogConfigPath   = PythonLogConifgDirectory + PythonLogConfigFile

	DefaultFilebeatConfig = "/usr/share/filebeat/config/filebeat.yaml"
	DefaultFilebeatImage  = "streamnative/filebeat:v0.6.0-rc7"

	EnvGoFunctionLogLevel = "LOGGING_LEVEL"
)

Variables

View Source
var Configs = DefaultConfigs()
View Source
var GRPCPort = corev1.ContainerPort{
	Name:          "tcp-grpc",
	ContainerPort: 9093,
	Protocol:      corev1.ProtocolTCP,
}
View Source
var MetricsPort = corev1.ContainerPort{
	Name:          "http-metrics",
	ContainerPort: 9094,
	Protocol:      corev1.ProtocolTCP,
}

Functions

func CheckIfHPASpecIsEqual added in v0.6.0

func CheckIfHPASpecIsEqual(spec *autov2.HorizontalPodAutoscalerSpec,
	desiredSpec *autov2.HorizontalPodAutoscalerSpec) bool

func CheckIfHPAV2Beta2SpecIsEqual added in v0.15.0

func CheckIfStatefulSetSpecIsEqual added in v0.6.0

func CheckIfStatefulSetSpecIsEqual(spec *appsv1.StatefulSetSpec, desiredSpec *appsv1.StatefulSetSpec) bool

func IsManaged

func IsManaged(object metav1.Object) bool

func MakeFunctionCleanUpJob added in v0.14.0

func MakeFunctionCleanUpJob(function *v1alpha1.Function) *v1.Job

func MakeFunctionComponent

func MakeFunctionComponent(functionName string, mesh *v1alpha1.FunctionMesh,
	spec *v1alpha1.FunctionSpec) *v1alpha1.Function

func MakeFunctionHPA

func MakeFunctionHPA(function *v1alpha1.Function) *autov2.HorizontalPodAutoscaler

func MakeFunctionObjectMeta

func MakeFunctionObjectMeta(function *v1alpha1.Function) *metav1.ObjectMeta

func MakeFunctionService

func MakeFunctionService(function *v1alpha1.Function) *corev1.Service

func MakeFunctionStatefulSet

func MakeFunctionStatefulSet(function *v1alpha1.Function) *appsv1.StatefulSet

func MakeGenericFunctionCommand added in v0.18.0

func MakeGenericFunctionCommand(downloadPath, functionFile, language, clusterName, details, uid string, authProvided, tlsProvided bool, secretMaps map[string]v1alpha1.SecretRef,
	state *v1alpha1.Stateful,
	tlsConfig TLSConfig, authConfig *v1alpha1.AuthConfig) []string

func MakeGoFunctionCommand

func MakeGoFunctionCommand(downloadPath, goExecFilePath string, function *v1alpha1.Function) []string

func MakeHeadlessServiceName

func MakeHeadlessServiceName(serviceName string) string

MakeHeadlessServiceName changes the name of service to headless style

func MakeJavaFunctionCommand

func MakeJavaFunctionCommand(downloadPath, packageFile, name, clusterName, generateLogConfigCommand, logLevel, details, extraDependenciesDir, uid string,
	javaOpts []string, hasPulsarctl, hasWget, authProvided, tlsProvided bool, secretMaps map[string]v1alpha1.SecretRef,
	state *v1alpha1.Stateful,
	tlsConfig TLSConfig, authConfig *v1alpha1.AuthConfig,
	maxPendingAsyncRequests *int32, logConfigFileName string) []string

func MakeLivenessProbe added in v0.9.0

func MakeLivenessProbe(liveness *v1alpha1.Liveness) *corev1.Probe

func MakeMetricsFromBuiltinHPARules

func MakeMetricsFromBuiltinHPARules(builtinRules []v1alpha1.BuiltinHPARule) []autov2.MetricSpec

func MakePythonFunctionCommand

func MakePythonFunctionCommand(downloadPath, packageFile, name, clusterName, generateLogConfigCommand, details, uid string,
	hasPulsarctl, hasWget, authProvided, tlsProvided bool, secretMaps map[string]v1alpha1.SecretRef,
	state *v1alpha1.Stateful,
	tlsConfig TLSConfig, authConfig *v1alpha1.AuthConfig) []string

func MakeService

func MakeService(objectMeta *metav1.ObjectMeta, labels map[string]string) *corev1.Service

func MakeSinkCleanUpJob added in v0.14.0

func MakeSinkCleanUpJob(sink *v1alpha1.Sink) *v1.Job

func MakeSinkCommand

func MakeSinkCommand(sink *v1alpha1.Sink) []string

func MakeSinkComponent

func MakeSinkComponent(sinkName string, mesh *v1alpha1.FunctionMesh, spec *v1alpha1.SinkSpec) *v1alpha1.Sink

func MakeSinkHPA

func MakeSinkHPA(sink *v1alpha1.Sink) *autov2.HorizontalPodAutoscaler

func MakeSinkObjectMeta

func MakeSinkObjectMeta(sink *v1alpha1.Sink) *metav1.ObjectMeta

func MakeSinkService

func MakeSinkService(sink *v1alpha1.Sink) *corev1.Service

func MakeSinkServiceName

func MakeSinkServiceName(sink *v1alpha1.Sink) string

func MakeSinkStatefulSet

func MakeSinkStatefulSet(sink *v1alpha1.Sink) *appsv1.StatefulSet

func MakeSourceCleanUpJob added in v0.14.0

func MakeSourceCleanUpJob(source *v1alpha1.Source) *v1.Job

func MakeSourceComponent

func MakeSourceComponent(sourceName string, mesh *v1alpha1.FunctionMesh, spec *v1alpha1.SourceSpec) *v1alpha1.Source

func MakeSourceHPA

func MakeSourceHPA(source *v1alpha1.Source) *autov2.HorizontalPodAutoscaler

func MakeSourceObjectMeta

func MakeSourceObjectMeta(source *v1alpha1.Source) *metav1.ObjectMeta

func MakeSourceService

func MakeSourceService(source *v1alpha1.Source) *corev1.Service

func MakeSourceStatefulSet

func MakeSourceStatefulSet(source *v1alpha1.Source) *appsv1.StatefulSet

func MakeStatefulSet

func MakeStatefulSet(objectMeta *metav1.ObjectMeta, replicas *int32, downloaderImage string,
	container *corev1.Container, filebeatContainer *corev1.Container,
	volumes []corev1.Volume, labels map[string]string, policy v1alpha1.PodPolicy, pulsar v1alpha1.PulsarMessaging,
	javaRuntime *v1alpha1.JavaRuntime, pythonRuntime *v1alpha1.PythonRuntime,
	goRuntime *v1alpha1.GoRuntime, definedVolumeMounts []corev1.VolumeMount,
	volumeClaimTemplates []corev1.PersistentVolumeClaim,
	persistentVolumeClaimRetentionPolicy *appsv1.StatefulSetPersistentVolumeClaimRetentionPolicy) *appsv1.StatefulSet

func MakeStatefulSetSpec

func MakeStatefulSetSpec(replicas *int32, container *corev1.Container, filebeatContainer *corev1.Container,
	volumes []corev1.Volume, labels map[string]string, policy v1alpha1.PodPolicy,
	serviceName string, downloaderContainer *corev1.Container, volumeClaimTemplates []corev1.PersistentVolumeClaim,
	persistentVolumeClaimRetentionPolicy *appsv1.StatefulSetPersistentVolumeClaimRetentionPolicy) *appsv1.StatefulSetSpec

func MakeVPA added in v0.8.0

func NeedCleanup added in v0.14.0

func NeedCleanup(object metav1.Object) bool

func ParseControllerConfigs

func ParseControllerConfigs(configFilePath string) error

func TriggerCleanup added in v0.14.0

func TriggerCleanup(ctx context.Context, k8sclient client.Client, restClient rest.Interface, config *rest.Config,
	job *v1.Job) error

Types

type BuiltinAutoScaler

type BuiltinAutoScaler interface {
	Metrics() []autov2.MetricSpec
}

func GetBuiltinAutoScaler

func GetBuiltinAutoScaler(builtinRule v1alpha1.BuiltinHPARule) (BuiltinAutoScaler, int)

func NewHPARuleAverageUtilizationCPUPercent

func NewHPARuleAverageUtilizationCPUPercent(cpuPercentage int32) BuiltinAutoScaler

func NewHPARuleAverageUtilizationMemoryPercent

func NewHPARuleAverageUtilizationMemoryPercent(memoryPercentage int32) BuiltinAutoScaler

type ControllerConfigs

type ControllerConfigs struct {
	RunnerImages        RunnerImages      `yaml:"runnerImages,omitempty"`
	ResourceLabels      map[string]string `yaml:"resourceLabels,omitempty"`
	ResourceAnnotations map[string]string `yaml:"resourceAnnotations,omitempty"`
}

func DefaultConfigs

func DefaultConfigs() *ControllerConfigs

type GoFunctionConf

type GoFunctionConf struct {
	PulsarServiceURL string        `json:"pulsarServiceURL" yaml:"pulsarServiceURL"`
	InstanceID       int           `json:"instanceID" yaml:"instanceID"`
	FuncID           string        `json:"funcID" yaml:"funcID"`
	FuncVersion      string        `json:"funcVersion" yaml:"funcVersion"`
	MaxBufTuples     int           `json:"maxBufTuples" yaml:"maxBufTuples"`
	Port             int           `json:"port" yaml:"port"`
	ClusterName      string        `json:"clusterName" yaml:"clusterName"`
	KillAfterIdle    time.Duration `json:"killAfterIdleMs" yaml:"killAfterIdleMs"`
	// function details config
	Tenant               string `json:"tenant" yaml:"tenant"`
	NameSpace            string `json:"nameSpace" yaml:"nameSpace"`
	Name                 string `json:"name" yaml:"name"`
	LogTopic             string `json:"logTopic" yaml:"logTopic"`
	ProcessingGuarantees int32  `json:"processingGuarantees" yaml:"processingGuarantees"`
	SecretsMap           string `json:"secretsMap" yaml:"secretsMap"`
	Runtime              int32  `json:"runtime" yaml:"runtime"`
	AutoACK              bool   `json:"autoAck" yaml:"autoAck"`
	Parallelism          int32  `json:"parallelism" yaml:"parallelism"`
	//source config
	SubscriptionType    int32  `json:"subscriptionType" yaml:"subscriptionType"`
	TimeoutMs           uint64 `json:"timeoutMs" yaml:"timeoutMs"`
	SubscriptionName    string `json:"subscriptionName" yaml:"subscriptionName"`
	CleanupSubscription bool   `json:"cleanupSubscription"  yaml:"cleanupSubscription"`
	//source input specs
	SourceSpecTopic            string `json:"sourceSpecsTopic" yaml:"sourceSpecsTopic"`
	SourceSchemaType           string `json:"sourceSchemaType" yaml:"sourceSchemaType"`
	IsRegexPatternSubscription bool   `json:"isRegexPatternSubscription" yaml:"isRegexPatternSubscription"`
	ReceiverQueueSize          int32  `json:"receiverQueueSize" yaml:"receiverQueueSize"`
	//sink spec config
	SinkSpecTopic  string `json:"sinkSpecsTopic" yaml:"sinkSpecsTopic"`
	SinkSchemaType string `json:"sinkSchemaType" yaml:"sinkSchemaType"`
	//resources config
	CPU  float64 `json:"cpu" yaml:"cpu"`
	RAM  int64   `json:"ram" yaml:"ram"`
	Disk int64   `json:"disk" yaml:"disk"`
	//retryDetails config
	MaxMessageRetries           int32  `json:"maxMessageRetries" yaml:"maxMessageRetries"`
	DeadLetterTopic             string `json:"deadLetterTopic" yaml:"deadLetterTopic"`
	ExpectedHealthCheckInterval int32  `json:"expectedHealthCheckInterval" yaml:"expectedHealthCheckInterval"`
	UserConfig                  string `json:"userConfig" yaml:"userConfig"`
	//metrics config
	MetricsPort int `json:"metricsPort" yaml:"metricsPort"`
}

type HPARuleAverageUtilizationCPUPercent

type HPARuleAverageUtilizationCPUPercent struct {
	// contains filtered or unexported fields
}

func (*HPARuleAverageUtilizationCPUPercent) Metrics

type HPARuleAverageUtilizationResourceMemoryPercent

type HPARuleAverageUtilizationResourceMemoryPercent struct {
	// contains filtered or unexported fields
}

func (*HPARuleAverageUtilizationResourceMemoryPercent) Metrics

type RunnerImages

type RunnerImages struct {
	Java           string            `yaml:"java,omitempty"`
	Python         string            `yaml:"python,omitempty"`
	Go             string            `yaml:"go,omitempty"`
	GenericRuntime map[string]string `yaml:"genericRuntime,omitempty"`
}

type TLSConfig added in v0.4.0

type TLSConfig interface {
	IsEnabled() bool
	AllowInsecureConnection() string
	EnableHostnameVerification() string
	SecretName() string
	SecretKey() string
	HasSecretVolume() bool
	GetMountPath() string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL