Created
February 4, 2020 20:03
-
-
Save jayunit100/ae81447cef44a9f648b9a4032011275d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| cat << EOF > ss.yaml | |
| apiVersion: v1 | |
| kind: Service | |
| metadata: | |
| name: nginx | |
| labels: | |
| app: nginx | |
| spec: | |
| ports: | |
| - port: 80 | |
| name: web | |
| clusterIP: None | |
| selector: | |
| app: nginx | |
| --- | |
| apiVersion: apps/v1 | |
| kind: StatefulSet | |
| metadata: | |
| name: web | |
| spec: | |
| serviceName: "nginx" | |
| replicas: 200 | |
| selector: | |
| matchLabels: | |
| app: nginx | |
| template: | |
| metadata: | |
| labels: | |
| app: nginx | |
| spec: | |
| containers: | |
| - name: nginx | |
| image: k8s.gcr.io/nginx-slim:0.8 | |
| ports: | |
| - containerPort: 80 | |
| name: web | |
| EOF | |
| echo "running test now" | |
| SOURCE=web-50 | |
| TARGET=web-150 | |
| # change web-50 to any pod up to the amount in spec.replicas | |
| kubectl apply -f ss.yaml # wait for 200 pods to come up. | |
| kubectl get pod $TARGET -o go-template={{.status.podIP}} | |
| targetPod=`kubectl get pod web-1 -o go-template={{.status.podIP}} | sed 's/.$//'` | |
| echo $targetPod | |
| echo "Attempting to curl nginx message directly from pod, then exiting..." | |
| kubectl exec -t -i $SOURCE -- curl $targetPod | |
| echo "Inspecting output ..." | |
| kubectl exec -t -i $SOURCE -- curl $targetPod | grep -q nginx | |
| exitCode=$? | |
| echo "Exit code was $exitCode" | |
| exit $exitCode |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment