Skip to content

Commit

Permalink
update web-show example (chaos-mesh#595)
Browse files Browse the repository at this point in the history
Signed-off-by: cwen0 <[email protected]>
  • Loading branch information
cwen0 authored Jun 4, 2020
1 parent e5698da commit 29d10e4
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 45 deletions.
61 changes: 56 additions & 5 deletions examples/web-show/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ USAGE:
install.sh [FLAGS] [OPTIONS]
FLAGS:
-h, --help Prints help information
-d, --delete Delete web-show application
--docker-mirror Use docker mirror to pull image
EOF
}

DOCKER_MIRROR=false
DELETE_APP=false

while [[ $# -gt 0 ]]
do
Expand All @@ -37,6 +39,10 @@ case $key in
DOCKER_MIRROR=true
shift
;;
-d|--delete)
DELETE_APP=true
shift
;;
-h|--help)
usage
exit 0
Expand All @@ -49,20 +55,65 @@ case $key in
esac
done

TARGET_IP=$(kubectl get pod -n kube-system -o wide| grep kube-controller | head -n 1 | awk '{print $6}')
if [ ${DELETE_APP} == "true" ]; then
kubectl delete deployments web-show
kubectl delete service web-show
exit 0
fi

sed "s/TARGETIP/$TARGET_IP/g" deployment.yaml > deployment-target.yaml
TARGET_IP=$(kubectl get pod -n kube-system -o wide| grep kube-controller | head -n 1 | awk '{print $6}')

if [ ${DOCKER_MIRROR} == "true" ]; then
docker pull dockerhub.azk8s.cn/pingcap/web-show || true
docker tag dockerhub.azk8s.cn/pingcap/web-show pingcap/web-show || true
kind load docker-image pingcap/web-show > /dev/null 2>&1 || true
fi

kubectl apply -f service.yaml
kubectl apply -f deployment-target.yaml
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: Service
metadata:
name: web-show
labels:
app: web-show
spec:
selector:
app: web-show
ports:
- protocol: TCP
port: 8081
targetPort: 8081
EOF

rm -rf deployment-target.yaml
cat <<EOF | kubectl apply -f -
apiVersion: apps/v1
kind: Deployment
metadata:
name: web-show
labels:
app: web-show
spec:
replicas: 1
selector:
matchLabels:
app: web-show
template:
metadata:
labels:
app: web-show
spec:
containers:
- name: web-show
image: pingcap/web-show
imagePullPolicy: Always
command:
- /usr/local/bin/web-show
- --target-ip=${TARGET_IP}
ports:
- name: web-port
containerPort: 8081
hostPort: 8081
EOF

while [[ $(kubectl get pods -l app=web-show -o 'jsonpath={..status.conditions[?(@.type=="Ready")].status}') != "True" ]]; do echo "Waiting for pod running" && sleep 10; done

Expand Down
27 changes: 0 additions & 27 deletions examples/web-show/deployment.yaml

This file was deleted.

13 changes: 0 additions & 13 deletions examples/web-show/service.yaml

This file was deleted.

0 comments on commit 29d10e4

Please sign in to comment.