Skip to content

Commit f6a441a

Browse files
committed
add cluster name env in dashboard
1 parent 8dc9261 commit f6a441a

File tree

8 files changed

+29
-3
lines changed

8 files changed

+29
-3
lines changed

api/go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ require (
1111
github.com/gorilla/websocket v1.4.2
1212
github.com/joho/godotenv v1.3.0
1313
github.com/kalmhq/kalm/controller v0.0.0-20200722131031-2336d7eaf4c9
14+
github.com/kalmhq/kalm/operator v0.0.0-20210302081042-e6a4c5b51613 // indirect
1415
github.com/labstack/echo/v4 v4.1.17
1516
github.com/labstack/gommon v0.3.0
1617
github.com/mattn/go-sqlite3 v2.0.3+incompatible

api/go.sum

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,9 @@ github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1
511511
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
512512
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
513513
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
514+
github.com/kalmhq/kalm v0.2.0 h1:hoNGJr+Af3hvtYUmNvZnfoRvccsQ+Siog4kF2IFK2wo=
515+
github.com/kalmhq/kalm/operator v0.0.0-20210302081042-e6a4c5b51613 h1:H299jV80FUAKNTQ+2yuFP1A5wZv2zLNsNqn8pS+Z3+A=
516+
github.com/kalmhq/kalm/operator v0.0.0-20210302081042-e6a4c5b51613/go.mod h1:8f1Ile/g18s0oHaa12t/eHbyOtzocmu9bz0kcICEjXk=
514517
github.com/karrick/godirwalk v1.8.0/go.mod h1:H5KPZjojv4lE+QYImBI8xVtrBRgYrIVsaRPx4tDPEn4=
515518
github.com/karrick/godirwalk v1.10.3/go.mod h1:RoGL9dQei4vP9ilrpETWE8CLOZ1kiN0LhBygSwrAsHA=
516519
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
@@ -693,6 +696,7 @@ github.com/prometheus/procfs v0.0.11/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4
693696
github.com/prometheus/procfs v0.1.3 h1:F0+tqvhOksq22sc6iCHF5WGlWjdwj92p0udFh1VFBS8=
694697
github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU=
695698
github.com/prometheus/prom2json v1.1.0/go.mod h1:v7OY1795b9fEUZgq4UU2+15YjRv0LfpxKejIQCy3L7o=
699+
github.com/prometheus/prometheus v1.8.2/go.mod h1:oAIUtOny2rjMX0OWN5vPR5/q/twIROJvdqnQKDdil/s=
696700
github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
697701
github.com/quasilyte/go-consistent v0.0.0-20190521200055-c6f3937de18c/go.mod h1:5STLWrekHfjyYwxBRVRXNOSewLJ3PWfDJd1VyTS21fI=
698702
github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=

api/handler/cluster.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package handler
22

33
import (
44
"fmt"
5+
"os"
56
"strconv"
67
"strings"
78
"sync"
@@ -33,6 +34,7 @@ type ClusterInfo struct {
3334
CanBeInitialized bool `json:"canBeInitialized"`
3435
KubernetesVersion *version.Info `json:"kubernetesVersion"`
3536
KalmVersion *version.Info `json:"kalmVersion"`
37+
ClusterName string `json:"clusterName"`
3638
}
3739

3840
var KubernetesVersion *version.Info
@@ -98,6 +100,8 @@ func (h *ApiHandler) getClusterInfo(c echo.Context) *ClusterInfo {
98100
}
99101
}
100102

103+
info.ClusterName = os.Getenv("KALM_CLUSTER_NAME")
104+
101105
var certNotFound, routeNotFound, ssoNotFound bool
102106

103107
wg := sync.WaitGroup{}

controller/api/v1alpha1/const.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ const (
5454

5555
ENV_EXTERNAL_DNS_SERVER_IP = "EXTERNAL_DNS_SERVER_IP"
5656

57+
ENV_KALM_CLUSTER_NAME = "KALM_CLUSTER_NAME"
58+
5759
// auth-proxy
5860
ENV_NEED_EXTRA_OAUTH_SCOPE = "NEED_EXTRA_OAUTH_SCOPE"
5961
)

operator/api/v1alpha1/kalmoperatorconfig_types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ type BYOCModeConfig struct {
8181
// like: foobar.byoc-clusters.kalm-dns.com
8282
BaseDNSDomain string `json:"baseDNSDomain,omitempty"`
8383

84+
ClusterName string `json:"clusterName,omitempty"`
85+
8486
OIDCIssuer *OIDCIssuerConfig `json:"oidcIssuer,omitempty"`
8587
}
8688

operator/config/crd/bases/install.kalm.dev_kalmoperatorconfigs.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ spec:
4747
baseDashboardDomain:
4848
description: 'like: foobar.byoc.kalm.dev'
4949
type: string
50+
clusterName:
51+
type: string
5052
clusterUUID:
5153
type: string
5254
kalmSaaSDomain:

operator/controllers/dashboard.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ func getKalmDashboardCommand(configSpec installv1alpha1.KalmOperatorConfigSpec)
7272

7373
func getKalmDashboardEnvs(configSpec installv1alpha1.KalmOperatorConfigSpec) []corev1alpha1.EnvVar {
7474
var envs []corev1alpha1.EnvVar
75+
7576
if configSpec.Dashboard != nil {
7677
for _, nv := range configSpec.Dashboard.Envs {
7778
envs = append(envs, corev1alpha1.EnvVar{
@@ -83,8 +84,18 @@ func getKalmDashboardEnvs(configSpec installv1alpha1.KalmOperatorConfigSpec) []c
8384
}
8485

8586
var baseAppDomain string
86-
if configSpec.BYOCModeConfig != nil && configSpec.BYOCModeConfig.BaseAppDomain != "" {
87-
baseAppDomain = configSpec.BYOCModeConfig.BaseAppDomain
87+
if configSpec.BYOCModeConfig != nil {
88+
if configSpec.BYOCModeConfig.BaseAppDomain != "" {
89+
baseAppDomain = configSpec.BYOCModeConfig.BaseAppDomain
90+
}
91+
92+
if configSpec.BYOCModeConfig.ClusterName != "" {
93+
envs = append(envs, corev1alpha1.EnvVar{
94+
Name: v1alpha1.ENV_KALM_CLUSTER_NAME,
95+
Value: configSpec.BYOCModeConfig.ClusterName,
96+
Type: corev1alpha1.EnvVarTypeStatic,
97+
})
98+
}
8899
}
89100

90101
// BaseAppDomain

operator/controllers/resources.gen.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)