diff --git a/etc/cfg.yml b/etc/cfg.yml new file mode 100644 index 0000000..82b22bf --- /dev/null +++ b/etc/cfg.yml @@ -0,0 +1,41 @@ +# 当前域名 +debug: true +curldebug: true +prd: false +local: true +# 服务器参数 +srv_addr: ':1003' +# 缓存 +redis_addr: '120.24.28.6:32572' + +# 连接官网数据库获取db mapping +db: + host: '119.23.182.117:3306' + name: 'super_advertisement' + user: 'root' + psw: 'Fnuo123com@' + show_log: true + max_lifetime: 30 + max_open_conns: 100 + max_idle_conns: 100 + path: 'tmp/%s.log' + +# 日志 +log: + app_name: 'applet' + level: 'debug' # 普通日志级别 #debug, info, warn, fatal, panic + is_stdout: true + time_format: 'standard' # sec, second, milli, nano, standard, iso + encoding: 'console' + is_file_out: true + file_dir: './tmp/' + file_max_size: 256 + file_max_age: 1 + file_name: 'debug.log' + +# 连接RabbitMq +mq: + host: '116.62.62.35' + port: '5672' + user: 'zhios' + pwd: 'ZHIoscnfnuo123' \ No newline at end of file diff --git a/go.mod b/go.mod index 67e36ab..e5d313d 100644 --- a/go.mod +++ b/go.mod @@ -2,10 +2,10 @@ module applet go 1.18 -replace code.fnuoos.com/zhimeng/model.git => E:/company/ad/models +//replace code.fnuoos.com/zhimeng/model.git => E:/company/ad/models require ( - code.fnuoos.com/zhimeng/model.git v0.0.2 + code.fnuoos.com/zhimeng/model.git v0.0.3-0.20240816151818-a491f294f782 github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5 github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 github.com/boombuler/barcode v1.0.1 diff --git a/k8s/container.yaml b/k8s/container.yaml new file mode 100644 index 0000000..03a3178 --- /dev/null +++ b/k8s/container.yaml @@ -0,0 +1,90 @@ +kind: Deployment +apiVersion: apps/v1 +# 元数据 +metadata: + name: advertisement-agent + namespace: advertisement-agent + labels: + app: advertisement-agent + annotations: + kubesphere.io/creator: dengbiao + kubesphere.io/description: advertisement-agent +# deployment主要部分 +spec: + replicas: 1 + selector: + matchLabels: + # 名称与上面的labels对应 + app: advertisement-agent + template: + metadata: + labels: + # 名称与上面的matchLabels对应 + app: advertisement-agent + spec: + # 声明挂载卷(将外部已存在的pvc、config等挂载进来) + volumes: + # 用于时区校正 + - name: host-time + hostPath: + path: /etc/localtime + type: '' + # 将前面创建的configMap也挂载进来 + - name: advertisement-agent-cfg + configMap: + # 这里的名字就是前面创建的configMap的名字 + name: advertisement-agent-cfg + defaultMode: 420 + # pvc + - name: advertisement-agent-pvc # 在该部署中的名称,后面使用改名称挂载 + persistentVolumeClaim: + claimName: advertisement-agent-pvc # pvc的名称 + # Nginx配置 + - name: advertisement-agent-nginx + configMap: + name: advertisement-agent-nginx # 外部configMap的名称 + items: + - key: go.conf + path: default.conf + containers: + # 主容器 + - name: advertisement-agent-container + # 镜像地址(提前打包好并推送的镜像仓库) + image: 'registry.cn-shenzhen.aliyuncs.com/fnuoos-prd/advertisement-agent:0.0.1' + ports: + - name: ad-1003 + # 容器端口号(注意与golang web server启动的端口一致) + containerPort: 1003 + protocol: TCP + # 将前面volume声明的需要用到的pvc、config挂载上来 + volumeMounts: + - name: host-time + readOnly: true + mountPath: /etc/localtime + - name: advertisement-agent-cfg # 该名字对应前面volumes声明的名字 + readOnly: true + # 挂载到容器的哪个路径 + mountPath: /var/zyos + imagePullPolicy: Always + # Nginx 容器 + - name: nginx + image: 'registry.cn-shenzhen.aliyuncs.com/fnuoos-prd/nginx:latest' + ports: + - name: http-80 + containerPort: 80 + protocol: TCP + volumeMounts: + # 时区校正 + - name: host-time + readOnly: true + mountPath: /etc/localtime + # 存储卷 用于存放前端代码 + - name: advertisement-agent-pvc # 前面volumes声明的名称 + mountPath: /usr/share/nginx/html + - name: advertisement-agent-nginx # Nginx 配置 + readOnly: true + mountPath: /etc/nginx/conf.d/default.conf + subPath: default.conf + restartPolicy: Always + terminationGracePeriodSeconds: 30 + dnsPolicy: ClusterFirst \ No newline at end of file diff --git a/k8s/zyos-mall-deployment_prd.yaml b/k8s/container_prd.yaml similarity index 100% rename from k8s/zyos-mall-deployment_prd.yaml rename to k8s/container_prd.yaml diff --git a/k8s/ingress.yaml b/k8s/ingress.yaml new file mode 100644 index 0000000..78252e4 --- /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.agent.advertisement.dengbiao.top # 使用的域名 + http: + paths: + - path: / + pathType: ImplementationSpecific + backend: + serviceName: advertisement # 流量转发到的服务 + servicePort: 80 \ No newline at end of file diff --git a/k8s/mall-task-prd.yaml b/k8s/mall-task-prd.yaml deleted file mode 100644 index 1e592eb..0000000 --- a/k8s/mall-task-prd.yaml +++ /dev/null @@ -1,56 +0,0 @@ -kind: Deployment -apiVersion: apps/v1 -metadata: - name: mall-task - namespace: zhios - labels: - app: mall-task - annotations: - kubesphere.io/creator: wuhanqin - kubesphere.io/description: 自营商城go定时任务 -spec: - replicas: 1 - selector: - matchLabels: - app: mall-task - template: - metadata: - labels: - app: mall-task - spec: - volumes: - - name: host-time - hostPath: - path: /etc/localtime - type: '' - - name: mall-task-cfg1 - configMap: - name: zhios-mall-task - items: - - key: task.yml - path: task.yml - defaultMode: 420 - containers: - - name: container-mall-task - image: 'registry.cn-shenzhen.aliyuncs.com/fnuoos-prd/zyos-mall-task:0.3' - resources: - limits: - cpu: '1' - memory: 1000Mi - requests: - cpu: 200m - memory: 1000Mi - volumeMounts: - - name: host-time - readOnly: true - mountPath: /etc/localtime - - name: mall-task-cfg1 - readOnly: true - mountPath: /var/zyos/task.yml - subPath: task.yml - terminationMessagePath: /dev/termination-log - terminationMessagePolicy: File - imagePullPolicy: Always - restartPolicy: Always - terminationGracePeriodSeconds: 30 - dnsPolicy: ClusterFirst diff --git a/k8s/mall-task.yaml b/k8s/mall-task.yaml deleted file mode 100644 index 534392a..0000000 --- a/k8s/mall-task.yaml +++ /dev/null @@ -1,56 +0,0 @@ -kind: Deployment -apiVersion: apps/v1 -metadata: - name: mall-task - namespace: dev - labels: - app: mall-task - annotations: - kubesphere.io/creator: wuhanqin - kubesphere.io/description: 自营商城go定时任务 -spec: - replicas: 1 - selector: - matchLabels: - app: mall-task - template: - metadata: - labels: - app: mall-task - spec: - volumes: - - name: host-time - hostPath: - path: /etc/localtime - type: '' - - name: mall-task-cfg1 - configMap: - name: mall-task-cfg - items: - - key: task.yml - path: task.yml - defaultMode: 420 - containers: - - name: container-mall-task - image: 'registry.cn-shenzhen.aliyuncs.com/fnuoos-prd/zyos-mall-task:0.1' - resources: - limits: - cpu: '1' - memory: 1000Mi - requests: - cpu: 200m - memory: 1000Mi - volumeMounts: - - name: host-time - readOnly: true - mountPath: /etc/localtime - - name: mall-task-cfg1 - readOnly: true - mountPath: /var/zyos/task.yml - subPath: task.yml - terminationMessagePath: /dev/termination-log - terminationMessagePolicy: File - imagePullPolicy: Always - restartPolicy: Always - terminationGracePeriodSeconds: 30 - dnsPolicy: ClusterFirst