Skip to content

Instantly share code, notes, and snippets.

@joshy91
Created July 12, 2018 08:21
Show Gist options
  • Select an option

  • Save joshy91/3fdce9a46a19b807c11f4f46608c8977 to your computer and use it in GitHub Desktop.

Select an option

Save joshy91/3fdce9a46a19b807c11f4f46608c8977 to your computer and use it in GitHub Desktop.
#!/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