===== Overview ===== How to install Kubernetes on Fedora 28 using downloadable binary tarballs, based on the installation script you can find [[https://get.k8s.io/|here]]. What this page does is explain what that script accomplishes. Note this does not allow you to build the source, only to run the binaries. ===== The tarballs ===== The ones you need: * [[https://dl.k8s.io/v1.10.0/kubernetes.tar.gz|kubernetes.tar.gz]] * [[https://dl.k8s.io/v1.10.0/kubernetes-client-linux-amd64.tar.gz|kubernetes-client-linux-amd64.tar.gz]] * [[https://dl.k8s.io/v1.10.0/kubernetes-server-linux-amd64.tar.gz|kubernetes-server-linux-amd64.tar.gz]] The rest (not sure you need these): * [[https://dl.k8s.io/v1.10.0/kubernetes-src.tar.gz|kubernetes-src.tar.gz]] * [[https://dl.k8s.io/v1.10.0/kubernetes-node-linux-amd64.tar.gz|kubernetes-node-linux-amd64.tar.gz]] ===== kubernetes.tar.gz ===== This tarball kicks things off, as the installation script ends with: echo "Unpacking kubernetes release ${KUBE_VERSION}" rm -rf "${PWD}/kubernetes" tar -xzf ${file} download_kube_binaries create_cluster So unload that tarball and get to work. ===== download_kube_binaries ===== ==== Overview ==== This function call does two things: * downloads the server tarball, but leaves it unextracted * downloads //and extracts// the client tarball ==== download_kube_binaries() ==== This just turns around and calls a script for the download and extraction: # Use the script from inside the Kubernetes tarball to fetch the client and # server binaries (if not included in kubernetes.tar.gz). function download_kube_binaries { ( cd kubernetes if [[ -x ./cluster/get-kube-binaries.sh ]]; then # Make sure to use the same download URL in get-kube-binaries.sh KUBERNETES_RELEASE_URL="${KUBERNETES_RELEASE_URL}" \ ./cluster/get-kube-binaries.sh fi ) } ==== cluster/get-kube-binaries.sh ==== === kubernetes-server-linux-amd64.tar.gz === As you can see, the server tarball is downloaded and simply left under ''server/'' for later: if "${DOWNLOAD_SERVER_TAR}"; then download_tarball "${KUBE_ROOT}/server" "${SERVER_TAR}" fi so you can easily do that manually. === kubernetes-client-linux-amd64.tar.gz === Unlike the server tarball, the client tarball is not only downloaded under ''client/'', it is then "extracted": if "${DOWNLOAD_CLIENT_TAR}"; then download_tarball "${KUBE_ROOT}/client" "${CLIENT_TAR}" extract_arch_tarball "${KUBE_ROOT}/client/${CLIENT_TAR}" "${CLIENT_PLATFORM}" "${CLIENT_ARCH}" fi The client tarball consists of the single executable ''kubectl'': $ tar tvf kubernetes-client-linux-amd64.tar.gz drwxr-xr-x root/root 0 2018-03-26 13:46 kubernetes/ drwxr-xr-x root/root 0 2018-03-26 13:46 kubernetes/client/ drwxr-xr-x root/root 0 2018-03-26 13:46 kubernetes/client/bin/ -rwxr-xr-x root/root 54277699 2018-03-26 13:46 kubernetes/client/bin/kubectl $ which will be "installed" and which you'll have to add to your search path shortly. Here's the ''extract_arch_tarball()'' function in that script: function extract_arch_tarball() { local -r tarfile="$1" local -r platform="$2" local -r arch="$3" platforms_dir="${KUBE_ROOT}/platforms/${platform}/${arch}" echo "Extracting ${tarfile} into ${platforms_dir}" mkdir -p "${platforms_dir}" # Tarball looks like kubernetes/{client,server}/bin/BINARY" tar -xzf "${tarfile}" --strip-components 3 -C "${platforms_dir}" # Create convenience symlink ln -sf "${platforms_dir}" "$(dirname ${tarfile})/bin" echo "Add '$(dirname ${tarfile})/bin' to your PATH to use newly-installed binaries." } In short, from the ''${KUBE_ROOT}'' directory (and in the context of a 64-bit Fedora system), extract that single ''kubectl'' executable: $ mkdir -p platforms/linux/amd64 $ tar xvf ../kubernetes-client-linux-amd64.tar.gz \ > --strip-components 3 \ > -C platforms/linux/amd64 $ $ tree platforms platforms └── linux └── amd64 └── kubectl $ Finally, make sure you can find ''kubectl'' on your search path somehow: PATH=$PATH:/home/rpjday/kubernetes/dl/kubernetes/platforms/linux/amd64 ===== create_cluster ===== ==== Overview ==== This function kicks off a new cluster: function create_cluster { if [[ -n "${KUBERNETES_SKIP_CREATE_CLUSTER-}" ]]; then exit 0 fi echo "Creating a kubernetes on ${KUBERNETES_PROVIDER:-gce}..." ( cd kubernetes ./cluster/kube-up.sh echo "Kubernetes binaries at ${PWD}/cluster/" if [[ ":$PATH:" != *":${PWD}/cluster:"* ]]; then echo "You may want to add this directory to your PATH in \$HOME/.profile" fi echo "Installation successful!" ) } You might want to add the ''cluster/'' directory to your search path for later: PATH=$PATH:/home/rpjday/kubernetes/dl/kubernetes/cluster ==== create_cluster() ==== This function calls the underlying script ''cluster/kube-up.sh'': function create_cluster { if [[ -n "${KUBERNETES_SKIP_CREATE_CLUSTER-}" ]]; then exit 0 fi echo "Creating a kubernetes on ${KUBERNETES_PROVIDER:-gce}..." ( cd kubernetes ./cluster/kube-up.sh echo "Kubernetes binaries at ${PWD}/cluster/" if [[ ":$PATH:" != *":${PWD}/cluster:"* ]]; then echo "You may want to add this directory to your PATH in \$HOME/.profile" fi echo "Installation successful!" ) }