diff --git a/tools/gate/funcs/kube.sh b/tools/gate/funcs/kube.sh index 0a9f11ebd2..cd5da23b5e 100755 --- a/tools/gate/funcs/kube.sh +++ b/tools/gate/funcs/kube.sh @@ -115,7 +115,7 @@ function kubeadm_aio_reqs_install { } function kubeadm_aio_build { - sudo docker build --pull -t ${KUBEADM_IMAGE} tools/kubeadm-aio + sudo docker build --pull -t ${KUBEADM_IMAGE} --build-arg KUBE_VERSION=$KUBE_VERSION tools/kubeadm-aio } function kubeadm_aio_launch { diff --git a/tools/kubeadm-aio/Dockerfile b/tools/kubeadm-aio/Dockerfile index 105e98f0e2..8f69c9d63b 100644 --- a/tools/kubeadm-aio/Dockerfile +++ b/tools/kubeadm-aio/Dockerfile @@ -1,8 +1,12 @@ FROM ubuntu:16.04 MAINTAINER pete.birley@att.com +# You can specify particulat version using +# --build-arg KUBE_VERSION=$KUBE_VERSION +# or put 'xlatest' and it will download latest availible k8s packages. +ARG KUBE_VERSION=v1.7.5 ENV HELM_VERSION=v2.6.1 \ - KUBE_VERSION=v1.7.5 \ + KUBE_VERSION=${KUBE_VERSION} \ CNI_VERSION=v0.6.0-rc2 \ container="docker" \ DEBIAN_FRONTEND="noninteractive" @@ -20,27 +24,33 @@ RUN set -x \ && curl -sSL https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - \ && echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" > /etc/apt/sources.list.d/kubernetes.list \ && apt-get update \ - && apt-get install -y --no-install-recommends \ + && if [ "$KUBE_VERSION" = "xlatest" ]; \ + then version=`apt-cache policy kubeadm| grep Candidate: | awk '{print $2}' | sed 's/-[0-9]*//'`; \ + APT_KUBE_VERSION="=${version}-*"; \ + API_KUBE_VERSION="v${version}"; \ + else APT_KUBE_VERSION="=$(echo $KUBE_VERSION | sed 's/v//g')-*";\ + API_KUBE_VERSION=${KUBE_VERSION}; fi; \ + apt-get install -y --no-install-recommends \ docker.io \ iptables \ - kubectl \ - kubelet \ + kubectl"$APT_KUBE_VERSION" \ + kubelet"$APT_KUBE_VERSION" \ kubernetes-cni \ # Install Kubeadm without running postinstall script as it expects systemd to be running. - && apt-get download kubeadm \ + && apt-get download kubeadm"$APT_KUBE_VERSION" \ && dpkg --unpack kubeadm*.deb \ && mv /var/lib/dpkg/info/kubeadm.postinst /opt/kubeadm.postinst \ && dpkg --configure kubeadm \ - && apt-get install -yf kubeadm \ + && apt-get install -yf kubeadm"$APT_KUBE_VERSION" \ && mkdir -p /etc/kubernetes/manifests \ # Install kubectl: - && curl -sSL https://dl.k8s.io/${KUBE_VERSION}/kubernetes-client-linux-amd64.tar.gz | tar -zxv --strip-components=1 \ + && curl -sSL https://dl.k8s.io/$API_KUBE_VERSION/kubernetes-client-linux-amd64.tar.gz | tar -zxv --strip-components=1 \ && mv ${TMP_DIR}/client/bin/kubectl /usr/bin/kubectl \ && chmod +x /usr/bin/kubectl \ # Install kubelet & kubeadm binaries: # (portdirect) We do things in this weird way to let us use the deps and systemd # units from the packages in the .deb repo. - && curl -sSL https://dl.k8s.io/${KUBE_VERSION}/kubernetes-server-linux-amd64.tar.gz | tar -zxv --strip-components=1 \ + && curl -sSL https://dl.k8s.io/${API_KUBE_VERSION}/kubernetes-server-linux-amd64.tar.gz | tar -zxv --strip-components=1 \ && mv ${TMP_DIR}/server/bin/kubelet /usr/bin/kubelet \ && chmod +x /usr/bin/kubelet \ && mv ${TMP_DIR}/server/bin/kubeadm /usr/bin/kubeadm \ diff --git a/tools/kubeadm-aio/assets/etc/kubeadm.conf b/tools/kubeadm-aio/assets/etc/kubeadm.conf index 31291f4395..7969180937 100644 --- a/tools/kubeadm-aio/assets/etc/kubeadm.conf +++ b/tools/kubeadm-aio/assets/etc/kubeadm.conf @@ -3,3 +3,4 @@ kind: MasterConfiguration kubernetesVersion: v1.7.5 apiServerExtraArgs: runtime-config: "batch/v2alpha1=true" + service-node-port-range: "1024-65535" diff --git a/tools/kubeadm-aio/assets/usr/bin/kubeadm-aio b/tools/kubeadm-aio/assets/usr/bin/kubeadm-aio index 830cc80ba6..411d38eea7 100755 --- a/tools/kubeadm-aio/assets/usr/bin/kubeadm-aio +++ b/tools/kubeadm-aio/assets/usr/bin/kubeadm-aio @@ -27,7 +27,7 @@ if [[ "${KUBE_ROLE}" == "master" ]]; then source /etc/kube-version if ! [[ "${KUBE_VERSION}" == "default" ]]; then echo "We will use K8s ${KUBE_VERSION}" - sed -i "s|^kubernetesVersion: v1.7.5|kubernetesVersion: ${KUBE_VERSION}|g" /etc/kubeadm.conf + sed -i "s|^kubernetesVersion:.*|kubernetesVersion: ${KUBE_VERSION}|g" /etc/kubeadm.conf fi echo 'Setting up K8s'