mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-26 21:17:23 +00:00
Merge pull request #19216 from luxas/etcd_cross_platform
Auto commit by PR queue bot
This commit is contained in:
commit
c156835f8a
4
cluster/images/etcd/.gitignore
vendored
4
cluster/images/etcd/.gitignore
vendored
@ -1,4 +0,0 @@
|
|||||||
etcd
|
|
||||||
etcdctl
|
|
||||||
etcd-*-linux-amd64.tar.gz
|
|
||||||
etcd-*-linux-amd64/
|
|
@ -1,5 +1,5 @@
|
|||||||
FROM busybox
|
FROM BASEIMAGE
|
||||||
MAINTAINER Dawn Chen <dawnchen@google.com>
|
MAINTAINER Dawn Chen <dawnchen@google.com>
|
||||||
|
|
||||||
ADD ./etcd /usr/local/bin/etcd
|
COPY ./etcd /usr/local/bin/etcd
|
||||||
ADD ./etcdctl /usr/local/bin/etcdctl
|
COPY ./etcdctl /usr/local/bin/etcdctl
|
||||||
|
@ -1,21 +1,48 @@
|
|||||||
.PHONY: clean build push
|
# Build the etcd image
|
||||||
|
#
|
||||||
|
# Usage:
|
||||||
|
# [TAG=2.2.1] [REGISTRY=gcr.io/google_containers] [ARCH=amd64] [BASEIMAGE=busybox] make (build|push)
|
||||||
|
|
||||||
IMAGE = etcd
|
TAG?=2.2.1
|
||||||
TAG = 2.2.1
|
ARCH?=amd64
|
||||||
ETCD_VERSION = 2.2.1
|
REGISTRY?=gcr.io/google_containers
|
||||||
OUTPUT_DIR = $(IMAGE)-v$(ETCD_VERSION)-linux-amd64
|
TEMP_DIR:=$(shell mktemp -d)
|
||||||
|
|
||||||
clean:
|
# Default base images for different architectures
|
||||||
rm -rf $(OUTPUT_DIR) $(IMAGE)-v$(ETCD_VERSION)-linux-amd64.tar.gz etcd etcdctl
|
# '/' in images has to be written as '\\/'
|
||||||
|
ifeq ($(ARCH),amd64)
|
||||||
|
BASEIMAGE?=busybox
|
||||||
|
endif
|
||||||
|
ifeq ($(ARCH),arm)
|
||||||
|
BASEIMAGE?=hypriot\\/armhf-busybox
|
||||||
|
endif
|
||||||
|
|
||||||
build: clean
|
build:
|
||||||
curl -L -O https://github.com/coreos/etcd/releases/download/v$(ETCD_VERSION)/$(IMAGE)-v$(ETCD_VERSION)-linux-amd64.tar.gz
|
# Download etcd source in a golang container and cross-compile it statically
|
||||||
tar xzvf $(IMAGE)-v$(ETCD_VERSION)-linux-amd64.tar.gz
|
# or download official binaries if the ARCH is amd64
|
||||||
cp $(OUTPUT_DIR)/etcd .
|
./build-etcd.sh ${TAG} ${ARCH} ${TEMP_DIR}
|
||||||
cp $(OUTPUT_DIR)/etcdctl .
|
|
||||||
docker build -t gcr.io/google_containers/$(IMAGE):$(TAG) .
|
# Copy the content in this dir to the temp dir
|
||||||
|
cp ./* ${TEMP_DIR}
|
||||||
|
|
||||||
|
# Replace BASEIMAGE with the real base image
|
||||||
|
cd ${TEMP_DIR} && sed -i "s/BASEIMAGE/${BASEIMAGE}/g" Dockerfile
|
||||||
|
|
||||||
|
# And build the image
|
||||||
|
docker build -t ${REGISTRY}/etcd-${ARCH}:${TAG} ${TEMP_DIR}
|
||||||
|
|
||||||
|
ifeq ($(ARCH),amd64)
|
||||||
|
# Backward compatability. TODO: deprecate this image tag
|
||||||
|
docker tag -f ${REGISTRY}/etcd-${ARCH}:${TAG} ${REGISTRY}/etcd:${TAG}
|
||||||
|
endif
|
||||||
|
|
||||||
push: build
|
push: build
|
||||||
gcloud docker push gcr.io/google_containers/$(IMAGE):$(TAG)
|
gcloud docker push ${REGISTRY}/etcd-${ARCH}:${TAG}
|
||||||
|
|
||||||
all: push
|
# Backward compatability. TODO: deprecate this image tag
|
||||||
|
ifeq ($(ARCH),amd64)
|
||||||
|
gcloud docker push ${REGISTRY}/etcd:${TAG}
|
||||||
|
endif
|
||||||
|
|
||||||
|
all: build
|
||||||
|
.PHONY: build push
|
57
cluster/images/etcd/build-etcd.sh
Executable file
57
cluster/images/etcd/build-etcd.sh
Executable file
@ -0,0 +1,57 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Copyright 2015 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.
|
||||||
|
|
||||||
|
# Build etcd from source in a docker container
|
||||||
|
|
||||||
|
# Require three arguments
|
||||||
|
if [[ $# != 3 ]]; then
|
||||||
|
echo "Usage: ./build-etcd.sh TAG ARCH TARGET_DIR"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Example tag should be 2.2.1, not v2.2.1
|
||||||
|
TAG=$1
|
||||||
|
ARCH=$2
|
||||||
|
TARGET_DIR=$3
|
||||||
|
|
||||||
|
GOLANG_VERSION=${GOLANG_VERSION:-1.5.2}
|
||||||
|
GOARM=6
|
||||||
|
|
||||||
|
# Create the ${TARGET_DIR} directory, if it doesn't exist
|
||||||
|
mkdir -p ${TARGET_DIR}
|
||||||
|
|
||||||
|
# Do not compile if we should make an image for amd64, use the "official" etcd binaries instead
|
||||||
|
if [[ ${ARCH} == "amd64" ]]; then
|
||||||
|
|
||||||
|
# Just download the binaries to ${TARGET_DIR}
|
||||||
|
curl -sSL https://github.com/coreos/etcd/releases/download/v${TAG}/etcd-v${TAG}-linux-amd64.tar.gz | tar -xz -C ${TARGET_DIR} --strip-components=1
|
||||||
|
else
|
||||||
|
# Download etcd in a golang container and cross-compile it statically
|
||||||
|
CID=$(docker run -d golang:${GOLANG_VERSION} /bin/sh -c \
|
||||||
|
"mkdir /etcd \
|
||||||
|
&& curl -sSL https://github.com/coreos/etcd/archive/v${TAG}.tar.gz | tar -C /etcd -xz --strip-components=1 \
|
||||||
|
&& cd /etcd \
|
||||||
|
&& GOARM=${GOARM} GOARCH=${ARCH} ./build")
|
||||||
|
|
||||||
|
# Wait until etcd has compiled
|
||||||
|
docker wait ${CID}
|
||||||
|
|
||||||
|
# Copy out the bin folder to ${TARGET_DIR}
|
||||||
|
docker cp ${CID}:/etcd/bin ${TARGET_DIR}
|
||||||
|
|
||||||
|
# Move the contents in bin to the target directory
|
||||||
|
mv ${TARGET_DIR}/bin/* ${TARGET_DIR}
|
||||||
|
fi
|
Loading…
Reference in New Issue
Block a user