From be9696bf4729b94cb79d79bdc8e8549a913302a1 Mon Sep 17 00:00:00 2001 From: Alexandru Avadanii Date: Fri, 14 Jun 2019 18:14:39 +0200 Subject: [PATCH] Add CentOS7 support for K8s installation Change-Id: Icd51658aed4f3280e2ee1bf5e44a68ae3fa7e5ca Signed-off-by: Alexandru Avadanii --- src/foundation/scripts/k8s_common.sh | 114 ++++++++++++++++++++++++++--------- 1 file changed, 85 insertions(+), 29 deletions(-) diff --git a/src/foundation/scripts/k8s_common.sh b/src/foundation/scripts/k8s_common.sh index 06d2d0d..975b43c 100755 --- a/src/foundation/scripts/k8s_common.sh +++ b/src/foundation/scripts/k8s_common.sh @@ -1,43 +1,99 @@ #!/bin/bash -ex -DOCKER_VERSION=18.06.1~ce~3-0~ubuntu -KUBE_VERSION=1.13.0-00 -K8S_CNI_VERSION=0.6.0-00 - -# Install basic software -sudo apt update -sudo apt install -y software-properties-common apt-transport-https curl - -# Install Docker as Prerequisite -curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - -sudo apt-key fingerprint 0EBFCD88 -sudo add-apt-repository \ - "deb https://download.docker.com/linux/ubuntu \ - $(lsb_release -cs) \ - stable" -sudo apt update -sudo apt install -y docker-ce=${DOCKER_VERSION} +if grep -q -e rhel /etc/*-release; then + OS_ID_LIKE=rhel +elif grep -q -e debian /etc/*-release; then + OS_ID_LIKE=debian +fi + +case ${OS_ID_LIKE:-} in +debian) + DOCKER_VERSION=18.06.1~ce~3-0~ubuntu + KUBE_VERSION=1.13.0-00 + K8S_CNI_VERSION=0.6.0-00 + KUBELET_CFG=/etc/default/kubelet + ;; +rhel) + DOCKER_VERSION=18.06.1.ce-3.el7 + KUBE_VERSION=1.13.0-0 + K8S_CNI_VERSION=0.6.0-0 + KUBELET_CFG=/etc/sysconfig/kubelet + ;; +*) + echo 'Unsupported distribution detected!' + exit 1 + ;; +esac + +case ${OS_ID_LIKE:-} in +debian) + # Install basic software + sudo apt update + sudo apt install -y software-properties-common apt-transport-https curl + + # Install Docker as Prerequisite + curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - + sudo apt-key fingerprint 0EBFCD88 + sudo add-apt-repository \ + "deb https://download.docker.com/linux/ubuntu \ + $(lsb_release -cs) \ + stable" + sudo apt update + sudo apt install -y docker-ce=${DOCKER_VERSION} + ;; +rhel) + sudo yum install -y yum-utils device-mapper-persistent-data lvm2 + sudo yum-config-manager --add-repo \ + https://download.docker.com/linux/centos/docker-ce.repo + sudo yum install -y \ + docker-ce-$DOCKER_VERSION \ + docker-ce-cli-$DOCKER_VERSION \ + containerd.io + ;; +esac # Disable swap on your machine sudo swapoff -a -# Install Kubernetes with Kubeadm -curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add - +case ${OS_ID_LIKE:-} in +debian) + # Install Kubernetes with Kubeadm + curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add - -cat <