Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize docker images. #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dind-up-cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -289,4 +289,4 @@ if [ $(basename "$0") = dind-up-cluster.sh ]; then
elif [ $(basename "$0") = dind-down-cluster.sh ]; then
source "${DIND_ROOT}/config.sh"
dind::kube-down
fi
fi
35 changes: 1 addition & 34 deletions image/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,39 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

FROM ubuntu:16.04

RUN apt-get update -qq && \
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -qqy \
apt-transport-https \
ca-certificates \
wget \
curl \
lxc \
iptables \
ipcalc \
ethtool \
dmsetup \
iproute2 \
net-tools \
iputils-ping \
tcpdump \
&& \
apt-get clean

# Install specific Docker version
ENV DOCKER_VERSION 1.11.2-0~xenial
#ENV DOCKER_VERSION 1.12.1-0~xenial
RUN apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D && \
mkdir -p /etc/apt/sources.list.d && \
echo deb https://apt.dockerproject.org/repo ubuntu-xenial main > /etc/apt/sources.list.d/docker.list && \
apt-get update -qq && \
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -qqy \
docker-engine=${DOCKER_VERSION} \
&& \
apt-get clean

RUN curl -o- https://raw.githubusercontent.com/karlkfi/resolveip/v1.0.2/install.sh | bash
FROM kubernetes-dind-base:v1

COPY ./bin/* /usr/local/bin/
RUN mkdir -p /var/lib/kubelet/manifests
50 changes: 50 additions & 0 deletions image/base/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Copyright 2016 The Kubernetes Authors All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

FROM ubuntu:16.04

RUN apt-get update -qq && \
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -qqy \
apt-transport-https \
ca-certificates \
wget \
curl \
lxc \
iptables \
ipcalc \
ethtool \
dmsetup \
iproute2 \
net-tools \
iputils-ping \
tcpdump \
socat \
&& \
apt-get clean

# Install specific Docker version
ENV DOCKER_VERSION 1.11.2-0~xenial
#ENV DOCKER_VERSION 1.12.1-0~xenial
RUN apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D && \
mkdir -p /etc/apt/sources.list.d && \
echo deb https://apt.dockerproject.org/repo ubuntu-xenial main > /etc/apt/sources.list.d/docker.list && \
apt-get update -qq && \
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -qqy \
docker-engine=${DOCKER_VERSION} \
&& \
apt-get clean

RUN curl -o- https://raw.githubusercontent.com/karlkfi/resolveip/v1.0.2/install.sh | bash

RUN mkdir -p /var/lib/kubelet/manifests
24 changes: 16 additions & 8 deletions image/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,25 +39,34 @@ find-binary() {
echo -n "${bin}"
}

pull-or-build() {
local image="$1"
local dir="$2"
local prepull="$3"
if docker images "${image}" | grep -q "${image/:*/}"; then
return 0
elif [ -n "${prepull}" ]; then
docker pull "${prepull}"
docker tag "${prepull}" "${image}"
else
docker build -t "${image}" "${dir}"
fi
}

hyperkube_path=$(find-binary hyperkube linux/amd64)
if [ -z "$hyperkube_path" ]; then
echo "Failed to find hyperkube binary for linux/amd64" 1>&2
exit 1
fi
kube_bin_path=$(dirname ${hyperkube_path})

# possibly build socat container
SOCAT_IMG=kubernetes-socat:v1
if ! docker images ${SOCAT_IMG} | grep -q ${SOCAT_IMG}; then
docker build -t ${SOCAT_IMG} "${script_dir}/socat"
fi
pull-or-build kubernetes-dind-base:v1 "${script_dir}/base" "${DIND_PREPULL_BASE:-}"

# download nsenter and socat
# download nsenter
overlay_dir=${DOCKER_IN_DOCKER_OVERLAY_DIR:-${script_dir}/overlay}
mkdir -p "${overlay_dir}"
! which selinuxenabled &>/dev/null || ! selinuxenabled 2>&1 || sudo chcon -Rt svirt_sandbox_file_t -l s0 "${overlay_dir}"
docker run --rm -v "${overlay_dir}:/target" jpetazzo/nsenter
docker run --rm -v "${overlay_dir}:/target" ${SOCAT_IMG}

# create temp workspace to place compiled binaries with image-specific scripts
# create temp workspace dir in KUBE_ROOT to avoid permission issues of TMPDIR on mac os x
Expand All @@ -79,7 +88,6 @@ mkdir -p "${workspace}/bin"
cp -a "${script_dir}/wrapdocker"* "${workspace}/bin/"
cp -a "${kube_bin_path}/hyperkube" "${workspace}/bin/"
cp -a "${overlay_dir}/nsenter" "${workspace}/bin"
cp -a "${overlay_dir}/socat" "${workspace}/bin"

# docker
cp "${script_dir}/Dockerfile" "${workspace}/"
Expand Down
29 changes: 0 additions & 29 deletions image/socat/Dockerfile

This file was deleted.