Browse Source

update

master
dengbiao 1 week ago
parent
commit
53d21efba6
2 changed files with 16 additions and 18 deletions
  1. +5
    -6
      Dockerfile
  2. +11
    -12
      k8s/zyos-go-mq-consume-prd.yaml

+ 5
- 6
Dockerfile View File

@@ -12,23 +12,22 @@ WORKDIR /go/release
# 把全部文件添加到/go/release目录 # 把全部文件添加到/go/release目录
ADD . . 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 FROM ubuntu:xenial as prod
LABEL maintainer="dengbiao" LABEL maintainer="dengbiao"
ENV TZ="Asia/Shanghai" ENV TZ="Asia/Shanghai"


COPY static/html static/html
# 时区纠正 # 时区纠正
RUN rm -f /etc/localtime \ RUN rm -f /etc/localtime \
&& ln -sv /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ && ln -sv /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
&& echo "Asia/Shanghai" > /etc/timezone && echo "Asia/Shanghai" > /etc/timezone
# 在build阶段复制可执行的go二进制文件app # 在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"]



+ 11
- 12
k8s/zyos-go-mq-consume-prd.yaml View File

@@ -2,25 +2,24 @@ kind: Deployment
apiVersion: apps/v1 apiVersion: apps/v1
# 元数据 # 元数据
metadata: metadata:
name: zyos-go-mq-consume-one-circles-v2
namespace: zhios
name: egg-go-mq-consume
namespace: egg
labels: labels:
app: zyos-go-mq-consume-one-circles-v2
app: egg-go-mq-consume
annotations: annotations:
kubesphere.io/creator: dengbiao kubesphere.io/creator: dengbiao
kubesphere.io/description: 一个圈圈v2
# deployment主要部分 # deployment主要部分
spec: spec:
replicas: 1 replicas: 1
selector: selector:
matchLabels: matchLabels:
# 名称与上面的labels对应 # 名称与上面的labels对应
app: zyos-go-mq-consume-one-circles-v2
app: egg-go-mq-consume
template: template:
metadata: metadata:
labels: labels:
# 名称与上面的matchLabels对应 # 名称与上面的matchLabels对应
app: zyos-go-mq-consume-one-circles-v2
app: egg-go-mq-consume
spec: spec:
# 声明挂载卷(将外部已存在的pvc、config等挂载进来) # 声明挂载卷(将外部已存在的pvc、config等挂载进来)
volumes: volumes:
@@ -30,25 +29,25 @@ spec:
path: /etc/localtime path: /etc/localtime
type: '' type: ''
# 将前面创建的configMap也挂载进来 # 将前面创建的configMap也挂载进来
- name: zyos-go-mq-consume-cfg
- name: egg-go-mq-consume-cfg
configMap: configMap:
# 这里的名字就是前面创建的configMap的名字 # 这里的名字就是前面创建的configMap的名字
name: zyos-go-mq-consume-cfg
name: egg-go-mq-consume-cfg
defaultMode: 420 defaultMode: 420
containers: containers:
# 主容器 # 主容器
- name: zyos-go-mq-consume-one-circles-v2-container
- name: egg-go-mq-consume
# 镜像地址(提前打包好并推送的镜像仓库) # 镜像地址(提前打包好并推送的镜像仓库)
image: 'registry.cn-shenzhen.aliyuncs.com/fnuoos-prd/zyos-go-mq-consume-one-circles-v2:20240727-01'
image: 'registry.cn-shenzhen.aliyuncs.com/fnuoos-prd/egg-go-mq-consume:0.0.1'
# 将前面volume声明的需要用到的pvc、config挂载上来 # 将前面volume声明的需要用到的pvc、config挂载上来
volumeMounts: volumeMounts:
- name: host-time - name: host-time
readOnly: true readOnly: true
mountPath: /etc/localtime mountPath: /etc/localtime
- name: zyos-go-mq-consume-cfg # 该名字对应前面volumes声明的名字
- name: egg-go-mq-consume-cfg # 该名字对应前面volumes声明的名字
readOnly: true readOnly: true
# 挂载到容器的哪个路径 # 挂载到容器的哪个路径
mountPath: /var/zyos
mountPath: /var/egg
imagePullPolicy: Always imagePullPolicy: Always
restartPolicy: Always restartPolicy: Always
terminationGracePeriodSeconds: 30 terminationGracePeriodSeconds: 30

Loading…
Cancel
Save