install.sh 1.4 KB
#!/bin/bash
export PATH=/root/local/bin:$PATH
kubectl -n <replace-your-k8s-namespace> get pods | grep -q mmm-worth
if [ "$?" == "1" ];then
	kubectl create -f /tmp/dev/mmm-worth/mmm-worth.yaml --record
	kubectl -n <replace-your-k8s-namespace> get svc | grep -q mmm-worth
	if [ "$?" == "0" ];then
		echo "mmm-worth service install success!"
	else
		echo "mmm-worth service install fail!"
	fi
	kubectl -n <replace-your-k8s-namespace> get pods | grep -q mmm-worth
	if [ "$?" == "0" ];then
		echo "mmm-worth deployment install success!"
	else
		echo "mmm-worth deployment install fail!"
	fi
else
	kubectl delete -f /tmp/dev/mmm-worth/mmm-worth.yaml
	kubectl -n <replace-your-k8s-namespace> get svc | grep -q mmm-worth
	while [ "$?" == "0" ]
	do
	kubectl -n <replace-your-k8s-namespace> get svc | grep -q mmm-worth
	done
	kubectl -n <replace-your-k8s-namespace> get pods | grep -q mmm-worth
	while [ "$?" == "0" ]
	do
	kubectl -n <replace-your-k8s-namespace> get pods | grep -q mmm-worth
	done
	kubectl create -f /tmp/dev/mmm-worth/mmm-worth.yaml --record
	kubectl -n <replace-your-k8s-namespace> get svc | grep -q mmm-worth
	if [ "$?" == "0" ];then
		echo "mmm-worth service update success!"
	else
		echo "mmm-worth service update fail!"
	fi
	kubectl -n <replace-your-k8s-namespace> get pods | grep -q mmm-worth
	if [ "$?" == "0" ];then
		echo "mmm-worth deployment update success!"
	else
		echo "mmm-worth deployment update fail!"
	fi
fi