#!/bin/bash gitpath=https://raw.githubusercontent.com/aws-samples/managing-eks-clusters-with-rancher/master #Deploy a persistent volume for InfluxDB container kubectl create -f ${gitpath}/influxdb-pvc.yaml sleep 10 #Deploy a InfluxDB container kubectl create -f ${gitpath}/influxdb-deploy.yaml sleep 10 #Wait for the InfluxDB container to be ready while true; do output=`kubectl get pod -n ns-citibike | grep influxdb | grep Running | wc -l` if [[ $output -eq 0 ]]; then echo "Waiting for influxdb container to become available" sleep 2 else break fi done #Create a database 'coordinates' in Influxdb kubectl exec -n ns-citibike `kubectl get pod -n ns-citibike | grep influx | awk '{print $1}'` -- influx --execute "create database coordinates" #Deploy the citibike container which queries Citi Bike and ingests data to InfluxDB #First we get the IP of InfluxDB container influxdbIP=`kubectl get pod -n ns-citibike -o wide | grep influxdb | awk '{print $6}'` #Second, we download the yaml file, modify it with the IP curl -L ${gitpath}/citibike-deploy.yaml -o /tmp/citibike-deploy.yaml sed -i s#influxdbIP#$influxdbIP#g /tmp/citibike-deploy.yaml #Next we create a persistent volume in EBS to archive historical data kubectl create -f ${gitpath}/citibike-pvc.yaml sleep 5 #Lastly we launch the container kubectl create -f /tmp/citibike-deploy.yaml #Create a Kubernetes service with ELB to frontend the Grafana container kubectl create -f ${gitpath}/grafana-svc.yaml sleep 10 #Finally we launch the Grafana container kubectl create -f ${gitpath}/grafana-deploy.yaml echo 'Done !!'