-
-
Save i11/433fcbcbfcedb677a26673426d304fc1 to your computer and use it in GitHub Desktop.
Kubernetes with kubeadm on Ubuntu Trusty (14.04) hack
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 -ex | |
| # | |
| # This script is meant to be run on Ubuntu Trusty (14.04) as root | |
| # | |
| # It is expected that you are following the guide at: | |
| # https://kubernetes.io/docs/setup/independent/install-kubeadm/ | |
| # https://kubernetes.io/docs/setup/independent/create-cluster-kubeadm/ | |
| # | |
| # Particularly you will need to have (BEFORE you start): | |
| # - binutils, ebtables, socat installed | |
| # - docker installed, upstart converted to systemd and running | |
| # - kubernetes-cni and kubectl installed | |
| # | |
| # It will create a directory in /tmp with the following artifacts in it: | |
| # - nsenter binary (to be copied to /usr/local/bin) | |
| # - kubelet-patched.deb (to be installed) | |
| # - kubeadm-patched.deb (to be installed) | |
| # (No changes on your system other than that directory) | |
| # | |
| # After you have done those steps do: | |
| # - kubeadm init | |
| # - start kubelet (from another shell, while kubeadm is waiting for the control plane) | |
| # - continue with "(3/4) Installing a pod network" | |
| # | |
| # An example of how docker upstart could be switched to systemd, assuming it was installed | |
| # following the https://docs.docker.com/engine/installation/linux/docker-ce/ubuntu/ guide: | |
| # | |
| # stop docker | |
| # mv /lib/systemd/system/docker.* /lib/systemd/upstart | |
| # rm -f /etc/init/docker.conf | |
| # systemctl daemon-reload | |
| getpkg() | |
| { | |
| local path=`apt-cache show "$1" | grep 'Filename: pool' | sort | tail -n1 | cut -d ' ' -f2` | |
| wget "https://packages.cloud.google.com/apt/$path" | |
| } | |
| unpkg() | |
| { | |
| ar x "$1" | |
| gzip -dv control.tar.gz | |
| unxz -v data.tar.xz | |
| } | |
| repkg() | |
| { | |
| gzip -v control.tar | |
| xz -v0 data.tar | |
| ar cr "$1" debian-binary control.tar.gz data.tar.xz | |
| } | |
| make_kubelet() | |
| { | |
| rm -rf kubelet | |
| mkdir kubelet | |
| cd kubelet | |
| getpkg kubelet | |
| unpkg kubelet*deb | |
| # replace maintainer scripts | |
| tar xvf control.tar ./control | |
| sed 's/init-system-helpers (>= 1.18~)/init-system-helpers (>= 1.14~)/' -i control | |
| tar --update -v -f control.tar ./control | |
| # replace deb-systemd-helper with direct systemctl calls | |
| tar xvf control.tar ./postinst | |
| sed 's/deb-systemd-helper enable/systemctl enable/' -i postinst | |
| sed 's/deb-systemd-helper start/systemctl start/' -i postinst | |
| tar --update -v -f control.tar ./postinst | |
| # Move kubelet.service to upstart systemd namespace | |
| tar xvf data.tar ./lib/systemd/system/kubelet.service | |
| mv ./lib/systemd/system ./lib/systemd/upstart | |
| tar --delete -v -f data.tar ./lib/systemd/system | |
| tar --update -v -f data.tar ./lib/systemd/upstart/kubelet.service | |
| repkg ../kubelet-patched.deb | |
| cd .. | |
| rm -rf kubelet | |
| } | |
| make_nsenter() | |
| { | |
| cat <<EOF | docker run -i --rm -v "`pwd`:/tmp" ubuntu:14.04 | |
| apt-get update | |
| apt-get install -y git bison gettext autoconf libtool automake gettext autopoint pkgconf make build-essential | |
| apt-get build-dep -y util-linux | |
| cd /tmp | |
| git clone git://git.kernel.org/pub/scm/utils/util-linux/util-linux.git | |
| cd util-linux | |
| ./autogen.sh | |
| ./configure --without-python --disable-all-programs --enable-nsenter | |
| make nsenter | |
| EOF | |
| cp -v util-linux/nsenter . | |
| rm -rf util-linux | |
| } | |
| tmp=`mktemp -d` | |
| cd "$tmp" | |
| make_kubelet | |
| make_nsenter | |
| cat <<EOF | |
| All done! | |
| EOF | |
| cp -v $tmp/nsenter /usr/local/bin | |
| dpkg -i $tmp/*-patched.deb | |
| rm -rf $tmp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment