Modify DockerFile to support multiple k8s versions

- service-node-port-range changed to support extended port range

Change-Id: Ia3d70504ffe1ac93df816b9798e8341dde9b65bb
This commit is contained in:
Vlad Naboichenko 2017-10-30 20:27:29 -05:00
parent 5ecedea42b
commit a168c44949
4 changed files with 21 additions and 10 deletions

View File

@ -115,7 +115,7 @@ function kubeadm_aio_reqs_install {
} }
function kubeadm_aio_build { 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 { function kubeadm_aio_launch {

View File

@ -1,8 +1,12 @@
FROM ubuntu:16.04 FROM ubuntu:16.04
MAINTAINER pete.birley@att.com 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 \ ENV HELM_VERSION=v2.6.1 \
KUBE_VERSION=v1.7.5 \ KUBE_VERSION=${KUBE_VERSION} \
CNI_VERSION=v0.6.0-rc2 \ CNI_VERSION=v0.6.0-rc2 \
container="docker" \ container="docker" \
DEBIAN_FRONTEND="noninteractive" 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 - \ && 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 \ && echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" > /etc/apt/sources.list.d/kubernetes.list \
&& apt-get update \ && 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 \ docker.io \
iptables \ iptables \
kubectl \ kubectl"$APT_KUBE_VERSION" \
kubelet \ kubelet"$APT_KUBE_VERSION" \
kubernetes-cni \ kubernetes-cni \
# Install Kubeadm without running postinstall script as it expects systemd to be running. # 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 \ && dpkg --unpack kubeadm*.deb \
&& mv /var/lib/dpkg/info/kubeadm.postinst /opt/kubeadm.postinst \ && mv /var/lib/dpkg/info/kubeadm.postinst /opt/kubeadm.postinst \
&& dpkg --configure kubeadm \ && dpkg --configure kubeadm \
&& apt-get install -yf kubeadm \ && apt-get install -yf kubeadm"$APT_KUBE_VERSION" \
&& mkdir -p /etc/kubernetes/manifests \ && mkdir -p /etc/kubernetes/manifests \
# Install kubectl: # 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 \ && mv ${TMP_DIR}/client/bin/kubectl /usr/bin/kubectl \
&& chmod +x /usr/bin/kubectl \ && chmod +x /usr/bin/kubectl \
# Install kubelet & kubeadm binaries: # Install kubelet & kubeadm binaries:
# (portdirect) We do things in this weird way to let us use the deps and systemd # (portdirect) We do things in this weird way to let us use the deps and systemd
# units from the packages in the .deb repo. # 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 \ && mv ${TMP_DIR}/server/bin/kubelet /usr/bin/kubelet \
&& chmod +x /usr/bin/kubelet \ && chmod +x /usr/bin/kubelet \
&& mv ${TMP_DIR}/server/bin/kubeadm /usr/bin/kubeadm \ && mv ${TMP_DIR}/server/bin/kubeadm /usr/bin/kubeadm \

View File

@ -3,3 +3,4 @@ kind: MasterConfiguration
kubernetesVersion: v1.7.5 kubernetesVersion: v1.7.5
apiServerExtraArgs: apiServerExtraArgs:
runtime-config: "batch/v2alpha1=true" runtime-config: "batch/v2alpha1=true"
service-node-port-range: "1024-65535"

View File

@ -27,7 +27,7 @@ if [[ "${KUBE_ROLE}" == "master" ]]; then
source /etc/kube-version source /etc/kube-version
if ! [[ "${KUBE_VERSION}" == "default" ]]; then if ! [[ "${KUBE_VERSION}" == "default" ]]; then
echo "We will use K8s ${KUBE_VERSION}" 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 fi
echo 'Setting up K8s' echo 'Setting up K8s'