作者 tangxuhui
  1 +apiVersion: v1
  2 +kind: Service
  3 +metadata:
  4 + name: allied-creation-gateway
  5 + namespace: mmm-suplus-prd
  6 + labels:
  7 + k8s-app: allied-creation-gateway
  8 +spec:
  9 + ports:
  10 + - name: "http"
  11 + port: 80
  12 + targetPort: 8082
  13 + - name: "https"
  14 + port: 443
  15 + targetPort: 443
  16 + selector:
  17 + k8s-app: allied-creation-gateway
  18 +---
  19 +apiVersion: extensions/v1beta1
  20 +kind: Deployment
  21 +metadata:
  22 + name: allied-creation-gateway
  23 + namespace: mmm-suplus-prd
  24 + labels:
  25 + k8s-app: allied-creation-gateway
  26 +spec:
  27 + replicas: 1
  28 + template:
  29 + metadata:
  30 + labels:
  31 + k8s-app: allied-creation-gateway
  32 + spec:
  33 + affinity:
  34 + nodeAffinity:
  35 + preferredDuringSchedulingIgnoredDuringExecution:
  36 + - preference: {}
  37 + weight: 100
  38 + requiredDuringSchedulingIgnoredDuringExecution:
  39 + nodeSelectorTerms:
  40 + - matchExpressions:
  41 + - key: kubernetes.io/hostname
  42 + operator: In
  43 + values:
  44 + - cn-hangzhou.i-bp1djh1xn7taumbue1ze
  45 + - cn-hangzhou.i-bp1djh1xn7taumbue1zd
  46 + - cn-hangzhou.i-bp1euf5u1ph9kbhtndhb
  47 + - cn-hangzhou.i-bp1hyp5oips9cdwxxgxy
  48 + containers:
  49 + - name: allied-creation-gateway
  50 + image: 192.168.0.243:5000/mmm/allied-creation-gateway:master
  51 + imagePullPolicy: Always
  52 + ports:
  53 + - containerPort: 8082
  54 + - containerPort: 443
  55 + volumeMounts:
  56 + - mountPath: /opt/logs
  57 + name: accesslogs
  58 + env:
  59 + - name: POSTGRESQL_DB_NAME
  60 + valueFrom:
  61 + configMapKeyRef:
  62 + name: suplus-config
  63 + key: postgresqlalliedcreation.dbname
  64 + - name: POSTGRESQL_USER
  65 + valueFrom:
  66 + configMapKeyRef:
  67 + name: suplus-config
  68 + key: postgresql.user
  69 + - name: POSTGRESQL_PASSWORD
  70 + valueFrom:
  71 + configMapKeyRef:
  72 + name: suplus-config
  73 + key: postgresql.password
  74 + - name: POSTGRESQL_HOST
  75 + valueFrom:
  76 + configMapKeyRef:
  77 + name: suplus-config
  78 + key: postgresql.host
  79 + - name: POSTGRESQL_PORT
  80 + valueFrom:
  81 + configMapKeyRef:
  82 + name: suplus-config
  83 + key: postgresql.port
  84 + - name: REDIS_HOST
  85 + valueFrom:
  86 + configMapKeyRef:
  87 + name: suplus-config
  88 + key: redis.ip
  89 + - name: REDIS_PORT
  90 + valueFrom:
  91 + configMapKeyRef:
  92 + name: suplus-config
  93 + key: redis.port
  94 + - name: REDIS_AUTH
  95 + value: ""
  96 + - name: LOG_LEVEL
  97 + value: "debug"
  98 + - name: LOG_FRAMEWORK
  99 + value: "beego"
  100 + - name: LOG_TYPE
  101 + value: "file"
  102 + - name: ERROR_BASE_CODE
  103 + value: "1"
  104 + - name: ERROR_BASE_CODE_MULTIPLE
  105 + value: "1000"
  106 + - name: ENABLE_KAFKA_LOG
  107 + value: "false"
  108 + - name: HTTP_PORT
  109 + value: "8082"
  110 + - name: ALLIED_CREATION_USER_HOST
  111 + value: "https://allied-creation-user-prd.fjmaimaimai.com"
  112 + - name: ALLIED_CREATION_COOPERATION_HOST
  113 + value: "https://allied-creation-cooperation-prd.fjmaimaimai.com"
  114 + - name: ALLIED_CREATION_BASIC_HOST
  115 + value: "https://allied-creation-basic-prd.fjmaimaimai.com"
  116 + - name: SMS_SERVE_HOST
  117 + value: "https://sms.fjmaimaimai.com:9897"
  118 + # - name: REDIS_HOST
  119 + # valueFrom:
  120 + # configMapKeyRef:
  121 + # name: suplus-config
  122 + # key: redis.ip
  123 + # - name: REDIS_PORT
  124 + # valueFrom:
  125 + # configMapKeyRef:
  126 + # name: suplus-config
  127 + # key: redis.port
  128 + volumes:
  129 + - name: accesslogs
  130 + emptyDir: {}
  1 +#!/bin/bash
  2 +export PATH=/root/local/bin:$PATH
  3 +kubectl -n mmm-suplus-prd get pods | grep -q allied-creation-gateway
  4 +if [ "$?" == "1" ];then
  5 + kubectl create -f /tmp/prd/allied-creation-gateway/allied-creation-gateway.yaml --record
  6 + kubectl -n mmm-suplus-prd get svc | grep -q allied-creation-gateway
  7 + if [ "$?" == "0" ];then
  8 + echo "allied-creation-gateway service install success!"
  9 + else
  10 + echo "allied-creation-gateway service install fail!"
  11 + fi
  12 + kubectl -n mmm-suplus-prd get pods | grep -q allied-creation-gateway
  13 + if [ "$?" == "0" ];then
  14 + echo "allied-creation-gateway deployment install success!"
  15 + else
  16 + echo "allied-creation-gateway deployment install fail!"
  17 + fi
  18 +else
  19 + kubectl delete -f /tmp/prd/allied-creation-gateway/allied-creation-gateway.yaml
  20 + kubectl -n mmm-suplus-prd get svc | grep -q allied-creation-gateway
  21 + while [ "$?" == "0" ]
  22 + do
  23 + kubectl -n mmm-suplus-prd get svc | grep -q allied-creation-gateway
  24 + done
  25 + kubectl -n mmm-suplus-prd get pods | grep -q allied-creation-gateway
  26 + while [ "$?" == "0" ]
  27 + do
  28 + kubectl -n mmm-suplus-prd get pods | grep -q allied-creation-gateway
  29 + done
  30 + kubectl create -f /tmp/prd/allied-creation-gateway/allied-creation-gateway.yaml --record
  31 + kubectl -n mmm-suplus-prd get svc | grep -q allied-creation-gateway
  32 + if [ "$?" == "0" ];then
  33 + echo "allied-creation-gateway service update success!"
  34 + else
  35 + echo "allied-creation-gateway service update fail!"
  36 + fi
  37 + kubectl -n mmm-suplus-prd get pods | grep -q allied-creation-gateway
  38 + if [ "$?" == "0" ];then
  39 + echo "allied-creation-gateway deployment update success!"
  40 + else
  41 + echo "allied-creation-gateway deployment update fail!"
  42 + fi
  43 +fi