作者 tangxuhui
  1 +apiVersion: v1
  2 +kind: Service
  3 +metadata:
  4 + name: allied-creation-basic
  5 + namespace: mmm-suplus-test
  6 + labels:
  7 + k8s-app: allied-creation-basic
  8 +spec:
  9 + ports:
  10 + - name: "http"
  11 + port: 80
  12 + targetPort: 8080
  13 + - name: "https"
  14 + port: 443
  15 + targetPort: 443
  16 + selector:
  17 + k8s-app: allied-creation-basic
  18 +---
  19 +apiVersion: extensions/v1beta1
  20 +kind: Deployment
  21 +metadata:
  22 + name: allied-creation-basic
  23 + namespace: mmm-suplus-test
  24 + labels:
  25 + k8s-app: allied-creation-basic
  26 +spec:
  27 + replicas: 1
  28 + template:
  29 + metadata:
  30 + labels:
  31 + k8s-app: allied-creation-basic
  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-basic
  50 + image: 192.168.0.243:5000/mmm/allied-creation-basic:dev
  51 + imagePullPolicy: Always
  52 + ports:
  53 + - containerPort: 8080
  54 + - containerPort: 443
  55 + volumeMounts:
  56 + - mountPath: /opt/logs
  57 + name: accesslogs
  58 + env:
  59 + - name: LOG_LEVEL
  60 + value: "debug"
  61 + - name: ERROR_BASE_CODE
  62 + value: "1"
  63 + - name: ERROR_BASE_CODE_MULTIPLE
  64 + value: "1000"
  65 + - name: REDIS_HOST
  66 + valueFrom:
  67 + configMapKeyRef:
  68 + name: suplus-config
  69 + key: redis.ip
  70 + - name: REDIS_PORT
  71 + valueFrom:
  72 + configMapKeyRef:
  73 + name: suplus-config
  74 + key: redis.port
  75 + - name: POSTGRESQL_DB_NAME
  76 + valueFrom:
  77 + configMapKeyRef:
  78 + name: suplus-config
  79 + key: postgresqlalliedcreationbasic.dbname
  80 + - name: POSTGRESQL_USER
  81 + valueFrom:
  82 + configMapKeyRef:
  83 + name: suplus-config
  84 + key: postgresql.user
  85 + - name: POSTGRESQL_PASSWORD
  86 + valueFrom:
  87 + configMapKeyRef:
  88 + name: suplus-config
  89 + key: postgresql.password
  90 + - name: POSTGRESQL_HOST
  91 + valueFrom:
  92 + configMapKeyRef:
  93 + name: suplus-config
  94 + key: postgresql.host
  95 + - name: POSTGRESQL_PORT
  96 + valueFrom:
  97 + configMapKeyRef:
  98 + name: suplus-config
  99 + key: postgresql.port
  100 + volumes:
  101 + - name: accesslogs
  102 + emptyDir: {}
  1 +#!/bin/bash
  2 +export PATH=/root/local/bin:$PATH
  3 +kubectl -n mmm-suplus-test get pods | grep -q allied-creation-basic
  4 +if [ "$?" == "1" ];then
  5 + kubectl create -f /tmp/test/allied-creation-basic/allied-creation-basic.yaml --record
  6 + kubectl -n mmm-suplus-test get svc | grep -q allied-creation-basic
  7 + if [ "$?" == "0" ];then
  8 + echo "allied-creation-basic service install success!"
  9 + else
  10 + echo "allied-creation-basic service install fail!"
  11 + fi
  12 + kubectl -n mmm-suplus-test get pods | grep -q allied-creation-basic
  13 + if [ "$?" == "0" ];then
  14 + echo "allied-creation-basic deployment install success!"
  15 + else
  16 + echo "allied-creation-basic deployment install fail!"
  17 + fi
  18 +else
  19 + kubectl delete -f /tmp/test/allied-creation-basic/allied-creation-basic.yaml
  20 + kubectl -n mmm-suplus-test get svc | grep -q allied-creation-basic
  21 + while [ "$?" == "0" ]
  22 + do
  23 + kubectl -n mmm-suplus-test get svc | grep -q allied-creation-basic
  24 + done
  25 + kubectl -n mmm-suplus-test get pods | grep -q allied-creation-basic
  26 + while [ "$?" == "0" ]
  27 + do
  28 + kubectl -n mmm-suplus-test get pods | grep -q allied-creation-basic
  29 + done
  30 + kubectl create -f /tmp/test/allied-creation-basic/allied-creation-basic.yaml --record
  31 + kubectl -n mmm-suplus-test get svc | grep -q allied-creation-basic
  32 + if [ "$?" == "0" ];then
  33 + echo "allied-creation-basic service update success!"
  34 + else
  35 + echo "allied-creation-basic service update fail!"
  36 + fi
  37 + kubectl -n mmm-suplus-test get pods | grep -q allied-creation-basic
  38 + if [ "$?" == "0" ];then
  39 + echo "allied-creation-basic deployment update success!"
  40 + else
  41 + echo "allied-creation-basic deployment update fail!"
  42 + fi
  43 +fi