You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by gi...@apache.org on 2026/10/12 00:09:50 UTC
(dubbo-kubernetes) branch master updated: feat: The operator has added repo and tag fields (#1042)
This is an automated email from the ASF dual-hosted git repository.
github-actions[bot] pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo-kubernetes.git
The following commit(s) were added to refs/heads/master by this push:
new 39c743c3 feat: The operator has added repo and tag fields (#1042)
39c743c3 is described below
commit 39c743c3cbe0111b0db09f8efabdca12273b4b6e
Author: Jian Zhong <11...@qq.com>
AuthorDate: Mon Oct 12 08:09:44 2026 +0800
feat: The operator has added repo and tag fields (#1042)
---
build.mk | 10 +-
common.mk | 6 +-
dubbod/discovery/cmd/app/cmd.go | 4 -
dubbod/discovery/pkg/bootstrap/management.go | 1304 --------------------
dubbod/discovery/pkg/bootstrap/management_test.go | 88 --
dubbod/discovery/pkg/bootstrap/mesh.go | 1 -
dubbod/discovery/pkg/bootstrap/options.go | 1 -
dubbod/discovery/pkg/bootstrap/server.go | 20 +-
go.mod | 2 +
go.sum | 4 +
manifests/charts/README.md | 2 +-
manifests/charts/dubbod/templates/clusterrole.yaml | 5 -
.../charts/dubbod/templates/configmap-values.yaml | 17 +-
manifests/charts/dubbod/templates/deployment.yaml | 20 +-
manifests/charts/dubbod/templates/service.yaml | 19 -
manifests/charts/dubbod/values.yaml | 20 +-
operator/cmd/validation/validation.go | 3 +
operator/pkg/apis/proto/values_types.proto | 22 +-
operator/pkg/apis/types.go | 4 +
operator/pkg/apis/validation/validation.go | 27 +
operator/pkg/apis/values_types.pb.go | 183 ++-
operator/pkg/render/manifest.go | 45 +
operator/pkg/render/manifest_test.go | 26 +-
operator/pkg/values/map.go | 6 +-
pkg/version/version.go | 11 +
25 files changed, 254 insertions(+), 1596 deletions(-)
diff --git a/build.mk b/build.mk
index 41de4349..b13785e0 100644
--- a/build.mk
+++ b/build.mk
@@ -28,8 +28,14 @@ build: $(addprefix build-,$(BINARIES)) ## Build all binaries into bin/ (host OS/
$(addprefix build-,$(BINARIES)): build-%:
$(GO_BUILD) -o $(BIN_DIR)/$* $(main_path_$*)
-.PHONY: docker-build
-docker-build: ## Build the dubbod container image (override with HUB=/IMAGE_TAG=).
+.PHONY: docker-build docker.dubbod
+docker.dubbod: ## Build a local Linux dubbod image (REPO=/TAG=; BUILD_ALL=false builds only dubbod).
+ $(MAKE) $(addprefix build-,$(if $(filter true,$(BUILD_ALL)),$(BINARIES),dubbod)) GOOS=linux BIN_DIR=$(BIN_DIR)/docker/dubbod
+ rm -rf $(BIN_DIR)/docker/dubbod/legal
+ go run ./tools/licenses -binary dubbod -goos linux -goarch $(GOARCH) -out $(BIN_DIR)/docker/dubbod/legal
+ docker build --platform linux/$(GOARCH) --build-arg BUILD_MODE=prebuilt -f dubbod/discovery/docker/dockerfile.dubbod -t $(IMAGE) $(BIN_DIR)/docker/dubbod
+
+docker-build: ## Build the dubbod container image (override with HUB=/TAG= or IMAGE_TAG=).
docker build -f dubbod/discovery/docker/dockerfile.dubbod -t $(IMAGE) .
.PHONY: clone-examples
diff --git a/common.mk b/common.mk
index b7f9e6d1..2b7b5a64 100644
--- a/common.mk
+++ b/common.mk
@@ -35,11 +35,13 @@ TOOL_BIN ?= $(CURDIR)/$(BIN_DIR)/tools
OPERATOR_APIS_DIR := operator/pkg/apis
HUB ?= dubml
-IMAGE_TAG ?= debug
+TAG ?= debug
+IMAGE_TAG ?= $(TAG)
IMAGE ?= $(HUB)/dubbod:$(IMAGE_TAG)
+BUILD_ALL ?= true
VERSION_PKG := github.com/apache/dubbo-kubernetes/pkg/version
-LDFLAGS ?= -X $(VERSION_PKG).gitTag=$(GIT_VERSION) -X $(VERSION_PKG).buildVersion=$(GIT_VERSION)
+LDFLAGS ?= -X $(VERSION_PKG).gitTag=$(GIT_VERSION) -X $(VERSION_PKG).buildVersion=$(GIT_VERSION) -X $(VERSION_PKG).buildRepo=$(HUB) -X $(VERSION_PKG).buildRepoTag=$(IMAGE_TAG)
GO_BUILD = CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) go build -ldflags "$(LDFLAGS)"
CHARTS := manifests/charts/base manifests/charts/dubbod
diff --git a/dubbod/discovery/cmd/app/cmd.go b/dubbod/discovery/cmd/app/cmd.go
index 0cb11343..097bbe99 100644
--- a/dubbod/discovery/cmd/app/cmd.go
+++ b/dubbod/discovery/cmd/app/cmd.go
@@ -132,10 +132,6 @@ func addFlags(c *cobra.Command) {
"httpAddr",
":8080",
"Discovery service HTTP address")
- c.PersistentFlags().StringVar(&serverArgs.ServerOptions.ManagementAddr,
- "managementAddr",
- ":26080",
- "Management API HTTP address")
c.PersistentFlags().StringVar(&serverArgs.ServerOptions.HTTPSAddr,
"httpsAddr",
":26017",
diff --git a/dubbod/discovery/pkg/bootstrap/management.go b/dubbod/discovery/pkg/bootstrap/management.go
deleted file mode 100644
index 62903229..00000000
--- a/dubbod/discovery/pkg/bootstrap/management.go
+++ /dev/null
@@ -1,1304 +0,0 @@
-// 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 bootstrap
-
-import (
- "bytes"
- "context"
- "encoding/json"
- "fmt"
- "net"
- "net/http"
- "path"
- "sort"
- "strconv"
- "strings"
- "time"
-
- appsv1 "k8s.io/api/apps/v1"
- corev1 "k8s.io/api/core/v1"
- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
- klabels "k8s.io/apimachinery/pkg/labels"
-
- discoverymodel "github.com/apache/dubbo-kubernetes/dubbod/discovery/pkg/model"
- "github.com/apache/dubbo-kubernetes/dubbod/security/pkg/nodeagent/util"
- "github.com/apache/dubbo-kubernetes/pkg/config"
- "github.com/apache/dubbo-kubernetes/pkg/config/constants"
- "github.com/apache/dubbo-kubernetes/pkg/config/schema/gvk"
- "github.com/apache/dubbo-kubernetes/pkg/kube/inject"
- "github.com/apache/dubbo-kubernetes/pkg/log"
- "github.com/apache/dubbo-kubernetes/pkg/monitoring"
- "github.com/apache/dubbo-kubernetes/pkg/util/sets"
- "github.com/apache/dubbo-kubernetes/pkg/version"
- dto "github.com/prometheus/client_model/go"
- sigsk8siogatewayapiapisv1 "sigs.k8s.io/gateway-api/apis/v1"
-)
-
-// managementAPIBase is the HTTP base path of the read-only management API.
-const managementAPIBase = "/api/v1"
-
-type managementOverview struct {
- Product string `json:"product"`
- Version string `json:"version"`
- Cluster string `json:"clusterId"`
- Namespace string `json:"namespace"`
- PodName string `json:"podName,omitempty"`
- Mesh managementOverviewMesh `json:"mesh"`
- Server managementOverviewServer `json:"server"`
- Status managementOverviewStatus `json:"status"`
- Counts managementOverviewCounts `json:"counts"`
- ConfigKinds []managementConfigKind `json:"configKinds"`
- Registries []managementRegistry `json:"registries"`
- Services []managementService `json:"services"`
- Instances []managementDubbodInstance `json:"instances"`
- DataPlane []managementWorkload `json:"dataPlane"`
- // Total running pods per namespace considered for proxyless bootstrap
- // injection.
- DataPlanePods map[string]int `json:"dataPlanePods,omitempty"`
- Routes []managementRoute `json:"routes"`
- XDSClients []managementXDSClient `json:"xdsClients"`
- GatewayInstances []managementDubbodInstance `json:"gatewayInstances"`
- UpdatedAt time.Time `json:"updatedAt"`
-}
-
-// managementWorkload is one injected application pod, joined with the xDS stream it
-// holds open against this control plane (if any).
-type managementWorkload struct {
- Name string `json:"name"`
- Namespace string `json:"namespace"`
- IP string `json:"ip,omitempty"`
- Phase string `json:"phase"`
- Ready bool `json:"ready"`
- ApplicationReady bool `json:"applicationReady"`
- ServiceAccount string `json:"serviceAccount,omitempty"`
- Image string `json:"image,omitempty"`
- XDSAddress string `json:"xdsAddress,omitempty"`
- Restarts int32 `json:"restarts"`
- MTLSModes []string `json:"mtlsModes,omitempty"`
- CertExpiresAt *time.Time `json:"certExpiresAt,omitempty"`
- CertRootActive bool `json:"certRootActive"`
- ConfigError string `json:"configError,omitempty"`
- Connected bool `json:"connected"`
- NodeID string `json:"nodeId,omitempty"`
- NodeType string `json:"nodeType,omitempty"`
- ConnectedAt *time.Time `json:"connectedAt,omitempty"`
- Watched []string `json:"watched,omitempty"`
-}
-
-// managementXDSClient is one live ADS stream opened directly by an application
-// or managed gateway.
-type managementXDSClient struct {
- NodeID string `json:"nodeId"`
- NodeType string `json:"nodeType,omitempty"`
- Peer string `json:"peer,omitempty"`
- ConnectedAt time.Time `json:"connectedAt"`
- Watched []string `json:"watched,omitempty"`
-}
-
-// managementRoute is one HTTPRoute as the control plane has it loaded: which parent it
-// attaches to, and where each rule sends traffic. This is the call graph dubbod
-// has programmed, not observed traffic — nothing in the xDS wire protocol
-// reports which call actually happened.
-type managementRoute struct {
- Name string `json:"name"`
- Namespace string `json:"namespace"`
- Parents []string `json:"parents,omitempty"`
- Hostnames []string `json:"hostnames,omitempty"`
- Rules []managementRouteRule `json:"rules,omitempty"`
-}
-
-type managementRouteRule struct {
- Match string `json:"match,omitempty"`
- Backends []managementRouteBackend `json:"backends,omitempty"`
-}
-
-type managementRouteBackend struct {
- Name string `json:"name"`
- Port int32 `json:"port,omitempty"`
- Weight int32 `json:"weight,omitempty"`
-}
-
-type managementDubbodInstance struct {
- Name string `json:"name"`
- Namespace string `json:"namespace"`
- IP string `json:"ip"`
- IsReady bool `json:"isReady"`
- GatewayClass string `json:"gatewayClass,omitempty"`
- GatewayName string `json:"gatewayName,omitempty"`
- ReadyReplicas int32 `json:"readyReplicas,omitempty"`
- DesiredReplicas int32 `json:"desiredReplicas,omitempty"`
-}
-
-type managementOverviewMesh struct {
- TrustDomain string `json:"trustDomain,omitempty"`
- RootNamespace string `json:"rootNamespace,omitempty"`
- DiscoveryAddress string `json:"discoveryAddress,omitempty"`
-}
-
-type managementOverviewServer struct {
- HTTPAddress string `json:"httpAddress,omitempty"`
- GRPCAddress string `json:"grpcAddress,omitempty"`
- SecureGRPCAddress string `json:"secureGrpcAddress,omitempty"`
- OverviewPath string `json:"overviewPath"`
- MetricsPath string `json:"metricsPath"`
- VersionPath string `json:"versionPath"`
- ReadyPath string `json:"readyPath,omitempty"`
-}
-
-type managementOverviewStatus struct {
- XDSServerReady bool `json:"xdsServerReady"`
- CachesSynced bool `json:"cachesSynced"`
- ServicesSynced bool `json:"servicesSynced"`
- ConfigSynced bool `json:"configSynced"`
- InherentSynced bool `json:"inherentSynced"`
- InjectorReady bool `json:"injectorReady"`
- ValidationReady bool `json:"validationReady"`
-}
-
-type managementOverviewCounts struct {
- Services int `json:"services"`
- EndpointServices int `json:"endpointServices"`
- XDSConnections int `json:"xdsConnections"`
- Registries int `json:"registries"`
- PeerAuthentications int `json:"peerAuthentications"`
- RequestAuthentications int `json:"requestAuthentications"`
- AuthorizationPolicies int `json:"authorizationPolicies"`
- HTTPRoutes int `json:"httpRoutes"`
- GatewayClasses int `json:"gatewayClasses"`
- Gateways int `json:"gateways"`
-}
-
-type managementRegistry struct {
- Provider string `json:"provider"`
- Cluster string `json:"cluster"`
- Synced bool `json:"synced"`
-}
-
-type managementConfigKind struct {
- Kind string `json:"kind"`
- Count int `json:"count"`
- Description string `json:"description"`
-}
-
-type managementService struct {
- Name string `json:"name"`
- Hostname string `json:"hostname"`
- Namespace string `json:"namespace"`
- Registry string `json:"registry"`
- Ports string `json:"ports"`
- Exposure string `json:"exposure"`
- ServiceAccounts int `json:"serviceAccounts"`
- DefaultAddress string `json:"defaultAddress,omitempty"`
- MeshExternal bool `json:"meshExternal"`
- MTLSMode string `json:"mtlsMode,omitempty"`
- MTLSFromPolicy bool `json:"mtlsFromPolicy"`
-}
-
-type managementMetricsResponse struct {
- Families []managementMetricFamily `json:"families"`
- UpdatedAt time.Time `json:"updatedAt"`
-}
-
-type managementMetricFamily struct {
- Name string `json:"name"`
- Help string `json:"help,omitempty"`
- Type string `json:"type"`
- Metrics []managementMetricSample `json:"metrics"`
-}
-
-type managementMetricSample struct {
- Labels map[string]string `json:"labels,omitempty"`
- Value *float64 `json:"value,omitempty"`
- Count *uint64 `json:"count,omitempty"`
- Sum *float64 `json:"sum,omitempty"`
- Buckets []managementMetricBucket `json:"buckets,omitempty"`
-}
-
-type managementMetricBucket struct {
- LE float64 `json:"le"`
- Count uint64 `json:"count"`
-}
-
-type managementLogsResponse struct {
- Kind string `json:"kind"`
- Name string `json:"name"`
- Namespace string `json:"namespace"`
- Pods []managementPodLog `json:"pods"`
- UpdatedAt time.Time `json:"updatedAt"`
-}
-
-type managementPodLog struct {
- Name string `json:"name"`
- Container string `json:"container"`
- Phase string `json:"phase"`
- Ready bool `json:"ready"`
- Logs string `json:"logs,omitempty"`
- Error string `json:"error,omitempty"`
-}
-
-func (s *Server) initManagement() error {
- s.managementMux.HandleFunc(s.managementOverviewPath(), s.managementOverviewHandler)
- s.managementMux.HandleFunc(s.managementLogsPath(), s.managementLogsHandler)
- s.managementMux.HandleFunc(s.managementMetricsPath(), s.managementMetricsHandler)
-
- return nil
-}
-
-func (s *Server) initManagementServer(addr string) error {
- s.addStartFunc("management", func(stop <-chan struct{}) error {
- if addr == "" {
- return nil
- }
-
- listener, err := net.Listen("tcp", addr)
- if err != nil {
- return fmt.Errorf("unable to listen on management socket: %v", err)
- }
- s.managementAddr = listener.Addr().String()
-
- managementServer := &http.Server{
- Addr: listener.Addr().String(),
- Handler: s.managementMux,
- IdleTimeout: 90 * time.Second,
- ReadTimeout: 30 * time.Second,
- }
-
- go func() {
- log.Infof("starting Management Server at %s", listener.Addr())
- if err := managementServer.Serve(listener); err != nil && err != http.ErrServerClosed {
- log.Errorf("error serving Management Server: %v", err)
- }
- }()
-
- go func() {
- <-stop
- if err := managementServer.Close(); err != nil {
- log.Errorf("error closing Management Server: %v", err)
- }
- }()
-
- return nil
- })
-
- return nil
-}
-
-func (s *Server) managementOverviewPath() string {
- return path.Join(managementAPIBase, "overview")
-}
-
-func (s *Server) managementLogsPath() string {
- return path.Join(managementAPIBase, "logs")
-}
-
-func (s *Server) managementMetricsPath() string {
- return path.Join(managementAPIBase, "metrics")
-}
-
-func (s *Server) managementMetricsHandler(writer http.ResponseWriter, request *http.Request) {
- if request.Method != http.MethodGet {
- writer.WriteHeader(http.StatusMethodNotAllowed)
- return
- }
-
- writer.Header().Set("Content-Type", "application/json; charset=utf-8")
- families, err := monitoring.GetRegistry().Gather()
- if err != nil {
- writeManagementError(writer, http.StatusInternalServerError, err.Error())
- return
- }
-
- response := managementMetricsResponse{
- Families: make([]managementMetricFamily, 0, len(families)),
- UpdatedAt: time.Now().UTC(),
- }
- for _, family := range families {
- if family == nil {
- continue
- }
- out := managementMetricFamily{
- Name: family.GetName(),
- Help: family.GetHelp(),
- Type: family.GetType().String(),
- Metrics: make([]managementMetricSample, 0, len(family.GetMetric())),
- }
- for _, metric := range family.GetMetric() {
- out.Metrics = append(out.Metrics, managementMetricSampleFrom(family.GetType(), metric))
- }
- response.Families = append(response.Families, out)
- }
-
- encoder := json.NewEncoder(writer)
- _ = encoder.Encode(response)
-}
-
-func managementMetricSampleFrom(kind dto.MetricType, metric *dto.Metric) managementMetricSample {
- sample := managementMetricSample{}
- if labels := metric.GetLabel(); len(labels) > 0 {
- sample.Labels = make(map[string]string, len(labels))
- for _, pair := range labels {
- sample.Labels[pair.GetName()] = pair.GetValue()
- }
- }
-
- floatPtr := func(v float64) *float64 { return &v }
- uintPtr := func(v uint64) *uint64 { return &v }
-
- switch kind {
- case dto.MetricType_COUNTER:
- sample.Value = floatPtr(metric.GetCounter().GetValue())
- case dto.MetricType_GAUGE:
- sample.Value = floatPtr(metric.GetGauge().GetValue())
- case dto.MetricType_UNTYPED:
- sample.Value = floatPtr(metric.GetUntyped().GetValue())
- case dto.MetricType_HISTOGRAM:
- histogram := metric.GetHistogram()
- sample.Count = uintPtr(histogram.GetSampleCount())
- sample.Sum = floatPtr(histogram.GetSampleSum())
- sample.Buckets = make([]managementMetricBucket, 0, len(histogram.GetBucket()))
- for _, bucket := range histogram.GetBucket() {
- sample.Buckets = append(sample.Buckets, managementMetricBucket{
- LE: bucket.GetUpperBound(),
- Count: bucket.GetCumulativeCount(),
- })
- }
- case dto.MetricType_SUMMARY:
- summary := metric.GetSummary()
- sample.Count = uintPtr(summary.GetSampleCount())
- sample.Sum = floatPtr(summary.GetSampleSum())
- }
- return sample
-}
-
-func (s *Server) managementOverviewHandler(writer http.ResponseWriter, request *http.Request) {
- if request.Method != http.MethodGet {
- writer.WriteHeader(http.StatusMethodNotAllowed)
- return
- }
-
- writer.Header().Set("Content-Type", "application/json; charset=utf-8")
- encoder := json.NewEncoder(writer)
- encoder.SetIndent("", " ")
- _ = encoder.Encode(s.buildManagementOverview())
-}
-
-func (s *Server) managementLogsHandler(writer http.ResponseWriter, request *http.Request) {
- if request.Method != http.MethodGet {
- writer.WriteHeader(http.StatusMethodNotAllowed)
- return
- }
-
- writer.Header().Set("Content-Type", "application/json; charset=utf-8")
- if s.kubeClient == nil {
- writeManagementError(writer, http.StatusServiceUnavailable, "kubernetes client is unavailable")
- return
- }
-
- kind := strings.TrimSpace(request.URL.Query().Get("kind"))
- namespace := strings.TrimSpace(request.URL.Query().Get("namespace"))
- name := strings.TrimSpace(request.URL.Query().Get("name"))
- tailLines := managementLogTailLines(request.URL.Query().Get("tail"))
-
- var response managementLogsResponse
- var err error
- switch kind {
- case "dubbod":
- if namespace == "" {
- namespace = s.namespace
- }
- if name == "" {
- name = "dubbod"
- }
- response, err = s.deploymentLogs(request.Context(), "dubbod", namespace, name, "execute", tailLines)
- case "gateway":
- if namespace == "" || name == "" {
- writeManagementError(writer, http.StatusBadRequest, "gateway logs require namespace and name")
- return
- }
- response, err = s.deploymentLogs(request.Context(), "gateway", namespace, name, "gateway", tailLines)
- default:
- writeManagementError(writer, http.StatusBadRequest, "unknown log kind")
- return
- }
- if err != nil {
- writeManagementError(writer, http.StatusInternalServerError, err.Error())
- return
- }
-
- encoder := json.NewEncoder(writer)
- encoder.SetIndent("", " ")
- _ = encoder.Encode(response)
-}
-
-func writeManagementError(writer http.ResponseWriter, status int, message string) {
- writer.WriteHeader(status)
- _ = json.NewEncoder(writer).Encode(map[string]string{"error": message})
-}
-
-func managementLogTailLines(raw string) int64 {
- const (
- defaultTailLines int64 = 200
- maxTailLines int64 = 2000
- )
- if raw == "" {
- return defaultTailLines
- }
- n, err := strconv.ParseInt(raw, 10, 64)
- if err != nil || n <= 0 {
- return defaultTailLines
- }
- if n > maxTailLines {
- return maxTailLines
- }
- return n
-}
-
-func (s *Server) deploymentLogs(ctx context.Context, kind, namespace, name, preferredContainer string, tailLines int64) (managementLogsResponse, error) {
- deployment, err := s.kubeClient.Kube().AppsV1().Deployments(namespace).Get(ctx, name, metav1.GetOptions{})
- if err != nil {
- return managementLogsResponse{}, fmt.Errorf("get deployment %s/%s: %v", namespace, name, err)
- }
-
- selector, err := metav1.LabelSelectorAsSelector(deployment.Spec.Selector)
- if err != nil {
- return managementLogsResponse{}, fmt.Errorf("build pod selector for deployment %s/%s: %v", namespace, name, err)
- }
- if selector.Empty() {
- selector = klabels.SelectorFromSet(deployment.Spec.Template.Labels)
- }
-
- pods, err := s.kubeClient.Kube().CoreV1().Pods(namespace).List(ctx, metav1.ListOptions{
- LabelSelector: selector.String(),
- })
- if err != nil {
- return managementLogsResponse{}, fmt.Errorf("list pods for deployment %s/%s: %v", namespace, name, err)
- }
- sort.SliceStable(pods.Items, func(i, j int) bool {
- return pods.Items[i].Name < pods.Items[j].Name
- })
-
- out := managementLogsResponse{
- Kind: kind,
- Name: name,
- Namespace: namespace,
- Pods: make([]managementPodLog, 0, len(pods.Items)),
- UpdatedAt: time.Now().UTC(),
- }
- for _, pod := range pods.Items {
- out.Pods = append(out.Pods, s.podLogs(ctx, pod, preferredContainer, tailLines)...)
- }
- return out, nil
-}
-
-func (s *Server) podLogs(ctx context.Context, pod corev1.Pod, preferredContainer string, tailLines int64) []managementPodLog {
- containers := managementLogContainers(pod, preferredContainer)
- out := make([]managementPodLog, 0, len(containers))
- for _, container := range containers {
- entry := managementPodLog{
- Name: pod.Name,
- Container: container,
- Phase: string(pod.Status.Phase),
- Ready: podReady(pod),
- }
- raw, err := s.kubeClient.Kube().CoreV1().Pods(pod.Namespace).GetLogs(pod.Name, &corev1.PodLogOptions{
- Container: container,
- TailLines: &tailLines,
- Timestamps: true,
- }).DoRaw(ctx)
- if err != nil {
- entry.Error = err.Error()
- } else {
- entry.Logs = string(raw)
- }
- out = append(out, entry)
- }
- return out
-}
-
-func managementLogContainers(pod corev1.Pod, preferredContainer string) []string {
- if preferredContainer != "" {
- for _, container := range pod.Spec.Containers {
- if container.Name == preferredContainer {
- return []string{preferredContainer}
- }
- }
- }
- out := make([]string, 0, len(pod.Spec.Containers))
- for _, container := range pod.Spec.Containers {
- out = append(out, container.Name)
- }
- return out
-}
-
-func podReady(pod corev1.Pod) bool {
- for _, cond := range pod.Status.Conditions {
- if cond.Type == corev1.PodReady && cond.Status == corev1.ConditionTrue {
- return true
- }
- }
- return false
-}
-
-func (s *Server) buildManagementOverview() managementOverview {
- meshOverview := managementOverviewMesh{}
- if meshConfig := s.environment.Mesh(); meshConfig != nil {
- meshOverview.TrustDomain = meshConfig.GetTrustDomain()
- meshOverview.RootNamespace = meshConfig.GetRootNamespace()
- if host, port, err := s.environment.GetDiscoveryAddress(); err == nil {
- meshOverview.DiscoveryAddress = string(host) + ":" + port
- }
- }
-
- dataPlane, dataPlanePods := s.buildManagementDataPlane()
-
- registries := s.buildManagementRegistries()
- configKinds := s.buildManagementConfigKinds()
- services := s.buildManagementServices()
- instances := s.buildManagementDubbodInstances()
-
- readyPath := ""
- if s.httpsAddr != "" {
- readyPath = "https://" + localLinkAddress(s.httpsAddr) + "/ready"
- }
- overviewPath := s.managementOverviewPath()
- if s.managementAddr != "" {
- overviewPath = buildLocalHTTPURL(s.managementAddr, s.managementOverviewPath())
- }
- metricsURL := metricsPath
- if s.httpAddr != "" {
- metricsURL = buildLocalHTTPURL(s.httpAddr, metricsPath)
- }
- versionURL := versionPath
- if s.httpAddr != "" {
- versionURL = buildLocalHTTPURL(s.httpAddr, versionPath)
- }
-
- return managementOverview{
- Product: version.Product,
- Version: version.Info.String(),
- Cluster: string(s.clusterID),
- Namespace: s.namespace,
- PodName: s.podName,
- Mesh: meshOverview,
- Server: managementOverviewServer{
- HTTPAddress: s.managementAddr,
- GRPCAddress: s.grpcAddress,
- SecureGRPCAddress: s.secureGrpcAddress,
- OverviewPath: overviewPath,
- MetricsPath: metricsURL,
- VersionPath: versionURL,
- ReadyPath: readyPath,
- },
- Status: managementOverviewStatus{
- XDSServerReady: s.XDSServer.IsServerReady(),
- CachesSynced: s.cachesSynced(),
- ServicesSynced: s.ServiceController().HasSynced(),
- ConfigSynced: s.configController != nil && s.configController.HasSynced(),
- InherentSynced: s.inherentGRPCWorkloadsSynced(),
- InjectorReady: s.kubeClient == nil || s.readinessFlags.InjectorReady.Load(),
- ValidationReady: s.kubeClient == nil || s.readinessFlags.configValidationReady.Load(),
- },
- Counts: managementOverviewCounts{
- Services: len(services),
- EndpointServices: len(s.environment.EndpointIndex.AllServices()),
- XDSConnections: len(s.XDSServer.AllClients()),
- Registries: len(registries),
- PeerAuthentications: s.countConfigs(gvk.PeerAuthentication),
- RequestAuthentications: s.countConfigs(gvk.RequestAuthentication),
- AuthorizationPolicies: s.countConfigs(gvk.AuthorizationPolicy),
- HTTPRoutes: s.countConfigs(gvk.HTTPRoute),
- GatewayClasses: s.countConfigs(gvk.GatewayClass),
- Gateways: s.countConfigs(gvk.KubernetesGateway),
- },
- ConfigKinds: configKinds,
- Registries: registries,
- Services: services,
- Instances: instances,
- Routes: s.buildManagementRoutes(),
- XDSClients: s.buildManagementXDSClients(),
- DataPlane: dataPlane,
- DataPlanePods: dataPlanePods,
- GatewayInstances: s.buildManagementGatewayInstances(),
- UpdatedAt: time.Now().UTC(),
- }
-}
-
-const (
- // managementDubbodPodSelector matches the label the dubbod chart puts on control
- // plane pods (manifests/charts/dubbod/templates/deployment.yaml).
- managementDubbodPodSelector = "app=dubbod"
-
- // Gateway deployments provisioned by dubbod carry these labels; the same
- // pair identifies gateway pods so the data plane listing can skip them.
- managementGatewayNameLabel = "app.kubernetes.io/name"
- managementGatewayNameValue = "gateway"
- managementGatewaySelector = managementGatewayNameLabel + "=" + managementGatewayNameValue + ",app.kubernetes.io/managed-by=dubbod"
-
- // What the native application runtime uses when no PeerAuthentication applies.
- inherentInboundFallbackMTLSMode = "PERMISSIVE"
-)
-
-func (s *Server) buildManagementDubbodInstances() []managementDubbodInstance {
- instances := make([]managementDubbodInstance, 0)
-
- // Off-cluster runs (`go run ./dubbod/discovery/cmd`) have no pods to list, so
- // report this process as-is rather than inventing an address for it.
- if s.kubeClient == nil {
- return append(instances, managementDubbodInstance{
- Name: s.podName,
- Namespace: s.namespace,
- IsReady: true,
- })
- }
-
- pods, err := s.kubeClient.Kube().CoreV1().Pods(s.namespace).List(context.TODO(), metav1.ListOptions{
- LabelSelector: managementDubbodPodSelector,
- })
- if err != nil {
- log.Warnf("management: listing control plane pods in %s: %v", s.namespace, err)
- return instances
- }
-
- for _, pod := range pods.Items {
- instances = append(instances, managementDubbodInstance{
- Name: pod.Name,
- Namespace: pod.Namespace,
- IP: pod.Status.PodIP,
- IsReady: podReady(pod),
- })
- }
-
- sort.SliceStable(instances, func(i, j int) bool { return instances[i].Name < instances[j].Name })
-
- return instances
-}
-
-// xdsTypeShortName turns an xDS type URL into the three-letter name operators
-// actually use. Unknown URLs fall back to their last path segment rather than
-// being dropped, so a new resource type shows up instead of silently vanishing.
-func xdsTypeShortName(typeURL string) string {
- switch {
- case strings.HasSuffix(typeURL, ".Cluster"):
- return "CDS"
- case strings.HasSuffix(typeURL, ".ClusterLoadAssignment"):
- return "EDS"
- case strings.HasSuffix(typeURL, ".Listener"):
- return "LDS"
- case strings.HasSuffix(typeURL, ".RouteConfiguration"):
- return "RDS"
- case strings.HasSuffix(typeURL, ".Secret"):
- return "SDS"
- }
- if idx := strings.LastIndex(typeURL, "."); idx >= 0 && idx+1 < len(typeURL) {
- return typeURL[idx+1:]
- }
- return typeURL
-}
-
-func (s *Server) buildManagementXDSClients() []managementXDSClient {
- clients := make([]managementXDSClient, 0)
- for _, conn := range s.XDSServer.AllClients() {
- proxy := conn.Proxy()
- if proxy == nil {
- continue
- }
- entry := managementXDSClient{
- NodeID: proxy.ID,
- NodeType: string(proxy.Type),
- Peer: conn.Peer(),
- ConnectedAt: conn.ConnectedAt().UTC(),
- }
- proxy.RLock()
- for typeURL := range proxy.WatchedResources {
- entry.Watched = append(entry.Watched, xdsTypeShortName(typeURL))
- }
- proxy.RUnlock()
- sort.Strings(entry.Watched)
- clients = append(clients, entry)
- }
- sort.SliceStable(clients, func(i, j int) bool { return clients[i].NodeID < clients[j].NodeID })
- return clients
-}
-
-// managementXDSClientsByIP indexes live ADS streams by every IP their node reported, so
-// a pod row can be joined to the stream it actually holds open.
-func (s *Server) managementXDSClientsByIP() map[string]managementWorkload {
- byIP := make(map[string]managementWorkload)
- for _, conn := range s.XDSServer.AllClients() {
- proxy := conn.Proxy()
- if proxy == nil {
- continue
- }
-
- entry := managementWorkload{
- Connected: true,
- NodeID: proxy.ID,
- NodeType: string(proxy.Type),
- }
- if at := conn.ConnectedAt(); !at.IsZero() {
- utc := at.UTC()
- entry.ConnectedAt = &utc
- }
-
- proxy.RLock()
- for typeURL := range proxy.WatchedResources {
- entry.Watched = append(entry.Watched, xdsTypeShortName(typeURL))
- }
- proxy.RUnlock()
- sort.Strings(entry.Watched)
-
- for _, ip := range proxy.IPAddresses {
- if ip != "" {
- byIP[ip] = entry
- }
- }
- }
- return byIP
-}
-
-// managementApplicationContainer returns the application container configured
-// to consume the injected xDS bootstrap directly.
-func managementApplicationContainer(pod corev1.Pod) *corev1.Container {
- for i := range pod.Spec.Containers {
- if managementContainerEnv(pod.Spec.Containers[i], "GRPC_XDS_BOOTSTRAP") != "" {
- return &pod.Spec.Containers[i]
- }
- }
- return nil
-}
-
-func managementContainerEnv(container corev1.Container, name string) string {
- for _, env := range container.Env {
- if env.Name == name {
- return env.Value
- }
- }
- return ""
-}
-
-// managementActiveRootCert mirrors inherentGRPCWorkloadController.activeRootCert so
-// workload secrets can be compared against the same root the issuer uses.
-func (s *Server) managementActiveRootCert() []byte {
- authority := s.RA
- if authority == nil {
- if s.CA == nil {
- return nil
- }
- if s.CA.GetCAKeyCertBundle() == nil {
- return nil
- }
- return s.CA.GetCAKeyCertBundle().GetRootCertPem()
- }
- if authority.GetCAKeyCertBundle() == nil {
- return nil
- }
- return authority.GetCAKeyCertBundle().GetRootCertPem()
-}
-
-// managementWorkloadSecretState reads the per-workload secret dubbod generates.
-// The application consumes this runtime config and certificate directly.
-func (s *Server) managementWorkloadSecretState(ctx context.Context, pod corev1.Pod, activeRoot []byte) (modes []string, expiresAt *time.Time, rootActive bool, problem string) {
- name := inject.InherentGRPCSecretNameForMeta(pod.ObjectMeta)
- secret, err := s.kubeClient.Kube().CoreV1().Secrets(pod.Namespace).Get(ctx, name, metav1.GetOptions{})
- if err != nil {
- return nil, nil, false, fmt.Sprintf("workload secret %s not readable: %v", name, err)
- }
-
- if raw := secret.Data[inject.InherentGRPCConfigFileName]; len(raw) > 0 {
- var runtime struct {
- Services []struct {
- Ports []struct {
- MTLSMode string `json:"mtlsMode"`
- } `json:"ports"`
- } `json:"services"`
- }
- if err := json.Unmarshal(raw, &runtime); err != nil {
- problem = fmt.Sprintf("runtime config in %s is not parseable: %v", name, err)
- } else {
- seen := sets.New[string]()
- for _, svc := range runtime.Services {
- for _, port := range svc.Ports {
- if mode := strings.TrimSpace(port.MTLSMode); mode != "" {
- seen.Insert(mode)
- }
- }
- }
- modes = seen.UnsortedList()
- sort.Strings(modes)
- }
- } else {
- problem = fmt.Sprintf("workload secret %s carries no runtime config", name)
- }
-
- if chain := secret.Data[constants.CertChainFilename]; len(chain) > 0 {
- if at, err := util.ParseCertAndGetExpiryTimestamp(chain); err == nil {
- utc := at.UTC()
- expiresAt = &utc
- } else if problem == "" {
- problem = fmt.Sprintf("workload certificate is not parseable: %v", err)
- }
- } else if problem == "" {
- problem = "workload secret carries no certificate chain"
- }
-
- // A workload still holding a superseded root will keep failing handshakes
- // once the old root is retired, so surface the mismatch rather than the
- // reassuring "cert is valid until X".
- rootActive = len(activeRoot) > 0 && bytes.Equal(secret.Data[constants.CACertNamespaceConfigMapDataName], activeRoot)
-
- return modes, expiresAt, rootActive, problem
-}
-
-// buildManagementDataPlane lists proxyless applications that consume the
-// injected bootstrap directly and joins each to its ADS stream. Gateway pods
-// are reported separately as the external data plane.
-func (s *Server) buildManagementDataPlane() ([]managementWorkload, map[string]int) {
- workloads := make([]managementWorkload, 0)
- candidates := make(map[string]int)
- if s.kubeClient == nil {
- return workloads, candidates
- }
-
- pods, err := s.kubeClient.Kube().CoreV1().Pods(metav1.NamespaceAll).List(context.TODO(), metav1.ListOptions{})
- if err != nil {
- log.Warnf("management: listing data plane pods: %v", err)
- return workloads, candidates
- }
-
- clients := s.managementXDSClientsByIP()
- activeRoot := s.managementActiveRootCert()
- for _, pod := range pods.Items {
- if pod.Labels[managementGatewayNameLabel] == managementGatewayNameValue {
- continue
- }
-
- // Finished pods are not part of the running data plane and would skew
- // the injected ratio.
- if pod.Status.Phase == corev1.PodSucceeded || pod.Status.Phase == corev1.PodFailed {
- continue
- }
- candidates[pod.Namespace]++
-
- application := managementApplicationContainer(pod)
- if application == nil {
- continue
- }
-
- applicationReady := false
- for _, status := range pod.Status.ContainerStatuses {
- if status.Name == application.Name {
- applicationReady = status.Ready
- }
- }
-
- workload := managementWorkload{
- Name: pod.Name,
- Namespace: pod.Namespace,
- IP: pod.Status.PodIP,
- Phase: string(pod.Status.Phase),
- Ready: podReady(pod),
- ApplicationReady: applicationReady,
- ServiceAccount: pod.Spec.ServiceAccountName,
- Image: application.Image,
- XDSAddress: managementContainerEnv(*application, "XDS_ADDRESS"),
- }
- for _, status := range pod.Status.ContainerStatuses {
- if status.Name == application.Name {
- workload.Restarts = status.RestartCount
- }
- }
- workload.MTLSModes, workload.CertExpiresAt, workload.CertRootActive, workload.ConfigError =
- s.managementWorkloadSecretState(context.TODO(), pod, activeRoot)
- if client, ok := clients[pod.Status.PodIP]; ok {
- workload.Connected = client.Connected
- workload.NodeID = client.NodeID
- workload.NodeType = client.NodeType
- workload.ConnectedAt = client.ConnectedAt
- workload.Watched = client.Watched
- }
- workloads = append(workloads, workload)
- }
-
- sort.SliceStable(workloads, func(i, j int) bool {
- if workloads[i].Namespace != workloads[j].Namespace {
- return workloads[i].Namespace < workloads[j].Namespace
- }
- return workloads[i].Name < workloads[j].Name
- })
-
- // Only namespaces that actually run part of the data plane are interesting;
- // the rest of the cluster is not something dubbod is failing to inject.
- injectedNamespaces := sets.New[string]()
- for _, workload := range workloads {
- injectedNamespaces.Insert(workload.Namespace)
- }
- for namespace := range candidates {
- if !injectedNamespaces.Contains(namespace) {
- delete(candidates, namespace)
- }
- }
-
- return workloads, candidates
-}
-
-func (s *Server) buildManagementGatewayInstances() []managementDubbodInstance {
- instances := make([]managementDubbodInstance, 0)
-
- if s.kubeClient != nil {
- deployments, err := s.kubeClient.Kube().AppsV1().Deployments("").List(context.TODO(), metav1.ListOptions{
- LabelSelector: managementGatewaySelector,
- })
- if err == nil && len(deployments.Items) > 0 {
- for _, deployment := range deployments.Items {
- instances = append(instances, managementGatewayInstanceFromDeployment(deployment))
- }
- }
- }
-
- return instances
-}
-
-func managementGatewayInstanceFromDeployment(deployment appsv1.Deployment) managementDubbodInstance {
- desired := int32(1)
- if deployment.Spec.Replicas != nil {
- desired = *deployment.Spec.Replicas
- }
- ready := deployment.Status.ReadyReplicas
- gatewayName := deployment.Labels["gateway.networking.k8s.io/gateway-name"]
-
- return managementDubbodInstance{
- Name: deployment.Name,
- Namespace: deployment.Namespace,
- IsReady: desired > 0 && ready >= desired,
- GatewayClass: "dubbo",
- GatewayName: gatewayName,
- ReadyReplicas: ready,
- DesiredReplicas: desired,
- }
-}
-
-// buildManagementRoutes flattens the HTTPRoutes in the config store into a simplified structure.
-// Matches are rendered as the operator wrote them so a rule can be grepped for in `kubectl get httproute -o yaml`.
-func (s *Server) buildManagementRoutes() []managementRoute {
- routes := make([]managementRoute, 0)
- if s.environment.ConfigStore == nil {
- return routes
- }
-
- for _, cfg := range s.environment.List(gvk.HTTPRoute, "") {
- spec, ok := cfg.Spec.(*sigsk8siogatewayapiapisv1.HTTPRouteSpec)
- if !ok {
- continue
- }
-
- entry := managementRoute{Name: cfg.Name, Namespace: cfg.Namespace}
- for _, parent := range spec.ParentRefs {
- entry.Parents = append(entry.Parents, string(parent.Name))
- }
- for _, hostname := range spec.Hostnames {
- entry.Hostnames = append(entry.Hostnames, string(hostname))
- }
-
- for _, rule := range spec.Rules {
- out := managementRouteRule{Match: managementRouteMatch(rule.Matches)}
- for _, backend := range rule.BackendRefs {
- item := managementRouteBackend{Name: string(backend.Name)}
- if backend.Port != nil {
- item.Port = *backend.Port
- }
- if backend.Weight != nil {
- item.Weight = *backend.Weight
- }
- out.Backends = append(out.Backends, item)
- }
- entry.Rules = append(entry.Rules, out)
- }
- routes = append(routes, entry)
- }
-
- sort.SliceStable(routes, func(i, j int) bool {
- if routes[i].Namespace != routes[j].Namespace {
- return routes[i].Namespace < routes[j].Namespace
- }
- return routes[i].Name < routes[j].Name
- })
-
- return routes
-}
-
-// managementRouteMatch renders the match conditions of one rule; an empty match set is
-// Gateway API's "match everything", which reads better as an explicit path.
-func managementRouteMatch(matches []sigsk8siogatewayapiapisv1.HTTPRouteMatch) string {
- if len(matches) == 0 {
- return "/"
- }
-
- parts := make([]string, 0, len(matches))
- for _, match := range matches {
- segment := ""
- if match.Path != nil && match.Path.Value != nil {
- segment = *match.Path.Value
- if match.Path.Type != nil && *match.Path.Type == sigsk8siogatewayapiapisv1.PathMatchPathPrefix {
- segment += "*"
- }
- }
- for _, header := range match.Headers {
- segment = strings.TrimSpace(segment + " " + string(header.Name) + "=" + header.Value)
- }
- if match.Method != nil {
- segment = strings.TrimSpace(string(*match.Method) + " " + segment)
- }
- if segment == "" {
- segment = "/"
- }
- parts = append(parts, segment)
- }
- return strings.Join(parts, " | ")
-}
-
-func (s *Server) buildManagementRegistries() []managementRegistry {
- registries := s.ServiceController().GetRegistries()
- items := make([]managementRegistry, 0, len(registries))
- for _, registry := range registries {
- items = append(items, managementRegistry{
- Provider: string(registry.Provider()),
- Cluster: string(registry.Cluster()),
- Synced: registry.HasSynced(),
- })
- }
-
- sort.SliceStable(items, func(i, j int) bool {
- if items[i].Provider != items[j].Provider {
- return items[i].Provider < items[j].Provider
- }
- return items[i].Cluster < items[j].Cluster
- })
-
- return items
-}
-
-func (s *Server) buildManagementConfigKinds() []managementConfigKind {
- return []managementConfigKind{
- {
- Kind: "PeerAuthentication",
- Count: s.countConfigs(gvk.PeerAuthentication),
- Description: "mTLS posture and workload identity policy.",
- },
- {
- Kind: "RequestAuthentication",
- Count: s.countConfigs(gvk.RequestAuthentication),
- Description: "JWT request authentication policy.",
- },
- {
- Kind: "AuthorizationPolicy",
- Count: s.countConfigs(gvk.AuthorizationPolicy),
- Description: "Request authorization policy.",
- },
- {
- Kind: "HTTPRoute",
- Count: s.countConfigs(gvk.HTTPRoute),
- Description: "Gateway API HTTP routing resources.",
- },
- {
- Kind: "GatewayClass",
- Count: s.countConfigs(gvk.GatewayClass),
- Description: "Gateway controller classes in scope.",
- },
- {
- Kind: "Gateway",
- Count: s.countConfigs(gvk.KubernetesGateway),
- Description: "Gateway instances served by the control plane.",
- },
- }
-}
-
-func (s *Server) buildManagementServices() []managementService {
- injectedNamespaces := make(map[string]bool)
- if s.kubeClient != nil {
- nsList, err := s.kubeClient.Kube().CoreV1().Namespaces().List(context.TODO(), metav1.ListOptions{})
- if err == nil {
- for _, ns := range nsList.Items {
- if ns.Labels != nil {
- if ns.Labels["dubbo-injection"] == "enabled" || ns.Labels["dubbo.apache.org/rev"] != "" {
- injectedNamespaces[ns.Name] = true
- }
- }
- }
- }
- }
-
- services := s.environment.Services()
- items := make([]managementService, 0, len(services))
- for _, service := range services {
- injected := injectedNamespaces[service.Attributes.Namespace]
- if !injected && s.environment.EndpointIndex != nil {
- if shards, ok := s.environment.EndpointIndex.ShardsForService(string(service.Hostname), service.Attributes.Namespace); ok {
- shards.RLock()
- for _, eps := range shards.Shards {
- for _, ep := range eps {
- if ep.Labels != nil && (ep.Labels["inherent.dubbo.apache.org/inject"] == "true" || ep.Labels["dubbo.apache.org/rev"] != "") {
- injected = true
- break
- }
- }
- if injected {
- break
- }
- }
- shards.RUnlock()
- }
- }
-
- if !injected {
- continue
- }
-
- mode, fromPolicy := s.managementServiceMTLSMode(service)
- items = append(items, managementService{
- MTLSMode: mode,
- MTLSFromPolicy: fromPolicy,
- Name: service.Attributes.Name,
- Hostname: string(service.Hostname),
- Namespace: service.Attributes.Namespace,
- Registry: string(service.Attributes.ServiceRegistry),
- Ports: servicePortsSummary(service),
- Exposure: serviceExposure(service),
- ServiceAccounts: len(service.ServiceAccounts),
- DefaultAddress: service.DefaultAddress,
- MeshExternal: service.MeshExternal,
- })
- }
-
- sort.SliceStable(items, func(i, j int) bool {
- if items[i].Namespace != items[j].Namespace {
- return items[i].Namespace < items[j].Namespace
- }
- if items[i].Name != items[j].Name {
- return items[i].Name < items[j].Name
- }
- return items[i].Hostname < items[j].Hostname
- })
-
- return items
-}
-
-// managementServiceMTLSMode resolves the inbound mTLS mode callers of this
-// service meet. When no PeerAuthentication selects the workload, the native
-// runtime falls back to PERMISSIVE.
-func (s *Server) managementServiceMTLSMode(service *discoverymodel.Service) (mode string, fromPolicy bool) {
- push := s.environment.PushContext()
- if push == nil || push.AuthenticationPolicies == nil {
- return inherentInboundFallbackMTLSMode, false
- }
-
- strongest := discoverymodel.MTLSUnknown
- for _, port := range service.Ports {
- if port == nil {
- continue
- }
- effective := push.AuthenticationPolicies.EffectiveMutualTLSMode(
- service.Attributes.Namespace, nil, uint32(port.Port))
- if effective == discoverymodel.MTLSUnknown {
- continue
- }
- // Report the weakest mode any port allows: that is what an attacker gets.
- if strongest == discoverymodel.MTLSUnknown || effective < strongest {
- strongest = effective
- }
- }
-
- switch strongest {
- case discoverymodel.MTLSDisable:
- return "DISABLE", true
- case discoverymodel.MTLSPermissive:
- return "PERMISSIVE", true
- case discoverymodel.MTLSStrict:
- return "STRICT", true
- }
- return inherentInboundFallbackMTLSMode, false
-}
-
-func (s *Server) countConfigs(kind config.GroupVersionKind) int {
- if s.environment.ConfigStore == nil {
- return 0
- }
- return len(s.environment.List(kind, ""))
-}
-
-func servicePortsSummary(service *discoverymodel.Service) string {
- if len(service.Ports) == 0 {
- return "n/a"
- }
-
- segments := make([]string, 0, len(service.Ports))
- for _, port := range service.Ports {
- if port == nil {
- continue
- }
-
- segment := fmt.Sprintf("%d", port.Port)
- if port.Name != "" {
- segment = port.Name + ":" + segment
- }
- if port.Protocol != "" {
- segment += "/" + string(port.Protocol)
- }
- segments = append(segments, segment)
- }
-
- if len(segments) == 0 {
- return "n/a"
- }
-
- return strings.Join(segments, ", ")
-}
-
-func serviceExposure(service *discoverymodel.Service) string {
- switch {
- case service.MeshExternal:
- return "mesh-external"
- case service.Attributes.Type != "":
- // Verbatim `Service.spec.type` (ClusterIP, NodePort, LoadBalancer,
- // ExternalName) so the column matches what kubectl prints. The cases
- // below are resolution modes, not Kubernetes types, and stay lowercase
- // to keep that distinction visible.
- return service.Attributes.Type
- case service.Resolution == discoverymodel.Passthrough:
- return "passthrough"
- case service.Resolution == discoverymodel.DNSLB || service.Resolution == discoverymodel.DNSRoundRobinLB:
- return "dns"
- default:
- return "internal"
- }
-}
-
-func localLinkAddress(addr string) string {
- trimmed := strings.TrimSpace(addr)
- switch {
- case strings.HasPrefix(trimmed, ":"):
- return "127.0.0.1" + trimmed
- case strings.HasPrefix(trimmed, "0.0.0.0:"):
- return "127.0.0.1:" + strings.TrimPrefix(trimmed, "0.0.0.0:")
- case strings.HasPrefix(trimmed, "[::]:"):
- return "127.0.0.1:" + strings.TrimPrefix(trimmed, "[::]:")
- default:
- return trimmed
- }
-}
-
-func buildLocalHTTPURL(addr, requestPath string) string {
- return "http://" + localLinkAddress(addr) + requestPath
-}
diff --git a/dubbod/discovery/pkg/bootstrap/management_test.go b/dubbod/discovery/pkg/bootstrap/management_test.go
deleted file mode 100644
index bc80df8e..00000000
--- a/dubbod/discovery/pkg/bootstrap/management_test.go
+++ /dev/null
@@ -1,88 +0,0 @@
-// 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 bootstrap
-
-import (
- "testing"
-
- appsv1 "k8s.io/api/apps/v1"
- corev1 "k8s.io/api/core/v1"
- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
-)
-
-func TestManagementGatewayInstanceUsesDeploymentIdentity(t *testing.T) {
- desired := int32(2)
- deployment := appsv1.Deployment{
- ObjectMeta: metav1.ObjectMeta{
- Name: "test-gateway",
- Namespace: "default",
- Labels: map[string]string{
- "gateway.networking.k8s.io/gateway-name": "test-gateway",
- },
- },
- Spec: appsv1.DeploymentSpec{
- Replicas: &desired,
- },
- Status: appsv1.DeploymentStatus{
- ReadyReplicas: 2,
- },
- }
-
- got := managementGatewayInstanceFromDeployment(deployment)
- if got.Name != "test-gateway" {
- t.Fatalf("Name = %q, want deployment name without pod hash", got.Name)
- }
- if got.GatewayName != "test-gateway" {
- t.Fatalf("GatewayName = %q, want test-gateway", got.GatewayName)
- }
- if got.ReadyReplicas != 2 || got.DesiredReplicas != 2 || !got.IsReady {
- t.Fatalf("readiness = ready:%d desired:%d isReady:%v, want 2/2 true",
- got.ReadyReplicas, got.DesiredReplicas, got.IsReady)
- }
-}
-
-func TestManagementLogTailLines(t *testing.T) {
- if got := managementLogTailLines(""); got != 200 {
- t.Fatalf("default tail lines = %d, want 200", got)
- }
- if got := managementLogTailLines("25"); got != 25 {
- t.Fatalf("tail lines = %d, want 25", got)
- }
- if got := managementLogTailLines("99999"); got != 2000 {
- t.Fatalf("capped tail lines = %d, want 2000", got)
- }
-}
-
-func TestManagementLogContainersPrefersNamedContainer(t *testing.T) {
- pod := corev1.Pod{
- Spec: corev1.PodSpec{
- Containers: []corev1.Container{
- {Name: "setup"},
- {Name: "gateway"},
- },
- },
- }
-
- got := managementLogContainers(pod, "gateway")
- if len(got) != 1 || got[0] != "gateway" {
- t.Fatalf("containers = %v, want [gateway]", got)
- }
-
- got = managementLogContainers(pod, "missing")
- if len(got) != 2 || got[0] != "setup" || got[1] != "gateway" {
- t.Fatalf("fallback containers = %v, want all containers", got)
- }
-}
diff --git a/dubbod/discovery/pkg/bootstrap/mesh.go b/dubbod/discovery/pkg/bootstrap/mesh.go
index 8f0ff498..a99514df 100644
--- a/dubbod/discovery/pkg/bootstrap/mesh.go
+++ b/dubbod/discovery/pkg/bootstrap/mesh.go
@@ -168,7 +168,6 @@ func serverAddressSummary(args *DubboArgs) string {
}
return multilineParts(
formatStringField("http", args.ServerOptions.HTTPAddr),
- formatStringField("management", args.ServerOptions.ManagementAddr),
formatStringField("https", args.ServerOptions.HTTPSAddr),
formatStringField("grpc", args.ServerOptions.GRPCAddr),
formatStringField("secure_grpc", args.ServerOptions.SecureGRPCAddr),
diff --git a/dubbod/discovery/pkg/bootstrap/options.go b/dubbod/discovery/pkg/bootstrap/options.go
index 5a800f7d..692183f1 100644
--- a/dubbod/discovery/pkg/bootstrap/options.go
+++ b/dubbod/discovery/pkg/bootstrap/options.go
@@ -52,7 +52,6 @@ type DubboArgs struct {
type DiscoveryServerOptions struct {
HTTPAddr string
- ManagementAddr string
HTTPSAddr string
GRPCAddr string
SecureGRPCAddr string
diff --git a/dubbod/discovery/pkg/bootstrap/server.go b/dubbod/discovery/pkg/bootstrap/server.go
index 0853071f..88517c93 100644
--- a/dubbod/discovery/pkg/bootstrap/server.go
+++ b/dubbod/discovery/pkg/bootstrap/server.go
@@ -85,13 +85,11 @@ type Server struct {
secureGrpcServer *grpc.Server
secureGrpcAddress string
- httpsServer *http.Server // webhooks HTTPS Server.
- httpAddr string
- managementAddr string
- httpsAddr string
- httpMux *http.ServeMux
- managementMux *http.ServeMux
- httpsMux *http.ServeMux // webhooks
+ httpsServer *http.Server // webhooks HTTPS Server.
+ httpAddr string
+ httpsAddr string
+ httpMux *http.ServeMux
+ httpsMux *http.ServeMux // webhooks
monitoringMux *http.ServeMux
@@ -174,7 +172,6 @@ func NewServer(args *DubboArgs, initFuncs ...func(*Server)) (*Server, error) {
server: server.New(),
clusterID: getClusterID(args),
httpMux: http.NewServeMux(),
- managementMux: http.NewServeMux(),
monitoringMux: http.NewServeMux(),
dubbodCertBundleWatcher: keycertbundle.NewWatcher(),
fileWatcher: filewatcher.NewWatcher(),
@@ -235,13 +232,6 @@ func NewServer(args *DubboArgs, initFuncs ...func(*Server)) (*Server, error) {
InitGenerators(s.XDSServer)
- if err := s.initManagement(); err != nil {
- return nil, fmt.Errorf("error initializing management API: %v", err)
- }
- if err := s.initManagementServer(args.ServerOptions.ManagementAddr); err != nil {
- return nil, fmt.Errorf("error initializing Management Server: %v", err)
- }
-
// Initialize monitoring server
if err := s.initMonitor(args.ServerOptions.HTTPAddr); err != nil {
return nil, fmt.Errorf("error initializing monitoring: %v", err)
diff --git a/go.mod b/go.mod
index 28c13cc8..606898b8 100644
--- a/go.mod
+++ b/go.mod
@@ -38,6 +38,7 @@ require (
github.com/gogo/protobuf v1.3.2
github.com/golang/protobuf v1.5.4
github.com/google/go-cmp v0.7.0
+ github.com/google/go-containerregistry v0.21.6
github.com/google/uuid v1.6.0
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0
github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.3.2
@@ -124,6 +125,7 @@ require (
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect
github.com/onsi/ginkgo/v2 v2.25.3 // indirect
github.com/onsi/gomega v1.42.1 // indirect
+ github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
diff --git a/go.sum b/go.sum
index a85fc62c..afa2d592 100644
--- a/go.sum
+++ b/go.sum
@@ -893,6 +893,8 @@ github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
+github.com/google/go-containerregistry v0.21.6 h1:T+yqQIlJXKrM98Om4DlW3GoWQAmhZuLMwoDOvVrtiUM=
+github.com/google/go-containerregistry v0.21.6/go.mod h1:U7MMSBIJynke2MVQrQk19NP9k/uQsGz/h0amIFSHMbo=
github.com/google/go-pkcs11 v0.2.1-0.20230907215043-c6f79328ddf9/go.mod h1:6eQoGcuNJpa7jnd5pMGdkSaQpNDYvPlXWMcjXXThLlY=
github.com/google/go-pkcs11 v0.3.0/go.mod h1:6eQoGcuNJpa7jnd5pMGdkSaQpNDYvPlXWMcjXXThLlY=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
@@ -1188,6 +1190,8 @@ github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1Cpa
github.com/onsi/gomega v1.42.1 h1:iN1rCUX+44NZ1Dc97MPoeFYbFR0vh8zxoxMFwKdyZ6I=
github.com/onsi/gomega v1.42.1/go.mod h1:REff/hsDsodHoKlWsP2mAPhu1+5/6hVYNf9rIEBpeSg=
github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk=
+github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
+github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
github.com/opentracing-contrib/go-observer v0.0.0-20170622124052-a52f23424492/go.mod h1:Ngi6UdF0k5OKD5t5wlmGhe/EDKPoUM3BXZSSfIuJbis=
github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74=
github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
diff --git a/manifests/charts/README.md b/manifests/charts/README.md
index a56c8e8c..43a97d9c 100644
--- a/manifests/charts/README.md
+++ b/manifests/charts/README.md
@@ -1,4 +1,4 @@
-# Dubbo Helm Charts
+# Dubbod Helm Charts
The charts in this directory are the source for every
supported install path:
diff --git a/manifests/charts/dubbod/templates/clusterrole.yaml b/manifests/charts/dubbod/templates/clusterrole.yaml
index 14bfac48..ff5ffa43 100644
--- a/manifests/charts/dubbod/templates/clusterrole.yaml
+++ b/manifests/charts/dubbod/templates/clusterrole.yaml
@@ -42,11 +42,6 @@ rules:
- apiGroups: [""]
resources: ["pods", "nodes", "services", "namespaces", "endpoints"]
verbs: ["get", "list", "watch"]
- # The management API tails control plane and managed gateway pods; `pods`
- # alone does not cover the log subresource.
- - apiGroups: [""]
- resources: ["pods/log"]
- verbs: ["get"]
- apiGroups: ["discovery.k8s.io"]
resources: ["endpointslices"]
verbs: ["get", "list", "watch"]
diff --git a/manifests/charts/dubbod/templates/configmap-values.yaml b/manifests/charts/dubbod/templates/configmap-values.yaml
index 30c4c198..13dc6dab 100644
--- a/manifests/charts/dubbod/templates/configmap-values.yaml
+++ b/manifests/charts/dubbod/templates/configmap-values.yaml
@@ -14,13 +14,20 @@
# limitations under the License.
{{- $defaults := .Values._internal_default_values_not_set | default dict }}
-{{- $defaultManagement := $defaults.management | default dict }}
-{{- $management := .Values.management | default dict }}
{{- $trustDomain := coalesce .Values.trustDomain $defaults.trustDomain "cluster.local" }}
{{- $revision := .Values.revision | default "default" }}
{{- $statusPort := coalesce .Values.statusPort $defaults.statusPort 26020 }}
-{{- $managementPort := int (coalesce $management.port $defaultManagement.port 26080) }}
-{{- $image := coalesce .Values.image $defaults.image (printf "ghcr.io/apache/dubbo-kubernetes/dubbod:%s" .Chart.AppVersion) }}
+{{- $repo := coalesce .Values.repo $defaults.repo "ghcr.io/apache/dubbo-kubernetes" }}
+{{- $tag := .Chart.AppVersion }}
+{{- if and (hasKey .Values "tag") (ne (.Values.tag | toString) "") }}
+{{- $tag = .Values.tag }}
+{{- else if and (hasKey $defaults "tag") (ne ($defaults.tag | toString) "") }}
+{{- $tag = $defaults.tag }}
+{{- end }}
+{{- $image := coalesce .Values.image $defaults.image "dubbod" }}
+{{- if not (contains "/" $image) }}
+{{- $image = printf "%s/%s:%v" $repo $image $tag }}
+{{- end }}
{{- $original := omit .Values "_internal_default_values_not_set" }}
apiVersion: v1
kind: ConfigMap
@@ -35,8 +42,6 @@ data:
revision: {{ $revision | quote }}
image: {{ $image | quote }}
trustDomain: {{ $trustDomain | quote }}
- management:
- port: {{ $managementPort }}
statusPort: {{ $statusPort }}
original-values: |-
{{ $original | toYaml | nindent 4 }}
diff --git a/manifests/charts/dubbod/templates/deployment.yaml b/manifests/charts/dubbod/templates/deployment.yaml
index 3793e5f2..fd3cfc2e 100644
--- a/manifests/charts/dubbod/templates/deployment.yaml
+++ b/manifests/charts/dubbod/templates/deployment.yaml
@@ -14,15 +14,22 @@
# limitations under the License.
{{- $defaults := .Values._internal_default_values_not_set | default dict }}
-{{- $defaultManagement := $defaults.management | default dict }}
-{{- $management := .Values.management | default dict }}
-{{- $managementPort := int (coalesce $management.port $defaultManagement.port 26080) }}
{{- $replicaCount := int (coalesce .Values.replicaCount $defaults.replicaCount 1) }}
{{- $gateway := .Values.gateway | default dict }}
{{- $defaultGateway := $defaults.gateway | default dict }}
{{- $gatewayImage := coalesce $gateway.image $defaultGateway.image "apache/dubbo-gateway:latest" }}
{{- $gatewayReplicas := int (coalesce $gateway.replicaCount $defaultGateway.replicaCount 2) }}
-{{- $image := coalesce .Values.image $defaults.image (printf "dubml/dubbod:%s" .Chart.AppVersion) }}
+{{- $repo := coalesce .Values.repo $defaults.repo "dubml" }}
+{{- $tag := .Chart.AppVersion }}
+{{- if and (hasKey .Values "tag") (ne (.Values.tag | toString) "") }}
+{{- $tag = .Values.tag }}
+{{- else if and (hasKey $defaults "tag") (ne ($defaults.tag | toString) "") }}
+{{- $tag = $defaults.tag }}
+{{- end }}
+{{- $image := coalesce .Values.image $defaults.image "dubbod" }}
+{{- if not (contains "/" $image) }}
+{{- $image = printf "%s/%s:%v" $repo $image $tag }}
+{{- end }}
apiVersion: apps/v1
kind: Deployment
metadata:
@@ -77,15 +84,10 @@ spec:
- "execute"
- --domain
- cluster.local
- - --managementAddr
- - ":{{ $managementPort }}"
ports:
- containerPort: 8080
protocol: TCP
name: http-debug
- - containerPort: {{ $managementPort }}
- protocol: TCP
- name: management
- containerPort: 26010
protocol: TCP
name: grpc-xds
diff --git a/manifests/charts/dubbod/templates/service.yaml b/manifests/charts/dubbod/templates/service.yaml
index c515d97a..4b4537e2 100644
--- a/manifests/charts/dubbod/templates/service.yaml
+++ b/manifests/charts/dubbod/templates/service.yaml
@@ -14,9 +14,6 @@
# limitations under the License.
{{- $defaults := .Values._internal_default_values_not_set | default dict }}
-{{- $defaultManagement := $defaults.management | default dict }}
-{{- $management := .Values.management | default dict }}
-{{- $managementPort := int (coalesce $management.port $defaultManagement.port 26080) }}
apiVersion: v1
kind: Service
metadata:
@@ -45,19 +42,3 @@ spec:
protocol: TCP
selector:
app: dubbod
----
-apiVersion: v1
-kind: Service
-metadata:
- name: dubbod-management
- namespace: dubbo-system
- labels:
- app: dubbod
-spec:
- ports:
- - port: {{ $managementPort }}
- name: management
- targetPort: {{ $managementPort }}
- protocol: TCP
- selector:
- app: dubbod
diff --git a/manifests/charts/dubbod/values.yaml b/manifests/charts/dubbod/values.yaml
index 6f60bea5..ea0a7ad3 100644
--- a/manifests/charts/dubbod/values.yaml
+++ b/manifests/charts/dubbod/values.yaml
@@ -16,6 +16,8 @@
_internal_default_values_not_set:
revision: ""
+ trustDomain: "cluster.local"
+
# Number of dubbod replicas. Two by default: a single replica makes every
# node drain, upgrade or eviction a full control-plane outage, during which
# no workload can be injected and no xDS update is served. At >= 2 a
@@ -23,24 +25,20 @@ _internal_default_values_not_set:
# automatically. Set to 1 only for local development.
replicaCount: 2
- # Control-plane image. An empty value resolves to
- # ghcr.io/apache/dubbo-kubernetes/dubbod:<Chart.appVersion>.
- image: ""
-
- trustDomain: "cluster.local"
-
- statusPort: 26020
+ # Root for control-plane docker image paths. The rendered image is
+ # <repo>/<image>:<tag>; an unset tag uses Chart.appVersion.
+ repo: ""
+ tag: ""
- management:
- port: 26080
+ # Can be a full repo/image:tag
+ image: dubbod
gateway:
# Image used by managed Gateway deployments. Keep it independently
# configurable from dubbod so a gateway can be rolled independently.
- image: "apache/dubbo-gateway:latest"
+ image: ""
# Individual Gateways can override this with the
# gateway.dubbo.apache.org/replicas annotation.
replicaCount: 2
-
configValidation: true
diff --git a/operator/cmd/validation/validation.go b/operator/cmd/validation/validation.go
index 721c95a0..2cd3aca9 100644
--- a/operator/cmd/validation/validation.go
+++ b/operator/cmd/validation/validation.go
@@ -21,6 +21,7 @@ import (
"encoding/json"
"fmt"
"github.com/apache/dubbo-kubernetes/operator/pkg/apis"
+ apisvalidation "github.com/apache/dubbo-kubernetes/operator/pkg/apis/validation"
"github.com/apache/dubbo-kubernetes/operator/pkg/util"
"github.com/apache/dubbo-kubernetes/operator/pkg/values"
"sigs.k8s.io/yaml"
@@ -41,6 +42,8 @@ func ParseAndValidateDubboOperator(dopMap values.Map) (Warnings, util.Errors) {
warnings = util.AppendErrs(warnings, vw)
errors = util.AppendErrs(errors, ve)
errors = util.AppendErr(errors, validateComponentNames(dop.Spec.Components))
+ errors = util.AppendErr(errors, apisvalidation.ValidateRepo(dop.Spec.Repo))
+ errors = util.AppendErr(errors, apisvalidation.ValidateTag(dop.Spec.Tag))
return warnings, errors
}
diff --git a/operator/pkg/apis/proto/values_types.proto b/operator/pkg/apis/proto/values_types.proto
index 58779235..622c2cf8 100644
--- a/operator/pkg/apis/proto/values_types.proto
+++ b/operator/pkg/apis/proto/values_types.proto
@@ -20,14 +20,11 @@ syntax = 'proto3';
package dubbo.operator.v1alpha1;
import "google/protobuf/wrappers.proto";
+import "google/protobuf/struct.proto";
// Package-wide variables from generator "generated".
option go_package = "dubbo.apache.org/dubbo/operator/pkg/apis";
-message ManagementConfig {
- int64 port = 1;
-}
-
message GatewayConfig {
// Default replica count for managed gateway deployments. Individual Gateways
// override it with the gateway.dubbo.apache.org/replicas annotation.
@@ -39,7 +36,8 @@ message GlobalConfig {
int64 statusPort = 2;
- ManagementConfig management = 3;
+ reserved 3;
+ reserved "admin", "management";
bool configValidation = 4;
@@ -50,6 +48,12 @@ message GlobalConfig {
GatewayConfig gateway = 7;
reserved 8;
+
+ // Root for docker image paths.
+ string repo = 9;
+
+ // Version tag for docker images; supports numeric tags.
+ google.protobuf.Value tag = 10;
}
message Values {
@@ -64,8 +68,14 @@ message Values {
// 1 is distinguishable from an unset field.
google.protobuf.Int32Value replicaCount = 3;
- // Control-plane image used by dubbod and its admission webhook.
+ // Control-plane image name, or a full repo/image:tag.
string image = 4;
+
+ // Version tag for control-plane docker images; supports numeric tags.
+ google.protobuf.Value tag = 5;
+
+ // Root for control-plane docker image paths.
+ string repo = 6;
}
// IntOrString is a type that can hold an int32 or a string. When used in
diff --git a/operator/pkg/apis/types.go b/operator/pkg/apis/types.go
index 941133a3..e7a4d2c3 100644
--- a/operator/pkg/apis/types.go
+++ b/operator/pkg/apis/types.go
@@ -43,6 +43,10 @@ type DubboOperatorSpec struct {
// Path or name for the profile.
// default profile is used if this field is unset.
Profile string `json:"profile,omitempty"`
+ // Root for docker image paths.
+ Repo string `json:"repo,omitempty"`
+ // Version tag for docker images.
+ Tag any `json:"tag,omitempty"`
// enablement and component-specific settings that are not internal to the component.
Components *DubboComponentSpec `json:"components,omitempty"`
// Overrides for default `values.yaml`. This is a validated pass-through to Helm templates.
diff --git a/operator/pkg/apis/validation/validation.go b/operator/pkg/apis/validation/validation.go
index eb5c7848..e89ed8ff 100644
--- a/operator/pkg/apis/validation/validation.go
+++ b/operator/pkg/apis/validation/validation.go
@@ -24,6 +24,7 @@ import (
"github.com/apache/dubbo-kubernetes/operator/pkg/util"
"github.com/apache/dubbo-kubernetes/operator/pkg/values"
"github.com/apache/dubbo-kubernetes/pkg/kube"
+ "github.com/google/go-containerregistry/pkg/name"
"sigs.k8s.io/yaml"
)
@@ -43,9 +44,35 @@ func ParseAndValidateDubboOperator(dopMap values.Map, _ kube.CLIClient) (Warning
warnings = util.AppendErrs(warnings, vw)
errors = util.AppendErrs(errors, ve)
errors = util.AppendErr(errors, validateComponentNames(iop.Spec.Components))
+ errors = util.AppendErr(errors, ValidateRepo(iop.Spec.Repo))
+ errors = util.AppendErr(errors, ValidateTag(iop.Spec.Tag))
return warnings, errors
}
+// ValidateRepo validates the root for docker image paths.
+func ValidateRepo(repo string) error {
+ if repo == "" {
+ return nil
+ }
+ _, err := name.NewRepository(repo + "/dubbod")
+ if err != nil {
+ return fmt.Errorf("bad repo: %v", err)
+ }
+ return nil
+}
+
+// ValidateTag validates a string or numeric docker image tag.
+func ValidateTag(tag any) error {
+ if tag == nil {
+ return nil
+ }
+ _, err := name.NewTag(fmt.Sprintf("dubml/dubbod:%v", tag))
+ if err != nil {
+ return fmt.Errorf("bad tag: %v", err)
+ }
+ return nil
+}
+
type FeatureValidator func(*apis.Values, apis.DubboOperatorSpec) (Warnings, util.Errors)
func validateFeatures(values *apis.Values, spec apis.DubboOperatorSpec) (Warnings, util.Errors) {
diff --git a/operator/pkg/apis/values_types.pb.go b/operator/pkg/apis/values_types.pb.go
index 0ab16fb5..67014c9f 100644
--- a/operator/pkg/apis/values_types.pb.go
+++ b/operator/pkg/apis/values_types.pb.go
@@ -25,6 +25,7 @@ package apis
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
+ structpb "google.golang.org/protobuf/types/known/structpb"
wrapperspb "google.golang.org/protobuf/types/known/wrapperspb"
reflect "reflect"
sync "sync"
@@ -38,50 +39,6 @@ const (
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
-type ManagementConfig struct {
- state protoimpl.MessageState `protogen:"open.v1"`
- Port int64 `protobuf:"varint,1,opt,name=port,proto3" json:"port,omitempty"`
- unknownFields protoimpl.UnknownFields
- sizeCache protoimpl.SizeCache
-}
-
-func (x *ManagementConfig) Reset() {
- *x = ManagementConfig{}
- mi := &file_values_types_proto_msgTypes[0]
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- ms.StoreMessageInfo(mi)
-}
-
-func (x *ManagementConfig) String() string {
- return protoimpl.X.MessageStringOf(x)
-}
-
-func (*ManagementConfig) ProtoMessage() {}
-
-func (x *ManagementConfig) ProtoReflect() protoreflect.Message {
- mi := &file_values_types_proto_msgTypes[0]
- if x != nil {
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- if ms.LoadMessageInfo() == nil {
- ms.StoreMessageInfo(mi)
- }
- return ms
- }
- return mi.MessageOf(x)
-}
-
-// Deprecated: Use ManagementConfig.ProtoReflect.Descriptor instead.
-func (*ManagementConfig) Descriptor() ([]byte, []int) {
- return file_values_types_proto_rawDescGZIP(), []int{0}
-}
-
-func (x *ManagementConfig) GetPort() int64 {
- if x != nil {
- return x.Port
- }
- return 0
-}
-
type GatewayConfig struct {
state protoimpl.MessageState `protogen:"open.v1"`
// Default replica count for managed gateway deployments. Individual Gateways
@@ -93,7 +50,7 @@ type GatewayConfig struct {
func (x *GatewayConfig) Reset() {
*x = GatewayConfig{}
- mi := &file_values_types_proto_msgTypes[1]
+ mi := &file_values_types_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -105,7 +62,7 @@ func (x *GatewayConfig) String() string {
func (*GatewayConfig) ProtoMessage() {}
func (x *GatewayConfig) ProtoReflect() protoreflect.Message {
- mi := &file_values_types_proto_msgTypes[1]
+ mi := &file_values_types_proto_msgTypes[0]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -118,7 +75,7 @@ func (x *GatewayConfig) ProtoReflect() protoreflect.Message {
// Deprecated: Use GatewayConfig.ProtoReflect.Descriptor instead.
func (*GatewayConfig) Descriptor() ([]byte, []int) {
- return file_values_types_proto_rawDescGZIP(), []int{1}
+ return file_values_types_proto_rawDescGZIP(), []int{0}
}
func (x *GatewayConfig) GetReplicaCount() *wrapperspb.Int32Value {
@@ -132,16 +89,19 @@ type GlobalConfig struct {
state protoimpl.MessageState `protogen:"open.v1"`
TrustDomain string `protobuf:"bytes,1,opt,name=trustDomain,proto3" json:"trustDomain,omitempty"`
StatusPort int64 `protobuf:"varint,2,opt,name=statusPort,proto3" json:"statusPort,omitempty"`
- Management *ManagementConfig `protobuf:"bytes,3,opt,name=management,proto3" json:"management,omitempty"`
ConfigValidation bool `protobuf:"varint,4,opt,name=configValidation,proto3" json:"configValidation,omitempty"`
Gateway *GatewayConfig `protobuf:"bytes,7,opt,name=gateway,proto3" json:"gateway,omitempty"`
- unknownFields protoimpl.UnknownFields
- sizeCache protoimpl.SizeCache
+ // Root for docker image paths.
+ Repo string `protobuf:"bytes,9,opt,name=repo,proto3" json:"repo,omitempty"`
+ // Version tag for docker images; supports numeric tags.
+ Tag *structpb.Value `protobuf:"bytes,10,opt,name=tag,proto3" json:"tag,omitempty"`
+ unknownFields protoimpl.UnknownFields
+ sizeCache protoimpl.SizeCache
}
func (x *GlobalConfig) Reset() {
*x = GlobalConfig{}
- mi := &file_values_types_proto_msgTypes[2]
+ mi := &file_values_types_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -153,7 +113,7 @@ func (x *GlobalConfig) String() string {
func (*GlobalConfig) ProtoMessage() {}
func (x *GlobalConfig) ProtoReflect() protoreflect.Message {
- mi := &file_values_types_proto_msgTypes[2]
+ mi := &file_values_types_proto_msgTypes[1]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -166,7 +126,7 @@ func (x *GlobalConfig) ProtoReflect() protoreflect.Message {
// Deprecated: Use GlobalConfig.ProtoReflect.Descriptor instead.
func (*GlobalConfig) Descriptor() ([]byte, []int) {
- return file_values_types_proto_rawDescGZIP(), []int{2}
+ return file_values_types_proto_rawDescGZIP(), []int{1}
}
func (x *GlobalConfig) GetTrustDomain() string {
@@ -183,13 +143,6 @@ func (x *GlobalConfig) GetStatusPort() int64 {
return 0
}
-func (x *GlobalConfig) GetManagement() *ManagementConfig {
- if x != nil {
- return x.Management
- }
- return nil
-}
-
func (x *GlobalConfig) GetConfigValidation() bool {
if x != nil {
return x.ConfigValidation
@@ -204,6 +157,20 @@ func (x *GlobalConfig) GetGateway() *GatewayConfig {
return nil
}
+func (x *GlobalConfig) GetRepo() string {
+ if x != nil {
+ return x.Repo
+ }
+ return ""
+}
+
+func (x *GlobalConfig) GetTag() *structpb.Value {
+ if x != nil {
+ return x.Tag
+ }
+ return nil
+}
+
type Values struct {
state protoimpl.MessageState `protogen:"open.v1"`
// Global configuration for dubbo components.
@@ -214,15 +181,19 @@ type Values struct {
// topology spread are added automatically above one. Wrapped so an explicit
// 1 is distinguishable from an unset field.
ReplicaCount *wrapperspb.Int32Value `protobuf:"bytes,3,opt,name=replicaCount,proto3" json:"replicaCount,omitempty"`
- // Control-plane image used by dubbod and its admission webhook.
- Image string `protobuf:"bytes,4,opt,name=image,proto3" json:"image,omitempty"`
+ // Control-plane image name, or a full repo/image:tag.
+ Image string `protobuf:"bytes,4,opt,name=image,proto3" json:"image,omitempty"`
+ // Version tag for control-plane docker images; supports numeric tags.
+ Tag *structpb.Value `protobuf:"bytes,5,opt,name=tag,proto3" json:"tag,omitempty"`
+ // Root for control-plane docker image paths.
+ Repo string `protobuf:"bytes,6,opt,name=repo,proto3" json:"repo,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *Values) Reset() {
*x = Values{}
- mi := &file_values_types_proto_msgTypes[3]
+ mi := &file_values_types_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -234,7 +205,7 @@ func (x *Values) String() string {
func (*Values) ProtoMessage() {}
func (x *Values) ProtoReflect() protoreflect.Message {
- mi := &file_values_types_proto_msgTypes[3]
+ mi := &file_values_types_proto_msgTypes[2]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -247,7 +218,7 @@ func (x *Values) ProtoReflect() protoreflect.Message {
// Deprecated: Use Values.ProtoReflect.Descriptor instead.
func (*Values) Descriptor() ([]byte, []int) {
- return file_values_types_proto_rawDescGZIP(), []int{3}
+ return file_values_types_proto_rawDescGZIP(), []int{2}
}
func (x *Values) GetGlobal() *GlobalConfig {
@@ -278,6 +249,20 @@ func (x *Values) GetImage() string {
return ""
}
+func (x *Values) GetTag() *structpb.Value {
+ if x != nil {
+ return x.Tag
+ }
+ return nil
+}
+
+func (x *Values) GetRepo() string {
+ if x != nil {
+ return x.Repo
+ }
+ return ""
+}
+
// IntOrString is a type that can hold an int32 or a string. When used in
// JSON or YAML marshalling and unmarshalling, it produces or consumes the
// inner type. This allows you to have, for example, a JSON field that can
@@ -298,7 +283,7 @@ type IntOrString struct {
func (x *IntOrString) Reset() {
*x = IntOrString{}
- mi := &file_values_types_proto_msgTypes[4]
+ mi := &file_values_types_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -310,7 +295,7 @@ func (x *IntOrString) String() string {
func (*IntOrString) ProtoMessage() {}
func (x *IntOrString) ProtoReflect() protoreflect.Message {
- mi := &file_values_types_proto_msgTypes[4]
+ mi := &file_values_types_proto_msgTypes[3]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -323,7 +308,7 @@ func (x *IntOrString) ProtoReflect() protoreflect.Message {
// Deprecated: Use IntOrString.ProtoReflect.Descriptor instead.
func (*IntOrString) Descriptor() ([]byte, []int) {
- return file_values_types_proto_rawDescGZIP(), []int{4}
+ return file_values_types_proto_rawDescGZIP(), []int{3}
}
func (x *IntOrString) GetType() int64 {
@@ -351,26 +336,27 @@ var File_values_types_proto protoreflect.FileDescriptor
const file_values_types_proto_rawDesc = "" +
"\n" +
- "\x12values_types.proto\x12\x17dubbo.operator.v1alpha1\x1a\x1egoogle/protobuf/wrappers.proto\"&\n" +
- "\x10ManagementConfig\x12\x12\n" +
- "\x04port\x18\x01 \x01(\x03R\x04port\"P\n" +
+ "\x12values_types.proto\x12\x17dubbo.operator.v1alpha1\x1a\x1egoogle/protobuf/wrappers.proto\x1a\x1cgoogle/protobuf/struct.proto\"P\n" +
"\rGatewayConfig\x12?\n" +
- "\freplicaCount\x18\x01 \x01(\v2\x1b.google.protobuf.Int32ValueR\freplicaCount\"\x9b\x02\n" +
+ "\freplicaCount\x18\x01 \x01(\v2\x1b.google.protobuf.Int32ValueR\freplicaCount\"\xa7\x02\n" +
"\fGlobalConfig\x12 \n" +
"\vtrustDomain\x18\x01 \x01(\tR\vtrustDomain\x12\x1e\n" +
"\n" +
"statusPort\x18\x02 \x01(\x03R\n" +
- "statusPort\x12I\n" +
- "\n" +
- "management\x18\x03 \x01(\v2).dubbo.operator.v1alpha1.ManagementConfigR\n" +
- "management\x12*\n" +
+ "statusPort\x12*\n" +
"\x10configValidation\x18\x04 \x01(\bR\x10configValidation\x12@\n" +
- "\agateway\x18\a \x01(\v2&.dubbo.operator.v1alpha1.GatewayConfigR\agatewayJ\x04\b\x05\x10\x06J\x04\b\x06\x10\aJ\x04\b\b\x10\t\"\xba\x01\n" +
+ "\agateway\x18\a \x01(\v2&.dubbo.operator.v1alpha1.GatewayConfigR\agateway\x12\x12\n" +
+ "\x04repo\x18\t \x01(\tR\x04repo\x12(\n" +
+ "\x03tag\x18\n" +
+ " \x01(\v2\x16.google.protobuf.ValueR\x03tagJ\x04\b\x03\x10\x04J\x04\b\x05\x10\x06J\x04\b\x06\x10\aJ\x04\b\b\x10\tR\x05adminR\n" +
+ "management\"\xf8\x01\n" +
"\x06Values\x12=\n" +
"\x06global\x18\x01 \x01(\v2%.dubbo.operator.v1alpha1.GlobalConfigR\x06global\x12\x1a\n" +
"\brevision\x18\x02 \x01(\tR\brevision\x12?\n" +
"\freplicaCount\x18\x03 \x01(\v2\x1b.google.protobuf.Int32ValueR\freplicaCount\x12\x14\n" +
- "\x05image\x18\x04 \x01(\tR\x05image\"\x8c\x01\n" +
+ "\x05image\x18\x04 \x01(\tR\x05image\x12(\n" +
+ "\x03tag\x18\x05 \x01(\v2\x16.google.protobuf.ValueR\x03tag\x12\x12\n" +
+ "\x04repo\x18\x06 \x01(\tR\x04repo\"\x8c\x01\n" +
"\vIntOrString\x12\x12\n" +
"\x04type\x18\x01 \x01(\x03R\x04type\x123\n" +
"\x06intVal\x18\x02 \x01(\v2\x1b.google.protobuf.Int32ValueR\x06intVal\x124\n" +
@@ -388,29 +374,30 @@ func file_values_types_proto_rawDescGZIP() []byte {
return file_values_types_proto_rawDescData
}
-var file_values_types_proto_msgTypes = make([]protoimpl.MessageInfo, 5)
+var file_values_types_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
var file_values_types_proto_goTypes = []any{
- (*ManagementConfig)(nil), // 0: dubbo.operator.v1alpha1.ManagementConfig
- (*GatewayConfig)(nil), // 1: dubbo.operator.v1alpha1.GatewayConfig
- (*GlobalConfig)(nil), // 2: dubbo.operator.v1alpha1.GlobalConfig
- (*Values)(nil), // 3: dubbo.operator.v1alpha1.Values
- (*IntOrString)(nil), // 4: dubbo.operator.v1alpha1.IntOrString
- (*wrapperspb.Int32Value)(nil), // 5: google.protobuf.Int32Value
+ (*GatewayConfig)(nil), // 0: dubbo.operator.v1alpha1.GatewayConfig
+ (*GlobalConfig)(nil), // 1: dubbo.operator.v1alpha1.GlobalConfig
+ (*Values)(nil), // 2: dubbo.operator.v1alpha1.Values
+ (*IntOrString)(nil), // 3: dubbo.operator.v1alpha1.IntOrString
+ (*wrapperspb.Int32Value)(nil), // 4: google.protobuf.Int32Value
+ (*structpb.Value)(nil), // 5: google.protobuf.Value
(*wrapperspb.StringValue)(nil), // 6: google.protobuf.StringValue
}
var file_values_types_proto_depIdxs = []int32{
- 5, // 0: dubbo.operator.v1alpha1.GatewayConfig.replicaCount:type_name -> google.protobuf.Int32Value
- 0, // 1: dubbo.operator.v1alpha1.GlobalConfig.management:type_name -> dubbo.operator.v1alpha1.ManagementConfig
- 1, // 2: dubbo.operator.v1alpha1.GlobalConfig.gateway:type_name -> dubbo.operator.v1alpha1.GatewayConfig
- 2, // 3: dubbo.operator.v1alpha1.Values.global:type_name -> dubbo.operator.v1alpha1.GlobalConfig
- 5, // 4: dubbo.operator.v1alpha1.Values.replicaCount:type_name -> google.protobuf.Int32Value
- 5, // 5: dubbo.operator.v1alpha1.IntOrString.intVal:type_name -> google.protobuf.Int32Value
- 6, // 6: dubbo.operator.v1alpha1.IntOrString.strVal:type_name -> google.protobuf.StringValue
- 7, // [7:7] is the sub-list for method output_type
- 7, // [7:7] is the sub-list for method input_type
- 7, // [7:7] is the sub-list for extension type_name
- 7, // [7:7] is the sub-list for extension extendee
- 0, // [0:7] is the sub-list for field type_name
+ 4, // 0: dubbo.operator.v1alpha1.GatewayConfig.replicaCount:type_name -> google.protobuf.Int32Value
+ 0, // 1: dubbo.operator.v1alpha1.GlobalConfig.gateway:type_name -> dubbo.operator.v1alpha1.GatewayConfig
+ 5, // 2: dubbo.operator.v1alpha1.GlobalConfig.tag:type_name -> google.protobuf.Value
+ 1, // 3: dubbo.operator.v1alpha1.Values.global:type_name -> dubbo.operator.v1alpha1.GlobalConfig
+ 4, // 4: dubbo.operator.v1alpha1.Values.replicaCount:type_name -> google.protobuf.Int32Value
+ 5, // 5: dubbo.operator.v1alpha1.Values.tag:type_name -> google.protobuf.Value
+ 4, // 6: dubbo.operator.v1alpha1.IntOrString.intVal:type_name -> google.protobuf.Int32Value
+ 6, // 7: dubbo.operator.v1alpha1.IntOrString.strVal:type_name -> google.protobuf.StringValue
+ 8, // [8:8] is the sub-list for method output_type
+ 8, // [8:8] is the sub-list for method input_type
+ 8, // [8:8] is the sub-list for extension type_name
+ 8, // [8:8] is the sub-list for extension extendee
+ 0, // [0:8] is the sub-list for field type_name
}
func init() { file_values_types_proto_init() }
@@ -424,7 +411,7 @@ func file_values_types_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: unsafe.Slice(unsafe.StringData(file_values_types_proto_rawDesc), len(file_values_types_proto_rawDesc)),
NumEnums: 0,
- NumMessages: 5,
+ NumMessages: 4,
NumExtensions: 0,
NumServices: 0,
},
diff --git a/operator/pkg/render/manifest.go b/operator/pkg/render/manifest.go
index a669b2be..2312f026 100644
--- a/operator/pkg/render/manifest.go
+++ b/operator/pkg/render/manifest.go
@@ -32,6 +32,7 @@ import (
"github.com/apache/dubbo-kubernetes/operator/pkg/util/clog"
"github.com/apache/dubbo-kubernetes/operator/pkg/values"
"github.com/apache/dubbo-kubernetes/pkg/kube"
+ pkgversion "github.com/apache/dubbo-kubernetes/pkg/version"
)
// MergeInputs merges the various configuration inputs into one single DubboOperator.
@@ -89,13 +90,57 @@ func MergeInputs(filenames []string, flags []string) (values.Map, error) {
path := ConfigBase.GetPathString("")
profile := ConfigBase.GetPathString("spec.profile")
+ userValues, _ := ConfigBase.GetPathMap("spec.values")
+ if userValues != nil {
+ userValues, err = values.MapFromJSON([]byte(userValues.JSON()))
+ if err != nil {
+ return nil, err
+ }
+ }
// Now we have the base
base, err := readProfile(path, profile)
if err != nil {
return base, err
}
+ if err := base.SetSpecPaths(repoTagOverlay()...); err != nil {
+ return nil, err
+ }
// Merge the user values on top
base.MergeFrom(ConfigBase)
+ base, err = translateDubboOperatorToHelm(base)
+ if err != nil {
+ return nil, err
+ }
+ // Explicit Helm values take precedence over top level settings.
+ if userValues != nil {
+ base.MergeFrom(values.Map{"spec": values.Map{"values": userValues}})
+ }
+ return base, nil
+}
+
+// repoTagOverlay overrides profile defaults with compiled repo/tag settings.
+func repoTagOverlay() []string {
+ repo := pkgversion.DockerInfo.Repo
+ tag := pkgversion.DockerInfo.Tag
+ if repo != "unknown" && tag != "unknown" {
+ return []string{"repo=" + repo, "tag=" + tag}
+ }
+ return nil
+}
+
+func translateDubboOperatorToHelm(base values.Map) (values.Map, error) {
+ for in, out := range map[string]string{
+ "spec.repo": "global.repo",
+ "spec.tag": "global.tag",
+ } {
+ v, found := base.GetPath(in)
+ if !found {
+ continue
+ }
+ if err := base.SetSpecPaths(fmt.Sprintf("values.%s=%v", out, v)); err != nil {
+ return nil, err
+ }
+ }
return base, nil
}
diff --git a/operator/pkg/render/manifest_test.go b/operator/pkg/render/manifest_test.go
index ad8b5de1..36b8dbfa 100644
--- a/operator/pkg/render/manifest_test.go
+++ b/operator/pkg/render/manifest_test.go
@@ -28,6 +28,9 @@ func TestGenerateManifestUsesEmbeddedInstallerAssets(t *testing.T) {
if err != nil {
t.Fatalf("GenerateManifest() error = %v", err)
}
+ if hasManifest(manifests, "Service", "dubbod-admin") || hasManifest(manifests, "Service", "dubbod-management") {
+ t.Fatal("removed management Service was rendered")
+ }
if len(manifests) == 0 {
t.Fatal("GenerateManifest() returned zero manifest sets")
}
@@ -213,7 +216,6 @@ func TestGenerateManifestExposesDubbodPrometheusScrapeEndpoint(t *testing.T) {
func TestGenerateManifestSetOverridesHelmValues(t *testing.T) {
manifests, _, err := GenerateManifest(nil, []string{
- "values.global.management.port=26081",
"values.global.trustDomain=example.local",
"values.global.statusPort=26021",
"values.global.configValidation=false",
@@ -223,28 +225,6 @@ func TestGenerateManifestSetOverridesHelmValues(t *testing.T) {
t.Fatalf("GenerateManifest() error = %v", err)
}
- managementService := findManifest(t, manifests, "Service", "dubbod-management")
- managementPort := findPort(t, managementService, "management")
- port, _, _ := unstructured.NestedInt64(managementPort, "port")
- targetPort, _, _ := unstructured.NestedInt64(managementPort, "targetPort")
- if port != 26081 || targetPort != 26081 {
- t.Fatalf("dubbod-management port=%d targetPort=%d, want 26081/26081", port, targetPort)
- }
-
- deployment := findManifest(t, manifests, "Deployment", "dubbod")
- containers, ok, err := unstructured.NestedSlice(deployment.Object, "spec", "template", "spec", "containers")
- if err != nil || !ok || len(containers) == 0 {
- t.Fatalf("deployment containers missing: ok=%v err=%v", ok, err)
- }
- execute := containers[0].(map[string]interface{})
- containerPorts, ok, err := unstructured.NestedSlice(execute, "ports")
- if err != nil || !ok {
- t.Fatalf("container ports missing: ok=%v err=%v", ok, err)
- }
- if !hasContainerPort(containerPorts, "management", 26081) {
- t.Fatal("dubbod deployment missing management containerPort 26081")
- }
-
configMap := findManifest(t, manifests, "ConfigMap", "dubbo")
if rev := configMap.GetLabels()["dubbo.apache.org/rev"]; rev != "canary" {
t.Fatalf("dubbo configmap revision label = %q, want canary", rev)
diff --git a/operator/pkg/values/map.go b/operator/pkg/values/map.go
index 4c3c777a..9eb1bb02 100644
--- a/operator/pkg/values/map.go
+++ b/operator/pkg/values/map.go
@@ -381,7 +381,11 @@ func extractKeyValue(seg string) (string, string, bool) {
}
// alwaysString represents types that should always be decoded as strings
-var alwaysString = []string{}
+var alwaysString = []string{
+ "spec.tag",
+ "spec.values.global.tag",
+ "spec.values.tag",
+}
func isAlwaysString(s string) bool {
for _, a := range alwaysString {
diff --git a/pkg/version/version.go b/pkg/version/version.go
index 66666c4c..f9d9d67d 100644
--- a/pkg/version/version.go
+++ b/pkg/version/version.go
@@ -28,8 +28,18 @@ var (
buildGitRevision = "unknown"
buildStatus = "unknown"
buildTag = "unknown"
+ buildRepo = "unknown"
+ buildRepoTag = "unknown"
)
+// DockerBuildInfo contains the compiled docker image root and version tag.
+type DockerBuildInfo struct {
+ Repo string
+ Tag string
+}
+
+var DockerInfo DockerBuildInfo
+
type BuildVersion struct {
Version string `json:"version"`
GitRevision string `json:"revision"`
@@ -164,6 +174,7 @@ func commandVersion() string {
}
func init() {
+ DockerInfo = DockerBuildInfo{Repo: buildRepo, Tag: buildRepoTag}
Build = BuildInfo{
Product: Product,
Version: version,