Created
February 6, 2017 14:50
-
-
Save joshrosso/e3f745022b80ce4fa600aca21fb7ee90 to your computer and use it in GitHub Desktop.
This file contains 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 | |
jq -r .Resources.LaunchConfigurationWorker.Properties.UserData assets/cloud-formation.json | base64 -d > launchConfigAssets.txt | |
jq -r .Resources.InstanceController.Properties.UserData assets/cloud-formation.json | base64 -d > controllerAssets.txt | |
jq -r '.systemd.units[] | select(.name=="kubelet.service") | .contents' launchConfigAssets.txt > workerKubelet.txt | |
jq -r '.systemd.units[] | select(.name=="kubelet.service") | .contents' controllerAssets.txt > controllerKubelet.txt | |
workerExecPreNum=$(grep -m 1 -n 'ExecStartPre' workerKubelet.txt | cut -f1 -d:) | |
workerMountNum=$(grep -m 1 -n '\-\-volume' workerKubelet.txt | cut -f1 -d:) | |
sed -i "${workerExecPreNum}iExecStartPre=/bin/mkdir -p /opt/cni/bin" workerKubelet.txt | |
sed -i "${workerMountNum}i\ --mount volume=cni-bin-dir,target=/opt/cni/bin \\\\" workerKubelet.txt | |
sed -i "${workerMountNum}i\ --volume=cni-bin-dir,kind=host,source=/opt/cni/bin \\\\" workerKubelet.txt | |
export kubeletWorkerUpdate=$(cat workerKubelet.txt) | |
jq -r '.systemd.units[] | select(.name=="kubelet.service") | .contents=env.kubeletWorkerUpdate' launchConfigAssets.txt | awk 'BEGIN{RS="";getline<"-";print>ARGV[1]}' updatedLaunchConfigKubelet.json | |
controllerExecPreNum=$(grep -m 1 -n 'ExecStartPre' controllerKubelet.txt | cut -f1 -d:) | |
controllerMountNum=$(grep -m 1 -n '\-\-volume' controllerKubelet.txt | cut -f1 -d:) | |
sed -i "${controllerExecPreNum}iExecStartPre=/bin/mkdir -p /opt/cni/bin" controllerKubelet.txt | |
sed -i "${controllerMountNum}i\ --mount volume=cni-bin-dir,target=/opt/cni/bin \\\\" controllerKubelet.txt | |
sed -i "${controllerMountNum}i\ --volume=cni-bin-dir,kind=host,source=/opt/cni/bin \\\\" controllerKubelet.txt | |
export kubeletControllerUpdate=$(cat controllerKubelet.txt) | |
jq -r '.systemd.units[] | select(.name=="kubelet.service") | .contents=env.kubeletControllerUpdate' controllerAssets.txt | awk 'BEGIN{RS="";getline<"-";print>ARGV[1]}' updatedControllerKubelet.json | |
jq . launchConfigAssets.txt > launchConfigAssets.json | |
jq . controllerAssets.txt > controllerAssets.json | |
rm launchConfigAssets.txt controllerAssets.txt workerKubelet.txt controllerKubelet.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment