X-Git-Url: https://gerrit.akraino.org/r/gitweb?a=blobdiff_plain;f=scripts%2Fnginx.sh;fp=scripts%2Fnginx.sh;h=40a937785df568d1726e95142002168033e9e75b;hb=3ca639186156bb294424f4979b30bf7804c77ae2;hp=0000000000000000000000000000000000000000;hpb=1c939edbe4f9d1057c55fac111340b55aaf3a7bf;p=iec.git diff --git a/scripts/nginx.sh b/scripts/nginx.sh new file mode 100755 index 0000000..40a9377 --- /dev/null +++ b/scripts/nginx.sh @@ -0,0 +1,64 @@ +#!/bin/bash -ex + +NGINX_APP=~/nginx-app.yaml + +cat < "${NGINX_APP}" +apiVersion: v1 +kind: Service +metadata: + name: nginx + labels: + app: nginx +spec: + type: NodePort + ports: + - port: 80 + protocol: TCP + name: http + selector: + app: nginx +--- +apiVersion: v1 +kind: ReplicationController +metadata: + name: nginx +spec: + replicas: 2 + template: + metadata: + labels: + app: nginx + spec: + containers: + - name: nginx + image: nginx + ports: + - containerPort: 80 +EOF + +if ! kubectl get services | grep -q nginx; then + kubectl create -f "${NGINX_APP}" +fi +kubectl get nodes +kubectl get services +kubectl get pods +kubectl get rc + +attempts=60 +while [ $attempts -gt 0 ] +do + if [ 3 == "$(kubectl get pods | grep -c -e STATUS -e Running)" ]; then + break + fi + ((attempts-=1)) + sleep 10 +done +[ $attempts -gt 0 ] || exit 1 + +svcip=$(kubectl get services nginx -o json | grep clusterIP | cut -f4 -d'"') +sleep 10 +wget "http://$svcip" +kubectl delete -f "${NGINX_APP}" +kubectl get rc +kubectl get pods +kubectl get services