作者 唐旭辉

配置修改

1 package config 1 package config
2 2
3 import ( 3 import (
  4 + "fmt"
  5 +
4 "github.com/astaxie/beego" 6 "github.com/astaxie/beego"
5 ) 7 )
6 8
@@ -20,9 +22,17 @@ type MyConfig struct { @@ -20,9 +22,17 @@ type MyConfig struct {
20 var MConfig *MyConfig 22 var MConfig *MyConfig
21 23
22 func RestMyConfig() *MyConfig { 24 func RestMyConfig() *MyConfig {
  25 + mysqlHost := beego.AppConfig.String("mysql_host")
  26 + mysqlPort := beego.AppConfig.String("mysql_port")
  27 + mysqlUser := beego.AppConfig.String("mysql_user")
  28 + mysqlPassword := beego.AppConfig.String("mysql_password")
  29 + mysqlDBname := beego.AppConfig.String("mysql_db_name")
  30 + sqlconn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s",
  31 + mysqlUser, mysqlPassword, mysqlHost, mysqlPort, mysqlDBname)
  32 + sqlconn = sqlconn + "?charset=utf8&loc=Asia%2FShanghai"
23 MConfig = &MyConfig{ 33 MConfig = &MyConfig{
24 ConfigName: beego.AppConfig.String("config_name"), 34 ConfigName: beego.AppConfig.String("config_name"),
25 - SqlConn: beego.AppConfig.String("sqlconn"), 35 + SqlConn: sqlconn,
26 RedisAddPort: beego.AppConfig.String("redis_add_port"), 36 RedisAddPort: beego.AppConfig.String("redis_add_port"),
27 RedisAuth: beego.AppConfig.DefaultString("redis_auth", ""), 37 RedisAuth: beego.AppConfig.DefaultString("redis_auth", ""),
28 RedisDB: beego.AppConfig.DefaultString("redis_db", "0"), 38 RedisDB: beego.AppConfig.DefaultString("redis_db", "0"),
@@ -30,6 +40,5 @@ func RestMyConfig() *MyConfig { @@ -30,6 +40,5 @@ func RestMyConfig() *MyConfig {
30 LogFilename: beego.AppConfig.DefaultString("log_filename", "./log/ability.log"), 40 LogFilename: beego.AppConfig.DefaultString("log_filename", "./log/ability.log"),
31 LogLevel: beego.AppConfig.DefaultString("log_Level", "debug"), 41 LogLevel: beego.AppConfig.DefaultString("log_Level", "debug"),
32 } 42 }
33 -  
34 return MConfig 43 return MConfig
35 } 44 }
@@ -10,14 +10,18 @@ AdminPort = 8088 @@ -10,14 +10,18 @@ AdminPort = 8088
10 10
11 #---自定义配置 开始---- 11 #---自定义配置 开始----
12 ##数据库连接 12 ##数据库连接
13 -# sqlconn ="${MYSQL_CONN||root:root@tcp(127.0.0.1:3306)/opportunity_dev?charset=utf8}"  
14 -sqlconn ="${MYSQL_CONN||root:sutianxia2015@tcp(115.29.205.99:3306)/opportunity?charset=utf8&loc=Asia%2FShanghai}" 13 +# sqlconn ="${MYSQL_CONN||root:sutianxia2015@tcp(115.29.205.99:3306)/opportunity?charset=utf8&loc=Asia%2FShanghai}"
  14 +mysql_user = "${MYSQL_USER||root}"
  15 +mysql_password = "${MYSQL_PASSWORD||sutianxia2015}"
  16 +mysql_host = "${MYSQL_HOST||115.29.205.99}"
  17 +mysql_port = "${MYSQL_PORT||3306}"
  18 +mysql_db_name = "${MYSQL_DB_NAME||opportunity}"
15 ##redis相关配置 19 ##redis相关配置
16 redis_add_port = "127.0.0.1:6379" 20 redis_add_port = "127.0.0.1:6379"
17 redis_auth = "" 21 redis_auth = ""
18 ##log相关配置 22 ##log相关配置
19 ##out_put:"console","file" 23 ##out_put:"console","file"
20 log_output = "file" 24 log_output = "file"
21 -log_filename = "${LOG_FILENAME||./log/ability.log}" 25 +log_filename = "${aliyun_logs_access||./log/ability.log}"
22 log_level = "${LOG_LEVEL||debug}" 26 log_level = "${LOG_LEVEL||debug}"
23 #---自定义配置 结束---- 27 #---自定义配置 结束----
@@ -10,7 +10,12 @@ AdminPort = 8088 @@ -10,7 +10,12 @@ AdminPort = 8088
10 10
11 #---自定义配置 开始---- 11 #---自定义配置 开始----
12 #数据库连接 12 #数据库连接
13 -sqlconn = "root:root@tcp(127.0.0.1:3306)/ability_display?charset=utf8&loc=Asia%2FShanghai" 13 +# sqlconn = "root:root@tcp(127.0.0.1:3306)/ability_display?charset=utf8&loc=Asia%2FShanghai"
  14 +mysql_user = "${MYSQL_USER||root}"
  15 +mysql_password = "${MYSQL_PASSWORD||sutianxia2015}"
  16 +mysql_host = "${MYSQL_HOST||115.29.205.99}"
  17 +mysql_port = "${MYSQL_PORT||3306}"
  18 +mysql_db_name = "${MYSQL_DB_NAME||opportunity}"
14 #redis相关配置 19 #redis相关配置
15 redis_add_port = "127.0.0.1:6379" 20 redis_add_port = "127.0.0.1:6379"
16 redis_auth = "" 21 redis_auth = ""
@@ -8,7 +8,12 @@ httpport = 8080 @@ -8,7 +8,12 @@ httpport = 8080
8 8
9 #---自定义配置 开始---- 9 #---自定义配置 开始----
10 #数据库连接 10 #数据库连接
11 -sqlconn = "${MYSQL_CONN||root:sutianxia2015@tcp(115.29.205.99:3306)/opportunity?charset=utf8&loc=Asia%2FShanghai}" 11 +# sqlconn = "${MYSQL_CONN||root:sutianxia2015@tcp(115.29.205.99:3306)/opportunity?charset=utf8&loc=Asia%2FShanghai}"
  12 +mysql_user = "${MYSQL_USER||root}"
  13 +mysql_password = "${MYSQL_PASSWORD||sutianxia2015}"
  14 +mysql_host = "${MYSQL_HOST||115.29.205.99}"
  15 +mysql_port = "${MYSQL_PORT||3306}"
  16 +mysql_db_name = "${MYSQL_DB_NAME||opportunity}"
12 #redis相关配置 17 #redis相关配置
13 redis_add_port = "127.0.0.1:6379" 18 redis_add_port = "127.0.0.1:6379"
14 redis_auth = "" 19 redis_auth = ""
  1 +#!/bin/bash
  2 +export PATH=/root/local/bin:$PATH
  3 +kubectl -n mmm-suplus-dev get pods | grep -q oppmg
  4 +if [ "$?" == "1" ];then
  5 + kubectl create -f /tmp/dev/oppmgmg/oppmg.yaml --record
  6 + kubectl -n mmm-suplus-dev get svc | grep -q oppmg
  7 + if [ "$?" == "0" ];then
  8 + echo "oppmg service install success!"
  9 + else
  10 + echo "oppmg service install fail!"
  11 + fi
  12 + kubectl -n mmm-suplus-dev get pods | grep -q oppmg
  13 + if [ "$?" == "0" ];then
  14 + echo "oppmg deployment install success!"
  15 + else
  16 + echo "oppmg deployment install fail!"
  17 + fi
  18 +else
  19 + kubectl delete -f /tmp/dev/oppmg/oppmg.yaml
  20 + kubectl -n mmm-suplus-dev get svc | grep -q oppmg
  21 + while [ "$?" == "0" ]
  22 + do
  23 + kubectl -n mmm-suplus-dev get svc | grep -q oppmg
  24 + done
  25 + kubectl -n mmm-suplus-dev get pods | grep -q oppmg
  26 + while [ "$?" == "0" ]
  27 + do
  28 + kubectl -n mmm-suplus-dev get pods | grep -q oppmg
  29 + done
  30 + kubectl create -f /tmp/dev/oppmg/oppmg.yaml --record
  31 + kubectl -n mmm-suplus-dev get svc | grep -q oppmg
  32 + if [ "$?" == "0" ];then
  33 + echo "oppmg service update success!"
  34 + else
  35 + echo "oppmg service update fail!"
  36 + fi
  37 + kubectl -n mmm-suplus-dev get pods | grep -q oppmg
  38 + if [ "$?" == "0" ];then
  39 + echo "oppmg deployment update success!"
  40 + else
  41 + echo "oppmg deployment update fail!"
  42 + fi
  43 +fi
  1 +apiVersion: v1
  2 +kind: Service
  3 +metadata:
  4 + name: oppmg
  5 + namespace: mmm-suplus-dev
  6 + labels:
  7 + k8s-app: oppmg
  8 +spec:
  9 + ports:
  10 + - name: "http"
  11 + port: 80
  12 + targetPort: 8080
  13 + selector:
  14 + k8s-app: oppmg
  15 +---
  16 +apiVersion: extensions/v1beta1
  17 +kind: Deployment
  18 +metadata:
  19 + name: oppmg
  20 + namespace: mmm-suplus-dev
  21 + labels:
  22 + k8s-app: oppmg
  23 +spec:
  24 + replicas: 1
  25 + template:
  26 + metadata:
  27 + labels:
  28 + k8s-app: oppmg
  29 + spec:
  30 + affinity:
  31 + nodeAffinity:
  32 + preferredDuringSchedulingIgnoredDuringExecution:
  33 + - preference: {}
  34 + weight: 100
  35 + requiredDuringSchedulingIgnoredDuringExecution:
  36 + nodeSelectorTerms:
  37 + - matchExpressions:
  38 + - key: kubernetes.io/hostname
  39 + operator: In
  40 + values:
  41 + - cn-hangzhou.i-bp1djh1xn7taumbue1ze
  42 + - cn-hangzhou.i-bp1djh1xn7taumbue1zd
  43 + - cn-hangzhou.i-bp1euf5u1ph9kbhtndhb
  44 + - cn-hangzhou.i-bp1hyp5oips9cdwxxgxy
  45 + containers:
  46 + - name: oppmg
  47 + image: 192.168.0.243:5000/mmm/oppmg:dev
  48 + imagePullPolicy: Always
  49 + ports:
  50 + - containerPort: 8080
  51 + volumeMounts:
  52 + - mountPath: /opt/logs
  53 + name: accesslogs
  54 + env:
  55 + - name: ENTERPRISE_SERVICE_HOST
  56 + valueFrom:
  57 + configMapKeyRef:
  58 + name: suplus-config
  59 + key: service.enterprise
  60 + - name: MYSQL_HOST
  61 + valueFrom:
  62 + configMapKeyRef:
  63 + name: suplus-config
  64 + key: mysql.host
  65 + - name: MYSQL_PORT
  66 + valueFrom:
  67 + configMapKeyRef:
  68 + name: suplus-config
  69 + key: mysql.port
  70 + - name: MYSQL_USER
  71 + valueFrom:
  72 + configMapKeyRef:
  73 + name: suplus-config
  74 + key: mysql.user
  75 + - name: MYSQL_PASSWORD
  76 + valueFrom:
  77 + configMapKeyRef:
  78 + name: suplus-config
  79 + key: mysql.password
  80 + - name: MYSQL_DB_NAME
  81 + value: "opportunity_dev"
  82 + - name: LOG_LEVEL
  83 + value: "debug"
  84 + - name: RUN_MODE
  85 + value: "test"
  86 + - name: aliyun_logs_suplus
  87 + value: "stdout"
  88 + - name: aliyun_logs_access
  89 + value: "/opt/logs/oppmg.log"
  90 + volumes:
  91 + - name: accesslogs
  92 + emptyDir: {}
  1 +#!/bin/bash
  2 +export PATH=/root/local/bin:$PATH
  3 +kubectl -n mmm-suplus-prd get pods | grep -q opp
  4 +if [ "$?" == "1" ];then
  5 + kubectl create -f /tmp/prd/opp/opp.yaml --record
  6 + kubectl -n mmm-suplus-prd get svc | grep -q opp
  7 + if [ "$?" == "0" ];then
  8 + echo "opp service install success!"
  9 + else
  10 + echo "opp service install fail!"
  11 + fi
  12 + kubectl -n mmm-suplus-prd get pods | grep -q opp
  13 + if [ "$?" == "0" ];then
  14 + echo "opp deployment install success!"
  15 + else
  16 + echo "opp deployment install fail!"
  17 + fi
  18 +else
  19 + kubectl delete -f /tmp/prd/opp/opp.yaml
  20 + kubectl -n mmm-suplus-prd get svc | grep -q opp
  21 + while [ "$?" == "0" ]
  22 + do
  23 + kubectl -n mmm-suplus-prd get svc | grep -q opp
  24 + done
  25 + kubectl -n mmm-suplus-prd get pods | grep -q opp
  26 + while [ "$?" == "0" ]
  27 + do
  28 + kubectl -n mmm-suplus-prd get pods | grep -q opp
  29 + done
  30 + kubectl create -f /tmp/prd/opp/opp.yaml --record
  31 + kubectl -n mmm-suplus-prd get svc | grep -q opp
  32 + if [ "$?" == "0" ];then
  33 + echo "opp service update success!"
  34 + else
  35 + echo "opp service update fail!"
  36 + fi
  37 + kubectl -n mmm-suplus-prd get pods | grep -q opp
  38 + if [ "$?" == "0" ];then
  39 + echo "opp deployment update success!"
  40 + else
  41 + echo "opp deployment update fail!"
  42 + fi
  43 +fi
  1 +apiVersion: v1
  2 +kind: Service
  3 +metadata:
  4 + name: opp
  5 + namespace: mmm-suplus-prd
  6 + labels:
  7 + k8s-app: opp
  8 +spec:
  9 + ports:
  10 + - name: "http"
  11 + port: 80
  12 + targetPort: 8082
  13 + selector:
  14 + k8s-app: opp
  15 +---
  16 +apiVersion: extensions/v1beta1
  17 +kind: Deployment
  18 +metadata:
  19 + name: opp
  20 + namespace: mmm-suplus-prd
  21 + labels:
  22 + k8s-app: opp
  23 +spec:
  24 + replicas: 1
  25 + template:
  26 + metadata:
  27 + labels:
  28 + k8s-app: opp
  29 + spec:
  30 + affinity:
  31 + nodeAffinity:
  32 + preferredDuringSchedulingIgnoredDuringExecution:
  33 + - preference: {}
  34 + weight: 100
  35 + requiredDuringSchedulingIgnoredDuringExecution:
  36 + nodeSelectorTerms:
  37 + - matchExpressions:
  38 + - key: kubernetes.io/hostname
  39 + operator: In
  40 + values:
  41 + - cn-hangzhou.i-bp1djh1xn7taumbue1ze
  42 + - cn-hangzhou.i-bp1djh1xn7taumbue1zd
  43 + - cn-hangzhou.i-bp1euf5u1ph9kbhtndhb
  44 + - cn-hangzhou.i-bp1hyp5oips9cdwxxgxy
  45 + containers:
  46 + - name: opp
  47 + image: 192.168.0.243:5000/mmm/opp:master
  48 + imagePullPolicy: Always
  49 + ports:
  50 + - containerPort: 8082
  51 + volumeMounts:
  52 + - mountPath: /opt/logs
  53 + name: accesslogs
  54 + env:
  55 + - name: ENTERPRISE_SERVICE_HOST
  56 + valueFrom:
  57 + configMapKeyRef:
  58 + name: suplus-config
  59 + key: service.enterprise
  60 + - name: MYSQL_HOST
  61 + valueFrom:
  62 + configMapKeyRef:
  63 + name: suplus-config
  64 + key: mysql.host
  65 + - name: MYSQL_PORT
  66 + valueFrom:
  67 + configMapKeyRef:
  68 + name: suplus-config
  69 + key: mysql.port
  70 + - name: MYSQL_USER
  71 + valueFrom:
  72 + configMapKeyRef:
  73 + name: suplus-config
  74 + key: mysql.user
  75 + - name: MYSQL_PASSWORD
  76 + valueFrom:
  77 + configMapKeyRef:
  78 + name: suplus-config
  79 + key: mysql.password
  80 + - name: MYSQL_DB_NAME
  81 + value: "opp"
  82 + - name: LOG_LEVEL
  83 + value: "debug"
  84 + - name: ERROR_BASE_CODE
  85 + value: "9"
  86 + - name: ERROR_BASE_CODE_MULTIPLE
  87 + value: "1000"
  88 + - name: RUN_MODE
  89 + value: "prod"
  90 + - name: aliyun_logs_suplus
  91 + value: "stdout"
  92 + - name: aliyun_logs_access
  93 + value: "/opt/logs/app.log"
  94 + volumes:
  95 + - name: accesslogs
  96 + emptyDir: {}
  1 +#!/bin/bash
  2 +export PATH=/root/local/bin:$PATH
  3 +kubectl -n mmm-suplus-test get pods | grep -q opp
  4 +if [ "$?" == "1" ];then
  5 + kubectl create -f /tmp/test/opp/opp.yaml --record
  6 + kubectl -n mmm-suplus-test get svc | grep -q opp
  7 + if [ "$?" == "0" ];then
  8 + echo "opp service install success!"
  9 + else
  10 + echo "opp service install fail!"
  11 + fi
  12 + kubectl -n mmm-suplus-test get pods | grep -q opp
  13 + if [ "$?" == "0" ];then
  14 + echo "opp deployment install success!"
  15 + else
  16 + echo "opp deployment install fail!"
  17 + fi
  18 +else
  19 + kubectl delete -f /tmp/test/opp/opp.yaml
  20 + kubectl -n mmm-suplus-test get svc | grep -q opp
  21 + while [ "$?" == "0" ]
  22 + do
  23 + kubectl -n mmm-suplus-test get svc | grep -q opp
  24 + done
  25 + kubectl -n mmm-suplus-test get pods | grep -q opp
  26 + while [ "$?" == "0" ]
  27 + do
  28 + kubectl -n mmm-suplus-test get pods | grep -q opp
  29 + done
  30 + kubectl create -f /tmp/test/opp/opp.yaml --record
  31 + kubectl -n mmm-suplus-test get svc | grep -q opp
  32 + if [ "$?" == "0" ];then
  33 + echo "opp service update success!"
  34 + else
  35 + echo "opp service update fail!"
  36 + fi
  37 + kubectl -n mmm-suplus-test get pods | grep -q opp
  38 + if [ "$?" == "0" ];then
  39 + echo "opp deployment update success!"
  40 + else
  41 + echo "opp deployment update fail!"
  42 + fi
  43 +fi
  1 +apiVersion: v1
  2 +kind: Service
  3 +metadata:
  4 + name: opp
  5 + namespace: mmm-suplus-test
  6 + labels:
  7 + k8s-app: opp
  8 +spec:
  9 + ports:
  10 + - name: "http"
  11 + port: 80
  12 + targetPort: 8082
  13 + selector:
  14 + k8s-app: opp
  15 +---
  16 +apiVersion: extensions/v1beta1
  17 +kind: Deployment
  18 +metadata:
  19 + name: opp
  20 + namespace: mmm-suplus-test
  21 + labels:
  22 + k8s-app: opp
  23 +spec:
  24 + replicas: 1
  25 + template:
  26 + metadata:
  27 + labels:
  28 + k8s-app: opp
  29 + spec:
  30 + affinity:
  31 + nodeAffinity:
  32 + preferredDuringSchedulingIgnoredDuringExecution:
  33 + - preference: {}
  34 + weight: 100
  35 + requiredDuringSchedulingIgnoredDuringExecution:
  36 + nodeSelectorTerms:
  37 + - matchExpressions:
  38 + - key: kubernetes.io/hostname
  39 + operator: In
  40 + values:
  41 + - cn-hangzhou.i-bp1djh1xn7taumbue1ze
  42 + - cn-hangzhou.i-bp1djh1xn7taumbue1zd
  43 + - cn-hangzhou.i-bp1euf5u1ph9kbhtndhb
  44 + - cn-hangzhou.i-bp1hyp5oips9cdwxxgxy
  45 + containers:
  46 + - name: opp
  47 + image: 192.168.0.243:5000/mmm/opp:test
  48 + imagePullPolicy: Always
  49 + ports:
  50 + - containerPort: 8082
  51 + volumeMounts:
  52 + - mountPath: /opt/logs
  53 + name: accesslogs
  54 + env:
  55 + - name: ENTERPRISE_SERVICE_HOST
  56 + valueFrom:
  57 + configMapKeyRef:
  58 + name: suplus-config
  59 + key: service.enterprise
  60 + - name: MYSQL_HOST
  61 + valueFrom:
  62 + configMapKeyRef:
  63 + name: suplus-config
  64 + key: mysql.host
  65 + - name: MYSQL_PORT
  66 + valueFrom:
  67 + configMapKeyRef:
  68 + name: suplus-config
  69 + key: mysql.port
  70 + - name: MYSQL_USER
  71 + valueFrom:
  72 + configMapKeyRef:
  73 + name: suplus-config
  74 + key: mysql.user
  75 + - name: MYSQL_PASSWORD
  76 + valueFrom:
  77 + configMapKeyRef:
  78 + name: suplus-config
  79 + key: mysql.password
  80 + - name: MYSQL_DB_NAME
  81 + value: "opp_test"
  82 + - name: LOG_LEVEL
  83 + value: "debug"
  84 + - name: ERROR_BASE_CODE
  85 + value: "9"
  86 + - name: ERROR_BASE_CODE_MULTIPLE
  87 + value: "1000"
  88 + - name: RUN_MODE
  89 + value: "prod"
  90 + - name: aliyun_logs_suplus
  91 + value: "stdout"
  92 + - name: aliyun_logs_access
  93 + value: "/opt/logs/app.log"
  94 + volumes:
  95 + - name: accesslogs
  96 + emptyDir: {}