Skip to content

Commit e88c185

Browse files
authored
fix: 修改k8s部署,增加ingress,容器化CICD开启。 (flipped-aurora#1158)
1 parent a5d2cc1 commit e88c185

13 files changed

+65
-33
lines changed

.github/workflows/docker-cicd.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,14 @@ jobs:
1919
- name: Sed Config
2020
shell: bash
2121
run: |
22-
sed -i 's#./entrypoint.sh"#./entrypoint.sh","actions"#g' Dockerfile
23-
sed -i "s#COPY build/ /usr/share/nginx/html/#COPY . /opt/gva#g" Dockerfile
24-
sed -i 16c"\ && cd /opt/gva/server/ && go mod tidy && cd /opt/gva/web/ && yarn" Dockerfile
22+
sed -i 51c"\ && yarn install && yarn build" Makefile
23+
make image TAGS_OPT="latest"
24+
sed -i 's#./entrypoint.sh"#./entrypoint.sh","actions"#g' deploy/docker/Dockerfile
25+
sed -i "s#COPY build/ /usr/share/nginx/html/#COPY . /opt/gva#g" deploy/docker/Dockerfile
26+
sed -i 16c"\ && cd /opt/gva/server/ && go mod tidy && cd /opt/gva/web/ && yarn" deploy/docker/Dockerfile
2527
sed -i "s#open: true#open: false#g" web/vite.config.js
2628
make images TAGS_OPT="latest"
29+
docker push registry.cn-hangzhou.aliyuncs.com/gva/gin-vue-admin:latest
2730
docker push registry.cn-hangzhou.aliyuncs.com/gva/web:latest
2831
docker push registry.cn-hangzhou.aliyuncs.com/gva/server:latest
2932
docker push registry.cn-hangzhou.aliyuncs.com/gva/all:latest

Makefile

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
11
SHELL = /bin/bash
22

3-
CONFIG_FILE = config.yaml
4-
PROJECT_NAME = github.com/flipped-aurora/gin-vue-admin/server
53
#SCRIPT_DIR = $(shell pwd)/etc/script
4+
#请选择golang版本
65
BUILD_IMAGE_SERVER = golang:1.16
6+
#请选择node版本
77
BUILD_IMAGE_WEB = node:16
8+
#项目名称
9+
PROJECT_NAME = github.com/flipped-aurora/gin-vue-admin/server
10+
#配置文件目录
11+
CONFIG_FILE = config.yaml
12+
#镜像仓库命名空间
813
IMAGE_NAME = gva
14+
#镜像地址
915
REPOSITORY = registry.cn-hangzhou.aliyuncs.com/${IMAGE_NAME}
1016

1117
ifeq ($(TAGS_OPT),)
12-
TAGS_OPT = 2.5.0b
18+
TAGS_OPT = latest
1319
else
1420
endif
1521

@@ -42,8 +48,7 @@ build-local:
4248
#本地环境打包前端
4349
build-web-local:
4450
@cd web/ && if [ -d "dist" ];then rm -rf dist; else echo "OK!"; fi \
45-
&& yarn config set registry http://mirrors.cloud.tencent.com/npm/ \
46-
&& yarn install && yarn build
51+
&& yarn config set registry http://mirrors.cloud.tencent.com/npm/ && yarn install && yarn build
4752

4853
#本地环境打包后端
4954
build-server-local:
@@ -54,8 +59,8 @@ build-server-local:
5459

5560
#打包前后端二合一镜像
5661
image: build
57-
docker build -t ${REPOSITORY}/all-one:${TAGS_OPT} .
62+
docker build -t ${REPOSITORY}/gin-vue-admin:${TAGS_OPT} -f deploy/docker/Dockerfile .
5863

5964
#尝鲜版
6065
images: build build-image-web build-image-server
61-
docker build -t ${REPOSITORY}/all:${TAGS_OPT} .
66+
docker build -t ${REPOSITORY}/all:${TAGS_OPT} -f deploy/docker/Dockerfile .
File renamed without changes.

Dockerfile renamed to deploy/docker/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
FROM centos:7
22
WORKDIR /opt
33
ENV LANG=en_US.utf8
4-
COPY entrypoint.sh .
4+
COPY deploy/docker/entrypoint.sh .
55
COPY build/ /usr/share/nginx/html/
66
COPY server/config.yaml /usr/share/nginx/html/config.yaml
77
COPY web/.docker-compose/nginx/conf.d/nginx.conf /etc/nginx/conf.d/nginx.conf
File renamed without changes.

deployment/server/gva-server-deployment.yaml renamed to deploy/kubernetes/server/gva-server-deployment.yaml

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ spec:
2323
spec:
2424
containers:
2525
- name: gin-vue-admin-container
26-
image: registry.cn-hangzhou.aliyuncs.com/gin-vue-admin/server:40fc3aa6
27-
imagePullPolicy: IfNotPresent
26+
image: registry.cn-hangzhou.aliyuncs.com/gva/server:latest
27+
imagePullPolicy: Always
2828
ports:
2929
- containerPort: 8888
3030
name: http
@@ -41,22 +41,28 @@ spec:
4141
requests:
4242
cpu: 100m
4343
memory: 200Mi
44-
# readinessProbe:
45-
# httpGet:
46-
# path: /ready
47-
# port: http
48-
# initialDelaySeconds: 20
49-
# periodSeconds: 10
50-
# successThreshold: 1
51-
# failureThreshold: 3
52-
# livenessProbe:
53-
# httpGet:
54-
# path: /health
55-
# port: http
56-
# initialDelaySeconds: 20
57-
# periodSeconds: 10
58-
# successThreshold: 1
59-
# failureThreshold: 3
44+
livenessProbe:
45+
failureThreshold: 1
46+
periodSeconds: 5
47+
successThreshold: 1
48+
tcpSocket:
49+
port: 8888
50+
timeoutSeconds: 1
51+
readinessProbe:
52+
failureThreshold: 3
53+
initialDelaySeconds: 30
54+
periodSeconds: 5
55+
successThreshold: 1
56+
tcpSocket:
57+
port: 8888
58+
timeoutSeconds: 1
59+
startupProbe:
60+
failureThreshold: 40
61+
periodSeconds: 5
62+
successThreshold: 1
63+
tcpSocket:
64+
port: 8888
65+
timeoutSeconds: 1
6066
#imagePullSecrets:
6167
# - name: docker-registry
6268
volumes:

deployment/web/gva-web-deploymemt.yaml renamed to deploy/kubernetes/web/gva-web-deploymemt.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ spec:
2323
spec:
2424
containers:
2525
- name: gin-vue-admin-nginx-container
26-
image: registry.cn-hangzhou.aliyuncs.com/gin-vue-admin/web:40fc3aa6
27-
imagePullPolicy: IfNotPresent
26+
image: registry.cn-hangzhou.aliyuncs.com/gva/web:latest
27+
imagePullPolicy: Always
2828
ports:
2929
- containerPort: 8080
3030
name: http
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
apiVersion: networking.k8s.io/v1
2+
kind: Ingress
3+
metadata:
4+
name: gva-ingress
5+
annotations:
6+
kubernetes.io/ingress.class: "nginx"
7+
spec:
8+
rules:
9+
- host: demo.gin-vue-admin.com
10+
http:
11+
paths:
12+
- path: /
13+
pathType: Prefix
14+
backend:
15+
service:
16+
name: gva-web
17+
port:
18+
number: 8080

deployment/web/gva-web-service.yaml renamed to deploy/kubernetes/web/gva-web-service.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ metadata:
1010
app: gva-web
1111
version: gva-vue3
1212
spec:
13-
type: NodePort
14-
# type: ClusterIP
13+
# type: NodePort
14+
type: ClusterIP
1515
ports:
1616
- name: http
1717
port: 8080

0 commit comments

Comments
 (0)