diff --git a/Makefile b/Makefile index bdb1fd7c..c21ba582 100644 --- a/Makefile +++ b/Makefile @@ -158,8 +158,10 @@ build-local-certs: -out ${TMPDIR}/k8s-webhook-server/serving-certs/tls.crt -subj "/CN=localhost" \ -extensions san -config <(echo '[req]'; echo 'distinguished_name=req'; echo '[san]'; echo 'subjectAltName=DNS:host.docker.internal') +K8S_LOCAL_CONTEXT ?= docker-desktop + use-local-context: - kubectl config use docker-desktop + kubectl config use $(K8S_LOCAL_CONTEXT) install-local: use-local-context kustomize manifests $(KUSTOMIZE) build config/local | kubectl apply --server-side --force-conflicts -f - >/dev/null diff --git a/apis/risingwave/v1alpha1/risingwave_types.go b/apis/risingwave/v1alpha1/risingwave_types.go index 6f76d525..44db65e9 100644 --- a/apis/risingwave/v1alpha1/risingwave_types.go +++ b/apis/risingwave/v1alpha1/risingwave_types.go @@ -110,6 +110,10 @@ type RisingWaveSpec struct { // +kubebuilder:default=false EnableEmbeddedServingMode *bool `json:"enableEmbeddedServingMode,omitempty"` + // Flag to control whether to enable advertising with IP. If enabled, the meta and compute nodes will be advertised + // with their IP addresses. This is useful when one wants to avoid the DNS resolution overhead and latency. + EnableAdvertisingWithIP *bool `json:"enableAdvertisingWithIP,omitempty"` + // Image for RisingWave component. Image string `json:"image"` diff --git a/apis/risingwave/v1alpha1/zz_generated.deepcopy.go b/apis/risingwave/v1alpha1/zz_generated.deepcopy.go index ba6f62c3..12f624ce 100644 --- a/apis/risingwave/v1alpha1/zz_generated.deepcopy.go +++ b/apis/risingwave/v1alpha1/zz_generated.deepcopy.go @@ -1220,6 +1220,11 @@ func (in *RisingWaveSpec) DeepCopyInto(out *RisingWaveSpec) { *out = new(bool) **out = **in } + if in.EnableAdvertisingWithIP != nil { + in, out := &in.EnableAdvertisingWithIP, &out.EnableAdvertisingWithIP + *out = new(bool) + **out = **in + } in.AdditionalFrontendServiceMetadata.DeepCopyInto(&out.AdditionalFrontendServiceMetadata) in.MetaStore.DeepCopyInto(&out.MetaStore) in.StateStore.DeepCopyInto(&out.StateStore) diff --git a/config/crd/bases/risingwave.risingwavelabs.com_risingwaves.yaml b/config/crd/bases/risingwave.risingwavelabs.com_risingwaves.yaml index ca097564..64e47a46 100644 --- a/config/crd/bases/risingwave.risingwavelabs.com_risingwaves.yaml +++ b/config/crd/bases/risingwave.risingwavelabs.com_risingwaves.yaml @@ -30348,6 +30348,11 @@ spec: type: boolean type: object type: object + enableAdvertisingWithIP: + description: |- + Flag to control whether to enable advertising with IP. If enabled, the meta and compute nodes will be advertised + with their IP addresses. This is useful when one wants to avoid the DNS resolution overhead and latency. + type: boolean enableDefaultServiceMonitor: description: |- Flag to indicate if a default ServiceMonitor (from Prometheus operator) should be created by the controller. diff --git a/config/risingwave-operator-test.yaml b/config/risingwave-operator-test.yaml index a21aeb37..65ff9ec3 100644 --- a/config/risingwave-operator-test.yaml +++ b/config/risingwave-operator-test.yaml @@ -30365,6 +30365,11 @@ spec: type: boolean type: object type: object + enableAdvertisingWithIP: + description: |- + Flag to control whether to enable advertising with IP. If enabled, the meta and compute nodes will be advertised + with their IP addresses. This is useful when one wants to avoid the DNS resolution overhead and latency. + type: boolean enableDefaultServiceMonitor: description: |- Flag to indicate if a default ServiceMonitor (from Prometheus operator) should be created by the controller. diff --git a/config/risingwave-operator.yaml b/config/risingwave-operator.yaml index ef44388e..82c3a055 100644 --- a/config/risingwave-operator.yaml +++ b/config/risingwave-operator.yaml @@ -30365,6 +30365,11 @@ spec: type: boolean type: object type: object + enableAdvertisingWithIP: + description: |- + Flag to control whether to enable advertising with IP. If enabled, the meta and compute nodes will be advertised + with their IP addresses. This is useful when one wants to avoid the DNS resolution overhead and latency. + type: boolean enableDefaultServiceMonitor: description: |- Flag to indicate if a default ServiceMonitor (from Prometheus operator) should be created by the controller. diff --git a/docs/general/api.md b/docs/general/api.md index c237a722..c8b82044 100644 --- a/docs/general/api.md +++ b/docs/general/api.md @@ -618,6 +618,18 @@ with embedded serving node enabled, and the compute nodes will serve streaming w +enableAdvertisingWithIP
+ +bool + + + +

Flag to control whether to enable advertising with IP. If enabled, the meta and compute nodes will be advertised +with their IP addresses. This is useful when one wants to avoid the DNS resolution overhead and latency.

+ + + + image
string @@ -4537,6 +4549,18 @@ with embedded serving node enabled, and the compute nodes will serve streaming w +enableAdvertisingWithIP
+ +bool + + + +

Flag to control whether to enable advertising with IP. If enabled, the meta and compute nodes will be advertised +with their IP addresses. This is useful when one wants to avoid the DNS resolution overhead and latency.

+ + + + image
string diff --git a/pkg/factory/risingwave_object_factory.go b/pkg/factory/risingwave_object_factory.go index 889764a4..9b834b40 100644 --- a/pkg/factory/risingwave_object_factory.go +++ b/pkg/factory/risingwave_object_factory.go @@ -533,6 +533,13 @@ func (f *RisingWaveObjectFactory) coreEnvsForMeta() []corev1.EnvVar { } func (f *RisingWaveObjectFactory) envsForMetaArgs() []corev1.EnvVar { + var advertiseAddr string + if ptr.Deref(f.risingwave.Spec.EnableAdvertisingWithIP, false) { + advertiseAddr = fmt.Sprintf("$(POD_IP):%d", consts.MetaServicePort) + } else { + advertiseAddr = fmt.Sprintf("$(POD_NAME).%s:%d", f.componentAddr(consts.ComponentMeta, ""), consts.MetaServicePort) + } + envVars := []corev1.EnvVar{ // Env var for local risectl access. { @@ -549,7 +556,7 @@ func (f *RisingWaveObjectFactory) envsForMetaArgs() []corev1.EnvVar { }, { Name: envs.RWAdvertiseAddr, - Value: fmt.Sprintf("$(POD_NAME).%s:%d", f.componentAddr(consts.ComponentMeta, ""), consts.MetaServicePort), + Value: advertiseAddr, }, { Name: envs.RWPrometheusHost, @@ -645,6 +652,13 @@ func (f *RisingWaveObjectFactory) envsForResourceLimits(cpuLimit int64, memLimit } func (f *RisingWaveObjectFactory) envsForComputeArgs(cpuLimit int64, memLimit int64) []corev1.EnvVar { + var advertiseAddr string + if ptr.Deref(f.risingwave.Spec.EnableAdvertisingWithIP, false) { + advertiseAddr = fmt.Sprintf("$(POD_IP):%d", consts.ComputeServicePort) + } else { + advertiseAddr = fmt.Sprintf("$(POD_NAME).%s:%d", f.componentAddr(consts.ComponentCompute, ""), consts.ComputeServicePort) + } + envVars := []corev1.EnvVar{ { Name: envs.RWConfigPath, @@ -656,7 +670,7 @@ func (f *RisingWaveObjectFactory) envsForComputeArgs(cpuLimit int64, memLimit in }, { Name: envs.RWAdvertiseAddr, - Value: fmt.Sprintf("$(POD_NAME).%s:%d", f.componentAddr(consts.ComponentCompute, ""), consts.ComputeServicePort), + Value: advertiseAddr, }, { Name: envs.RWMetaAddr, diff --git a/pkg/object/risingwave_manager.go b/pkg/object/risingwave_manager.go index 85ecd426..75d668ca 100644 --- a/pkg/object/risingwave_manager.go +++ b/pkg/object/risingwave_manager.go @@ -223,6 +223,11 @@ func (r *RisingWaveReader) IsStandaloneModeEnabled() bool { return ptr.Deref(r.risingwave.Spec.EnableStandaloneMode, false) } +// IsAdvertisingWithIP returns true when the advertising with IP is enabled. +func (r *RisingWaveReader) IsAdvertisingWithIP() bool { + return ptr.Deref(r.risingwave.Spec.EnableAdvertisingWithIP, false) +} + // KeepLock resets the current scale views record in the status with the given array. func (mgr *RisingWaveManager) KeepLock(aliveScaleView []risingwavev1alpha1.RisingWaveScaleViewLock) { mgr.mu.Lock()