作者 tangxvhui
#!/bin/bash
export PATH=/root/local/bin:$PATH
kubectl -n mmm-suplus-prd get pods | grep -q partner
kubectl -n mmm-suplus-prd get pods | grep -q mmm-partnermg
if [ "$?" == "1" ];then
kubectl create -f /tmp/prd/partner/partner.yaml --record
kubectl -n mmm-suplus-prd get svc | grep -q partner
kubectl create -f /tmp/prd/partnermg/partner.yaml --record
kubectl -n mmm-suplus-prd get svc | grep -q mmm-partnermg
if [ "$?" == "0" ];then
echo "partner service install success!"
else
echo "partner service install fail!"
fi
kubectl -n mmm-suplus-prd get pods | grep -q partner
kubectl -n mmm-suplus-prd get pods | grep -q mmm-partnermg
if [ "$?" == "0" ];then
echo "partner deployment install success!"
else
echo "partner deployment install fail!"
fi
else
kubectl delete -f /tmp/prd/partner/partner.yaml
kubectl -n mmm-suplus-prd get svc | grep -q partner
kubectl delete -f /tmp/prd/partnermg/partner.yaml
kubectl -n mmm-suplus-prd get svc | grep -q mmm-partnermg
while [ "$?" == "0" ]
do
kubectl -n mmm-suplus-prd get svc | grep -q partner
kubectl -n mmm-suplus-prd get svc | grep -q mmm-partnermg
done
kubectl -n mmm-suplus-prd get pods | grep -q partner
kubectl -n mmm-suplus-prd get pods | grep -q mmm-partnermg
while [ "$?" == "0" ]
do
kubectl -n mmm-suplus-prd get pods | grep -q partner
kubectl -n mmm-suplus-prd get pods | grep -q mmm-partnermg
done
kubectl create -f /tmp/prd/partner/partner.yaml --record
kubectl -n mmm-suplus-prd get svc | grep -q partner
kubectl create -f /tmp/prd/partnermg/partner.yaml --record
kubectl -n mmm-suplus-prd get svc | grep -q mmm-partnermg
if [ "$?" == "0" ];then
echo "partner service update success!"
else
echo "partner service update fail!"
fi
kubectl -n mmm-suplus-prd get pods | grep -q partner
kubectl -n mmm-suplus-prd get pods | grep -q mmm-partnermg
if [ "$?" == "0" ];then
echo "partner deployment update success!"
else
... ...
apiVersion: v1
kind: Service
metadata:
name: partner
name: mmm-partnermg
namespace: mmm-suplus-prd
labels:
k8s-app: partner
k8s-app: mmm-partnermg
spec:
ports:
- name: "http"
port: 80
targetPort: 8082
selector:
k8s-app: partner
k8s-app: mmm-partnermg
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: partner
name: mmm-partnermg
namespace: mmm-suplus-prd
labels:
k8s-app: partner
k8s-app: mmm-partnermg
spec:
replicas: 1
template:
metadata:
labels:
k8s-app: partner
k8s-app: mmm-partnermg
spec:
affinity:
nodeAffinity:
... ... @@ -43,8 +43,8 @@ spec:
- cn-hangzhou.i-bp1euf5u1ph9kbhtndhb
- cn-hangzhou.i-bp1hyp5oips9cdwxxgxy
containers:
- name: partner
image: 192.168.0.243:5000/mmm/partner:master
- name: mmm-partnermg
image: 192.168.0.243:5000/mmm/mmm-partnermg:master
imagePullPolicy: Always
ports:
- containerPort: 8082
... ...