Created
July 12, 2018 08:21
-
-
Save joshy91/3fdce9a46a19b807c11f4f46608c8977 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 | |
| #Creates two kubernetes jobs using yaml config and displays the description and log of the job | |
| echo “apiVersion: batch/v1 | |
| kind: Job | |
| metadata: | |
| name: pi | |
| spec: | |
| template: | |
| spec: | |
| containers: | |
| - name: pi | |
| image: perl | |
| command: ["perl", "-Mbignum=bpi", "-wle", "print bpi(2000)"] | |
| restartPolicy: Never | |
| backoffLimit: 4” >> pi-job.yaml | |
| kubectl create -f pi-job.yaml | |
| kubectl describe job pi | |
| podname=`kubectl describe job pi | awk '/Normal/ {print $7}'` | |
| kubectl logs $podname | |
| echo “apiVersion: batch/v1 | |
| kind: Job | |
| metadata: | |
| name: busybox | |
| spec: | |
| template: | |
| spec: | |
| containers: | |
| - name: busybox | |
| image: busybox | |
| command: ["sleep", "10"] | |
| restartPolicy: Never | |
| backoffLimit: 4” >> busybox-job.yaml | |
| kubectl create -f busybox-job.yaml | |
| kubectl describe job busybox | |
| podname=`kubectl describe job busybox | awk '/Normal/ {print $7}'` | |
| kubectl logs $podname |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment