Skip to content

Commit 35cbd34

Browse files
authored
feat: kubernetes deployment manifests and docker file (#1410)
* refactor: refactor dockerfile and implement dubbo-admin deployment * fix: deploy manifests
1 parent dc5eb0d commit 35cbd34

5 files changed

Lines changed: 190 additions & 121 deletions

File tree

Dockerfile

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,29 +13,46 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16-
# Build the manager binary
17-
FROM docker.io/golang:1.24 AS builder
16+
# Build frontend
17+
FROM swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/node:18-alpine AS frontend-builder
18+
19+
WORKDIR /ui-vue3
20+
21+
COPY ui-vue3/package.json ui-vue3/yarn.lock ./
22+
RUN yarn install --frozen-lockfile
23+
COPY ui-vue3/ ./
24+
RUN yarn build
25+
26+
27+
# Build backend
28+
FROM swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/golang:1.24 AS builder
1829
ARG TARGETOS
1930
ARG TARGETARCH
2031

2132
WORKDIR /app
33+
ENV GOPROXY=https://goproxy.cn,direct
2234

23-
COPY go.mod go.mod
24-
COPY go.sum go.sum
35+
COPY go.mod go.sum ./
36+
RUN go mod download
37+
38+
COPY . .
39+
COPY --from=frontend-builder /ui-vue3/dist app/dubbo-ui/dist
2540

26-
ENV GOPROXY=https://goproxy.cn,direct
2741

28-
# cache deps before building and copying source so that we don't need to re-download as much
29-
# and so that source changes don't invalidate our downloaded layer
30-
RUN go env && go mod download
42+
RUN CGO_ENABLED=0 \
43+
GOOS=${TARGETOS:-linux} \
44+
GOARCH=${TARGETARCH:-amd64} \
45+
go build -a -o dubbo-admin ./app/dubbo-admin/main.go
3146

32-
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o dubbo-admin ./app/dubbo-admin/main.go
3347

3448
# Use distroless as minimal base image to package the manager binary
3549
# Refer to https://github.com/GoogleContainerTools/distroless for more details
36-
FROM gcr.io/distroless/static:nonroot
37-
WORKDIR /
38-
COPY --from=builder /app/dubbo-admin .
50+
FROM swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/library/alpine:3.20
51+
RUN addgroup -g 65532 app \
52+
&& adduser -D -u 65532 -G app app
53+
54+
WORKDIR /app
55+
COPY --from=builder /app/dubbo-admin /app/dubbo-admin
3956
USER 65532:65532
4057

41-
ENTRYPOINT ["./dubbo-admin","run"]
58+
ENTRYPOINT ["./dubbo-admin"]

release/kubernetes/dubbo-samples-shop/dubbo-samples-shop-all.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ metadata:
2929
labels:
3030
org.apache.dubbo/service: dubbo-qos
3131
spec:
32-
type: NodePort
32+
type: ClusterIP
3333
sessionAffinity: None
3434
selector:
3535
app-type: dubbo
@@ -45,7 +45,7 @@ metadata:
4545
name: shop-frontend
4646
namespace: dubbo-samples-shop
4747
spec:
48-
type: NodePort
48+
type: ClusterIP
4949
sessionAffinity: None
5050
selector:
5151
app: shop-frontend

release/kubernetes/dubbo-system/dubbo-admin-legacy.yaml

Lines changed: 0 additions & 71 deletions
This file was deleted.
Lines changed: 126 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
1-
# Licensed to the Apache Software Foundation (ASF) under one or more
2-
# contributor license agreements. See the NOTICE file distributed with
3-
# this work for additional information regarding copyright ownership.
4-
# The ASF licenses this file to You under the Apache License, Version 2.0
5-
# (the "License"); you may not use this file except in compliance with
6-
# the License. You may obtain a copy of the License at
7-
#
8-
# http://www.apache.org/licenses/LICENSE-2.0
9-
#
10-
# Unless required by applicable law or agreed to in writing, software
11-
# distributed under the License is distributed on an "AS IS" BASIS,
12-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
# See the License for the specific language governing permissions and
14-
# limitations under the License.
15-
1+
# Licensed to the Apache Software Foundation (ASF) under one or more
2+
# contributor license agreements. See the NOTICE file distributed with
3+
# this work for additional information regarding copyright ownership.
4+
# The ASF licenses this file to You under the Apache License, Version 2.0
5+
# (the "License"); you may not use this file except in compliance with
6+
# the License. You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
1616
apiVersion: apps/v1
1717
kind: Deployment
1818
metadata:
1919
name: dubbo-admin
20+
namespace: dubbo-system
2021
labels:
2122
app: dubbo-admin
2223
spec:
23-
replicas: 2
24+
replicas: 1
2425
selector:
2526
matchLabels:
2627
app: dubbo-admin
@@ -30,26 +31,132 @@ spec:
3031
labels:
3132
app: dubbo-admin
3233
spec:
34+
securityContext:
35+
runAsUser: 65532
36+
runAsGroup: 65532
37+
fsGroup: 65532
38+
runAsNonRoot: true
39+
serviceAccountName: dubbo-admin
3340
containers:
3441
- name: dubbo-admin
35-
image:
42+
image: apache/dubbo-admin:0.7.0
3643
imagePullPolicy: IfNotPresent
44+
volumeMounts:
45+
- mountPath: /etc/dubbo-admin
46+
name: dubbo-admin-config
47+
readOnly: true
48+
- name: dubbo-admin-logs
49+
mountPath: /app/logs
50+
command:
51+
- /app/dubbo-admin
52+
args:
53+
- run
54+
- -c
55+
- /etc/dubbo-admin/dubbo-admin.yaml
56+
livenessProbe:
57+
httpGet:
58+
port: 5680
59+
path: /healthy
60+
scheme: HTTP
61+
initialDelaySeconds: 20
62+
periodSeconds: 10
63+
timeoutSeconds: 5
64+
successThreshold: 1
65+
failureThreshold: 3
66+
readinessProbe:
67+
httpGet:
68+
port: 5680
69+
path: /ready
70+
scheme: HTTP
71+
initialDelaySeconds: 10
72+
periodSeconds: 10
73+
timeoutSeconds: 5
74+
successThreshold: 1
75+
failureThreshold: 3
3776
ports:
3877
- containerPort: 8888
3978
protocol: TCP
4079
restartPolicy: Always
80+
volumes:
81+
- name: dubbo-admin-config
82+
configMap:
83+
name: dubbo-admin-config
84+
- name: dubbo-admin-logs
85+
# You can replace it with hostPath or pvc to store logs.
86+
emptyDir: { }
87+
---
88+
apiVersion: v1
89+
kind: ConfigMap
90+
metadata:
91+
name: dubbo-admin-config
92+
namespace: dubbo-system
4193

94+
data:
95+
dubbo-admin.yaml: |
96+
observability:
97+
grafana: http://grafana.monitoringg.svc:3000
98+
prometheus: http://prometheus-k8s.monitoring.svc:9090/
99+
console:
100+
auth:
101+
user: admin
102+
password: dubbo@2025
103+
expirationTime: 3600
104+
discovery:
105+
- type: nacos2
106+
name: nacos2.5-standalone
107+
id: nacos2.5
108+
address:
109+
registry: nacos://nacos.dubbo-system.svc:8848?username=nacos&password=nacos
110+
configCenter: nacos://nacos.dubbo-system.svc:8848?username=nacos&password=nacos
111+
metadataReport: nacos://nacos.dubbo-system.svc:8848?username=nacos&password=nacos
112+
engine:
113+
id: default
114+
name: default
115+
type: kubernetes
42116
---
43117
apiVersion: v1
44118
kind: Service
45119
metadata:
46120
name: dubbo-admin
47121
namespace: dubbo-system
48122
spec:
49-
type: NodePort
123+
type: ClusterIP
50124
selector:
51125
app: dubbo-admin
52126
ports:
53127
- protocol: TCP
54128
port: 8888
55-
targetPort: 8888
129+
targetPort: 8888
130+
131+
---
132+
apiVersion: rbac.authorization.k8s.io/v1
133+
kind: ClusterRole
134+
metadata:
135+
name: dubbo-admin-cluster-role
136+
rules:
137+
- apiGroups: [""]
138+
resources: ["pods", "services"]
139+
verbs: ["get", "list", "watch"]
140+
- apiGroups: ["apps"]
141+
resources: ["deployments", "statefulsets", "replicasets"]
142+
verbs: ["get", "list", "watch"]
143+
---
144+
apiVersion: v1
145+
kind: ServiceAccount
146+
metadata:
147+
name: dubbo-admin
148+
namespace: dubbo-system
149+
150+
---
151+
apiVersion: rbac.authorization.k8s.io/v1
152+
kind: ClusterRoleBinding
153+
metadata:
154+
name: dubbo-admin-cluster-binding
155+
subjects:
156+
- kind: ServiceAccount
157+
name: dubbo-admin
158+
namespace: dubbo-system
159+
roleRef:
160+
kind: ClusterRole
161+
name: dubbo-admin-cluster-role
162+
apiGroup: rbac.authorization.k8s.io

release/kubernetes/dubbo-system/nacos.yaml

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
# Licensed to the Apache Software Foundation (ASF) under one or more
2-
# contributor license agreements. See the NOTICE file distributed with
3-
# this work for additional information regarding copyright ownership.
4-
# The ASF licenses this file to You under the Apache License, Version 2.0
5-
# (the "License"); you may not use this file except in compliance with
6-
# the License. You may obtain a copy of the License at
7-
#
8-
# http://www.apache.org/licenses/LICENSE-2.0
9-
#
10-
# Unless required by applicable law or agreed to in writing, software
11-
# distributed under the License is distributed on an "AS IS" BASIS,
12-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
# See the License for the specific language governing permissions and
14-
# limitations under the License.
15-
1+
# Licensed to the Apache Software Foundation (ASF) under one or more
2+
# contributor license agreements. See the NOTICE file distributed with
3+
# this work for additional information regarding copyright ownership.
4+
# The ASF licenses this file to You under the Apache License, Version 2.0
5+
# (the "License"); you may not use this file except in compliance with
6+
# the License. You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
1616
# Nacos
1717
apiVersion: apps/v1
1818
kind: Deployment
@@ -33,6 +33,22 @@ spec:
3333
- name: consumer
3434
image: swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/nacos/nacos-server:v2.5.2
3535
imagePullPolicy: IfNotPresent
36+
livenessProbe:
37+
tcpSocket:
38+
port: 8848
39+
initialDelaySeconds: 20
40+
timeoutSeconds: 5
41+
periodSeconds: 10
42+
failureThreshold: 3
43+
successThreshold: 1
44+
readinessProbe:
45+
tcpSocket:
46+
port: 8848
47+
initialDelaySeconds: 10
48+
timeoutSeconds: 5
49+
periodSeconds: 10
50+
failureThreshold: 3
51+
successThreshold: 1
3652
ports:
3753
- containerPort: 8848
3854
name: client
@@ -60,7 +76,7 @@ metadata:
6076
name: nacos
6177
namespace: dubbo-system
6278
spec:
63-
type: NodePort
79+
type: ClusterIP
6480
sessionAffinity: None
6581
selector:
6682
app: nacos

0 commit comments

Comments
 (0)