作者 linmadan

Merge branch 'dev' of http://gitlab.fjmaimaimai.com/linmadan/mmm-worth into dev

  1 +#!/bin/bash
  2 +export PATH=/root/local/bin:$PATH
  3 +kubectl -n mmm-suplus-test get pods | grep -q mmm-worth
  4 +if [ "$?" == "1" ];then
  5 + kubectl create -f /tmp/test/mmm-worth/mmm-worth.yaml --record
  6 + kubectl -n mmm-suplus-test get svc | grep -q mmm-worth
  7 + if [ "$?" == "0" ];then
  8 + echo "mmm-worth service install success!"
  9 + else
  10 + echo "mmm-worth service install fail!"
  11 + fi
  12 + kubectl -n mmm-suplus-test get pods | grep -q mmm-worth
  13 + if [ "$?" == "0" ];then
  14 + echo "mmm-worth deployment install success!"
  15 + else
  16 + echo "mmm-worth deployment install fail!"
  17 + fi
  18 +else
  19 + kubectl delete -f /tmp/test/mmm-worth/mmm-worth.yaml
  20 + kubectl -n mmm-suplus-test get svc | grep -q mmm-worth
  21 + while [ "$?" == "0" ]
  22 + do
  23 + kubectl -n mmm-suplus-test get svc | grep -q mmm-worth
  24 + done
  25 + kubectl -n mmm-suplus-test get pods | grep -q mmm-worth
  26 + while [ "$?" == "0" ]
  27 + do
  28 + kubectl -n mmm-suplus-test get pods | grep -q mmm-worth
  29 + done
  30 + kubectl create -f /tmp/test/mmm-worth/mmm-worth.yaml --record
  31 + kubectl -n mmm-suplus-test get svc | grep -q mmm-worth
  32 + if [ "$?" == "0" ];then
  33 + echo "mmm-worth service update success!"
  34 + else
  35 + echo "mmm-worth service update fail!"
  36 + fi
  37 + kubectl -n mmm-suplus-test get pods | grep -q mmm-worth
  38 + if [ "$?" == "0" ];then
  39 + echo "mmm-worth deployment update success!"
  40 + else
  41 + echo "mmm-worth deployment update fail!"
  42 + fi
  43 +fi
  1 +apiVersion: v1
  2 +kind: Service
  3 +metadata:
  4 + name: mmm-worth
  5 + namespace: mmm-suplus-test
  6 + labels:
  7 + k8s-app: mmm-worth
  8 +spec:
  9 + ports:
  10 + - name: "http"
  11 + port: 80
  12 + targetPort: 8082
  13 + selector:
  14 + k8s-app: mmm-worth
  15 +---
  16 +apiVersion: extensions/v1beta1
  17 +kind: Deployment
  18 +metadata:
  19 + name: mmm-worth
  20 + namespace: mmm-suplus-test
  21 + labels:
  22 + k8s-app: mmm-worth
  23 +spec:
  24 + replicas: 1
  25 + template:
  26 + metadata:
  27 + labels:
  28 + k8s-app: mmm-worth
  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: mmm-worth
  47 + image: 192.168.0.243:5000/mmm/mmm-worth:test
  48 + imagePullPolicy: Always
  49 + ports:
  50 + - containerPort: 8082
  51 + volumeMounts:
  52 + - mountPath: /opt/logs
  53 + name: accesslogs
  54 + env:
  55 + - name: POSTGRESQL_DB_NAME
  56 + value: "mmmworthtest"
  57 + - name: POSTGRESQL_USER
  58 + value: "postgres"
  59 + - name: POSTGRESQL_PASSWORD
  60 + value: "postgres_15432"
  61 + - name: POSTGRESQL_HOST
  62 + value: "101.37.68.23"
  63 + - name: POSTGRESQL_PORT
  64 + value: "15432"
  65 + - name: LOG_LEVEL
  66 + value: "debug"
  67 + - name: ERROR_BASE_CODE
  68 + value: "1"
  69 + - name: ERROR_BASE_CODE_MULTIPLE
  70 + value: "1000"
  71 + volumes:
  72 + - name: accesslogs
  73 + emptyDir: {}