Created
January 6, 2017 17:46
-
-
Save ktraff/b1aa1901fbfbd99251a3d08ec8c40fcc to your computer and use it in GitHub Desktop.
Patches kubelet agents with necessary ceph packages and a secretfile for mounting CephFS volumes in Kubernetes.
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 | |
# Script that patches kubernetes kubelet with | |
# various fixes to get CephFS mounts working. | |
KUBELET_ID=$(docker ps | grep kubelet | cut -d' ' -f1) | |
KUBELET_DESC=$(docker ps | grep kubelet | awk '{print $2}') | |
echo -e "KUBELET_ID=$KUBELET_ID ($KUBELET_DESC)" | |
if [ -z ${CEPH_SECRET+x} ]; then | |
echo "CEPH_SECRET is empty - please set this yourself!"; | |
else echo -e "CEPH_SECRET=$CEPH_SECRET\n" | |
fi | |
read -p "Proceed (Yn)? " -n 1 -r | |
echo # (optional) move to a new line | |
if [[ ! $REPLY =~ ^[Yy]$ ]] | |
then | |
# handle exits from shell or function but don't exit interactive shell | |
[[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1 | |
fi | |
echo "Installing Ceph packages" | |
docker exec $KUBELET_ID apt-get update | |
docker exec $KUBELET_ID apt-get install -y wget lsb-release apt-transport-https | |
docker exec $KUBELET_ID /bin/bash -c "wget -q -O- 'https://download.ceph.com/keys/release.asc' | apt-key add -" | |
RELEASE=$(docker exec $KUBELET_ID lsb_release -sc) | |
docker exec $KUBELET_ID /bin/bash -c "echo deb https://download.ceph.com/debian-jewel/ $RELEASE main | tee /etc/apt/sources.list.d/ceph.list" | |
docker exec $KUBELET_ID apt-get update | |
docker exec $KUBELET_ID apt-get install -y ceph-fs-common | |
docker exec $KUBELET_ID apt-get install -y ceph-common | |
echo "Installing Ceph secretfile" | |
docker exec $KUBELET_ID mkdir -p /etc/ceph | |
docker exec $KUBELET_ID /bin/bash -c "echo $CEPH_SECRET > /etc/ceph/admin.secret" | |
echo "Done" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment