From 3e5501f12ec68fa9cac4b465e940675fc8498e25 Mon Sep 17 00:00:00 2001 From: dengbiao Date: Thu, 14 Nov 2024 17:46:53 +0800 Subject: [PATCH] updatea --- Dockerfile | 14 ++++++++------ go.mod | 14 +++++++------- k8s/container.yaml | 40 ++++++++++++++++++++-------------------- k8s/ingress.yaml | 17 +++++++++++++++++ k8s/ingress_prd.yaml | 20 ++++++++++++++++++++ 5 files changed, 72 insertions(+), 33 deletions(-) create mode 100644 k8s/ingress.yaml create mode 100644 k8s/ingress_prd.yaml diff --git a/Dockerfile b/Dockerfile index 650d62d..9b1787d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,23 +13,25 @@ WORKDIR /go/release # 把全部文件添加到/go/release目录 ADD . . -# 编译:把main.go编译成可执行的二进制文件,命名为zyos -RUN GOOS=linux CGO_ENABLED=0 GOARCH=amd64 go build -tags netgo -ldflags="-s -w" -installsuffix cgo -o zyos main.go +# 编译:把main.go编译成可执行的二进制文件,命名为egg +RUN GOOS=linux CGO_ENABLED=0 GOARCH=amd64 go build -tags netgo -ldflags="-s -w" -installsuffix cgo -o egg main.go FROM ubuntu:xenial as prod -LABEL maintainer="wuhanqin" +LABEL maintainer="dengbiao" ENV TZ="Asia/Shanghai" COPY static/html static/html +COPY docs docs + # 时区纠正 RUN rm -f /etc/localtime \ && ln -sv /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ && echo "Asia/Shanghai" > /etc/timezone # 在build阶段复制可执行的go二进制文件app -COPY --from=build /go/release/zyos ./zyos +COPY --from=build /go/release/egg ./egg -COPY --from=build /go/release/etc/cfg.yml /var/zyos/cfg.yml +COPY --from=build /go/release/etc/cfg.yml /var/egg/cfg.yml # 启动服务 -CMD ["./zyos","-c","/var/zyos/cfg.yml"] +CMD ["./egg","-c","/var/egg/cfg.yml"] diff --git a/go.mod b/go.mod index b1ee5e3..07c020c 100644 --- a/go.mod +++ b/go.mod @@ -2,9 +2,9 @@ module applet go 1.19 -replace code.fnuoos.com/EggPlanet/egg_models.git => E:/company/Egg/egg_models - -replace code.fnuoos.com/EggPlanet/egg_system_rules.git => E:/company/Egg/egg_system_rules +//replace code.fnuoos.com/EggPlanet/egg_models.git => E:/company/Egg/egg_models +// +//replace code.fnuoos.com/EggPlanet/egg_system_rules.git => E:/company/Egg/egg_system_rules require ( github.com/boombuler/barcode v1.0.1 @@ -34,11 +34,13 @@ require ( ) require ( - code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241112135742-0200baa0a923 - code.fnuoos.com/EggPlanet/egg_system_rules.git v0.0.2 + code.fnuoos.com/EggPlanet/egg_models.git v0.0.2 + code.fnuoos.com/EggPlanet/egg_system_rules.git v0.0.3 code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git v0.0.5 + github.com/aliyun/aliyun-oss-go-sdk v3.0.2+incompatible github.com/go-sql-driver/mysql v1.8.1 github.com/gocolly/colly v1.2.0 + github.com/shopspring/decimal v1.3.1 github.com/tidwall/gjson v1.14.1 ) @@ -47,7 +49,6 @@ require ( github.com/BurntSushi/toml v1.4.0 // indirect github.com/KyleBanks/depth v1.2.1 // indirect github.com/PuerkitoBio/goquery v1.9.2 // indirect - github.com/aliyun/aliyun-oss-go-sdk v3.0.2+incompatible // indirect github.com/andybalholm/cascadia v1.3.2 // indirect github.com/antchfx/htmlquery v1.3.3 // indirect github.com/antchfx/xmlquery v1.4.2 // indirect @@ -85,7 +86,6 @@ require ( github.com/pelletier/go-toml/v2 v2.2.1 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/saintfish/chardet v0.0.0-20230101081208-5e3ef4b5456d // indirect - github.com/shopspring/decimal v1.3.1 // indirect github.com/streadway/amqp v1.0.0 // indirect github.com/syndtr/goleveldb v1.0.0 // indirect github.com/temoto/robotstxt v1.1.2 // indirect diff --git a/k8s/container.yaml b/k8s/container.yaml index 3c96dc8..ea8c7b5 100644 --- a/k8s/container.yaml +++ b/k8s/container.yaml @@ -2,25 +2,25 @@ kind: Deployment apiVersion: apps/v1 # 元数据 metadata: - name: advertisement - namespace: advertisement + name: egg-admin + namespace: egg labels: - app: advertisement + app: egg-admin annotations: kubesphere.io/creator: dengbiao - kubesphere.io/description: advertisement + kubesphere.io/description: egg-admin # deployment主要部分 spec: replicas: 1 selector: matchLabels: # 名称与上面的labels对应 - app: advertisement + app: egg-admin template: metadata: labels: # 名称与上面的matchLabels对应 - app: advertisement + app: egg-admin spec: # 声明挂载卷(将外部已存在的pvc、config等挂载进来) volumes: @@ -30,41 +30,41 @@ spec: path: /etc/localtime type: '' # 将前面创建的configMap也挂载进来 - - name: advertisement-cfg + - name: egg-admin-cfg configMap: # 这里的名字就是前面创建的configMap的名字 - name: advertisement-cfg + name: egg-admin-cfg defaultMode: 420 # pvc - - name: advertisement # 在该部署中的名称,后面使用改名称挂载 + - name: egg-admin # 在该部署中的名称,后面使用改名称挂载 persistentVolumeClaim: - claimName: advertisement # pvc的名称 + claimName: egg-admin # pvc的名称 # Nginx配置 - - name: advertisement-nginx + - name: egg-admin-nginx configMap: - name: advertisement-nginx # 外部configMap的名称 + name: egg-admin-nginx # 外部configMap的名称 items: - key: go.conf path: default.conf containers: # 主容器 - - name: advertisement-container + - name: egg-admin-container # 镜像地址(提前打包好并推送的镜像仓库) - image: 'registry.cn-shenzhen.aliyuncs.com/fnuoos-prd/advertisement:0.0.1' + image: 'registry.cn-shenzhen.aliyuncs.com/fnuoos-prd/egg-admin:0.0.1' ports: - - name: ad-1002 + - name: egg-admin-4001 # 容器端口号(注意与golang web server启动的端口一致) - containerPort: 1002 + containerPort: 4001 protocol: TCP # 将前面volume声明的需要用到的pvc、config挂载上来 volumeMounts: - name: host-time readOnly: true mountPath: /etc/localtime - - name: advertisement-cfg # 该名字对应前面volumes声明的名字 + - name: egg-admin-cfg # 该名字对应前面volumes声明的名字 readOnly: true # 挂载到容器的哪个路径 - mountPath: /var/zyos + mountPath: /var/egg imagePullPolicy: Always # Nginx 容器 - name: nginx @@ -79,9 +79,9 @@ spec: readOnly: true mountPath: /etc/localtime # 存储卷 用于存放前端代码 - - name: advertisement # 前面volumes声明的名称 + - name: egg-admin # 前面volumes声明的名称 mountPath: /usr/share/nginx/html - - name: advertisement-nginx # Nginx 配置 + - name: egg-admin-nginx # Nginx 配置 readOnly: true mountPath: /etc/nginx/conf.d/default.conf subPath: default.conf diff --git a/k8s/ingress.yaml b/k8s/ingress.yaml new file mode 100644 index 0000000..3e2d6c0 --- /dev/null +++ b/k8s/ingress.yaml @@ -0,0 +1,17 @@ +kind: Ingress +apiVersion: extensions/v1beta1 +metadata: + name: advertisement # ingress名称 + namespace: advertisement + annotations: + kubesphere.io/creator: dengbiao +spec: + rules: + - host: 123456.advertisement.dengbiao.top # 使用的域名 + http: + paths: + - path: / + pathType: ImplementationSpecific + backend: + serviceName: advertisement # 流量转发到的服务 + servicePort: 80 \ No newline at end of file diff --git a/k8s/ingress_prd.yaml b/k8s/ingress_prd.yaml new file mode 100644 index 0000000..cb70a46 --- /dev/null +++ b/k8s/ingress_prd.yaml @@ -0,0 +1,20 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + annotations: + cert-manager.io/cluster-issuer: letsencrypt-prod + kubesphere.io/creator: dengbiao + name: advertisement + namespace: advertisement +spec: + rules: + - host: '*.adcms.zhiyingos.cn' + http: + paths: + - backend: + service: + name: advertisement + port: + number: 80 + path: / + pathType: ImplementationSpecific