Multiarch image support (#1768)

* multi-arch docker image support

Signed-off-by: Prajyot Parab <prajyot.parab@ibm.com>

* updated manifest for latest tag

Signed-off-by: Prajyot Parab <prajyot.parab@ibm.com>

* updated manifest part

Signed-off-by: Prajyot Parab <prajyot.parab@ibm.com>

* update changelog

Signed-off-by: Prajyot Parab <prajyot.parab@ibm.com>

* Removed commented out code lines

Signed-off-by: Prajyot Parab <prajyot.parab@ibm.com>

* minor changes

Signed-off-by: Prajyot Parab <prajyot.parab@ibm.com>

* bumped restic version

Signed-off-by: Prajyot Parab <prajyot.parab@ibm.com>

* refactoring vars

Signed-off-by: Prajyot Parab <prajyot.parab@ibm.com>

* added purge flag to manifest push command

Signed-off-by: Prajyot Parab <prajyot.parab@ibm.com>

* removed all-build from workflow

Signed-off-by: Prajyot Parab <prajyot.parab@ibm.com>

* enabled docker_cli_experimental flag for docker manifest

Signed-off-by: Prajyot Parab <prajyot.parab@ibm.com>

* Updated manifest related info

Signed-off-by: Prajyot Parab <prajyot.parab@ibm.com>

* Updated manifests info to doc

Signed-off-by: Prajyot Parab <prajyot.parab@ibm.com>
This commit is contained in:
Prajyot-Parab
2020-01-08 00:03:31 +05:30
committed by Nolan Brubaker
parent c832e52905
commit b9d02795b5
8 changed files with 208 additions and 35 deletions

View File

@@ -12,18 +12,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
FROM ubuntu:bionic
FROM ppc64le/ubuntu:bionic
LABEL maintainer="Steve Kriss <krisss@vmware.com>"
RUN apt-get update && \
apt-get install -y --no-install-recommends ca-certificates wget && \
wget --quiet https://oplab9.parqtec.unicamp.br/pub/ppc64el/restic/restic-0.9.5 && \
mv restic-0.9.5 /usr/bin/restic && \
chmod +x /usr/bin/restic && \
apt-get remove -y wget && \
rm -rf /var/lib/apt/lists/*
LABEL maintainer="Prajyot Parab <prajyot.parab@ibm.com>"
ADD /bin/linux/ppc64le/restic /usr/bin/restic
ADD /bin/linux/ppc64le/velero /velero

View File

@@ -12,9 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
FROM ubuntu:bionic
FROM ppc64le/ubuntu:bionic
LABEL maintainer="Steve Kriss <krisss@vmware.com>"
LABEL maintainer="Prajyot Parab <prajyot.parab@ibm.com>"
ADD /bin/linux/ppc64le/velero-restic-restore-helper .

View File

@@ -33,21 +33,26 @@ VERSION ?= master
TAG_LATEST ?= false
# The version of restic binary to be downloaded for power architecture
RESTIC_VERSION ?= 0.9.5
CLI_PLATFORMS ?= linux-amd64 linux-arm linux-arm64 darwin-amd64 windows-amd64 linux-ppc64le
CONTAINER_PLATFORMS ?= linux-amd64 linux-ppc64le #linux-arm linux-arm64
MANIFEST_PLATFORMS ?= amd64 ppc64le
###
### These variables should not need tweaking.
###
CLI_PLATFORMS := linux-amd64 linux-arm linux-arm64 darwin-amd64 windows-amd64 linux-ppc64le
CONTAINER_PLATFORMS := linux-amd64 linux-arm linux-arm64 linux-ppc64le
platform_temp = $(subst -, ,$(ARCH))
GOOS = $(word 1, $(platform_temp))
GOARCH = $(word 2, $(platform_temp))
# TODO(ncdc): support multiple image architectures once gcr.io supports manifest lists
# Set default base image dynamically for each arch
ifeq ($(GOARCH),amd64)
DOCKERFILE ?= Dockerfile-$(BIN)
local-arch:
@echo "local environment for amd64 is up-to-date"
endif
#ifeq ($(GOARCH),arm)
# DOCKERFILE ?= Dockerfile.arm #armel/busybox
@@ -57,12 +62,16 @@ endif
#endif
ifeq ($(GOARCH),ppc64le)
DOCKERFILE ?= Dockerfile-$(BIN)-ppc64le
local-arch:
RESTIC_VERSION=$(RESTIC_VERSION) \
./hack/get-restic-ppc64le.sh
endif
IMAGE = $(REGISTRY)/$(BIN)
MULTIARCH_IMAGE = $(REGISTRY)/$(BIN)
IMAGE = $(REGISTRY)/$(BIN)-$(GOARCH)
# If you want to build all binaries, see the 'all-build' rule.
# If you want to build all containers, see the 'all-container' rule.
# If you want to build all containers, see the 'all-containers' rule.
# If you want to build AND push all containers, see the 'all-push' rule.
all:
@$(MAKE) build
@@ -70,18 +79,25 @@ all:
build-%:
@$(MAKE) --no-print-directory ARCH=$* build
@$(MAKE) --no-print-directory ARCH=$* build BIN=velero-restic-restore-helper
#container-%:
# @$(MAKE) --no-print-directory ARCH=$* container
container-%:
@$(MAKE) --no-print-directory ARCH=$* container
@$(MAKE) --no-print-directory ARCH=$* container BIN=velero-restic-restore-helper
#push-%:
# @$(MAKE) --no-print-directory ARCH=$* push
push-%:
@$(MAKE) --no-print-directory ARCH=$* push
@$(MAKE) --no-print-directory ARCH=$* push BIN=velero-restic-restore-helper
all-build: $(addprefix build-, $(CLI_PLATFORMS))
#all-container: $(addprefix container-, $(CONTAINER_PLATFORMS))
all-containers: $(addprefix container-, $(CONTAINER_PLATFORMS))
#all-push: $(addprefix push-, $(CONTAINER_PLATFORMS))
all-push: $(addprefix push-, $(CONTAINER_PLATFORMS))
all-manifests:
@$(MAKE) manifest
@$(MAKE) manifest BIN=velero-restic-restore-helper
local: build-dirs
GOOS=$(GOOS) \
@@ -135,7 +151,7 @@ all-containers:
$(MAKE) container
$(MAKE) container BIN=velero-restic-restore-helper
container: .container-$(DOTFILE_IMAGE) container-name
container: local-arch .container-$(DOTFILE_IMAGE) container-name
.container-$(DOTFILE_IMAGE): _output/bin/$(GOOS)/$(GOARCH)/$(BIN) $(DOCKERFILE)
@cp $(DOCKERFILE) _output/.dockerfile-$(BIN)-$(GOOS)-$(GOARCH)
@docker build --pull -t $(IMAGE):$(VERSION) -f _output/.dockerfile-$(BIN)-$(GOOS)-$(GOARCH) _output
@@ -144,11 +160,6 @@ container: .container-$(DOTFILE_IMAGE) container-name
container-name:
@echo "container: $(IMAGE):$(VERSION)"
all-push:
$(MAKE) push
$(MAKE) push BIN=velero-restic-restore-helper
push: .push-$(DOTFILE_IMAGE) push-name
.push-$(DOTFILE_IMAGE): .container-$(DOTFILE_IMAGE)
@docker push $(IMAGE):$(VERSION)
@@ -161,6 +172,20 @@ endif
push-name:
@echo "pushed: $(IMAGE):$(VERSION)"
manifest: .manifest-$(MULTIARCH_IMAGE) manifest-name
.manifest-$(MULTIARCH_IMAGE):
@DOCKER_CLI_EXPERIMENTAL=enabled docker manifest create $(MULTIARCH_IMAGE):$(VERSION) \
$(foreach arch, $(MANIFEST_PLATFORMS), $(MULTIARCH_IMAGE)-$(arch):$(VERSION))
@DOCKER_CLI_EXPERIMENTAL=enabled docker manifest push --purge $(MULTIARCH_IMAGE):$(VERSION)
ifeq ($(TAG_LATEST), true)
@DOCKER_CLI_EXPERIMENTAL=enabled docker manifest create $(MULTIARCH_IMAGE):latest \
$(foreach arch, $(MANIFEST_PLATFORMS), $(MULTIARCH_IMAGE)-$(arch):latest)
@DOCKER_CLI_EXPERIMENTAL=enabled docker manifest push --purge $(MULTIARCH_IMAGE):latest
endif
manifest-name:
@echo "pushed: $(MULTIARCH_IMAGE):$(VERSION)"
SKIP_TESTS ?=
test: build-dirs
ifneq ($(SKIP_TESTS), 1)

View File

@@ -0,0 +1 @@
added support for ppc64le images and manifest lists

View File

@@ -80,4 +80,4 @@ unset GIT_HTTP_USER_AGENT
echo "Building and pushing container images."
VERSION="$VERSION" TAG_LATEST="$TAG_LATEST" make all-containers all-push
VERSION="$VERSION" TAG_LATEST="$TAG_LATEST" make all-containers all-push all-manifests

34
hack/get-restic-ppc64le.sh Executable file
View File

@@ -0,0 +1,34 @@
#!/bin/bash
#
# Copyright 2019 the Velero contributors.
#
# 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.
set -o errexit
set -o nounset
set -o pipefail
if [ -z "${RESTIC_VERSION}" ]; then
echo "RESTIC_VERSION must be set"
exit 1
fi
if [ ! -d "_output/bin/linux/ppc64le/" ]; then
mkdir -p _output/bin/linux/ppc64le/
fi
wget --quiet https://oplab9.parqtec.unicamp.br/pub/ppc64el/restic/restic-${RESTIC_VERSION}
mv restic-${RESTIC_VERSION} _output/bin/linux/ppc64le/restic
chmod +x _output/bin/linux/ppc64le/restic

View File

@@ -64,6 +64,7 @@ Velero's `Makefile` has a convenience target, `all-build`, that builds the follo
* linux-amd64
* linux-arm
* linux-arm64
* linux-ppc64le
* darwin-amd64
* windows-amd64
@@ -75,7 +76,7 @@ If after installing Velero you would like to change the image used by its deploy
kubectl -n velero set image deploy/velero velero=myimagerepo/velero:$VERSION
```
To build a Velero container image, first set the `$REGISTRY` environment variable. For example, if you want to build the `gcr.io/my-registry/velero:master` image, set `$REGISTRY` to `gcr.io/my-registry`. If this variable is not set, the default is `velero`.
To build a Velero container image, first set the `$REGISTRY` environment variable. For example, if you want to build the `gcr.io/my-registry/velero-amd64:master` image, set `$REGISTRY` to `gcr.io/my-registry`. If this variable is not set, the default is `velero`.
Optionally, set the `$VERSION` environment variable to change the image tag. Then, run:
@@ -83,12 +84,71 @@ Optionally, set the `$VERSION` environment variable to change the image tag. The
make container
```
To push your image to the registry, run:
For any specific platform, run `ARCH=<GOOS>-<GOARCH> make container`
For example, to build an image for the Power (ppc64le), run:
```bash
ARCH=linux-ppc64le make container
```
_Note: By default, ARCH is set to linux-amd64_
To push your image to the registry. For example, if you want to push the `gcr.io/my-registry/velero-amd64:master` image, run:
```bash
make push
```
For any specific platform, run `ARCH=<GOOS>-<GOARCH> make push`
For example, to push image for the Power (ppc64le), run:
```bash
ARCH=linux-ppc64le make push
```
_Note: By default, ARCH is set to linux-amd64_
To create and push your manifest to the registry. For example, if you want to create and push the `gcr.io/my-registry/velero:master` manifest, run:
```bash
make manifest
```
For any specific platform, run `MANIFEST_PLATFORMS=<GOARCH> make manifest`
For example, to create and push manifest only for amd64, run:
```bash
MANIFEST_PLATFORMS=amd64 make manifest
```
_Note: By default, MANIFEST_PLATFORMS is set to amd64, ppc64le_
To run the entire workflow, run:
`REGISTRY=<$REGISTRY> VERSION=<$VERSION> ARCH=<GOOS>-<GOARCH> MANIFEST_PLATFORMS=<GOARCH> make container push manifest`
For example, to run the workflow only for amd64
```bash
REGISTRY=myrepo VERSION=foo MANIFEST_PLATFORMS=amd64 make container push manifest
```
_Note: By default, ARCH is set to linux-amd64_
For example, to run the workflow only for ppc64le
```bash
REGISTRY=myrepo VERSION=foo ARCH=linux-ppc64le MANIFEST_PLATFORMS=ppc64le make container push manifest
```
For example, to run the workflow for all supported platforms
```bash
REGISTRY=myrepo VERSION=foo make all-containers all-push all-manifests
```
_Note: By default, MANIFEST_PLATFORMS is set to amd64, ppc64le_
Note: if you want to update the image but not change its name, you will have to trigger Kubernetes to pick up the new image. One way of doing so is by deleting the Velero deployment pod:
```bash

View File

@@ -64,6 +64,7 @@ Velero's `Makefile` has a convenience target, `all-build`, that builds the follo
* linux-amd64
* linux-arm
* linux-arm64
* linux-ppc64le
* darwin-amd64
* windows-amd64
@@ -75,7 +76,7 @@ If after installing Velero you would like to change the image used by its deploy
kubectl -n velero set image deploy/velero velero=myimagerepo/velero:$VERSION
```
To build a Velero container image, first set the `$REGISTRY` environment variable. For example, if you want to build the `gcr.io/my-registry/velero:master` image, set `$REGISTRY` to `gcr.io/my-registry`. If this variable is not set, the default is `velero`.
To build a Velero container image, first set the `$REGISTRY` environment variable. For example, if you want to build the `gcr.io/my-registry/velero-amd64:master` image, set `$REGISTRY` to `gcr.io/my-registry`. If this variable is not set, the default is `velero`.
Optionally, set the `$VERSION` environment variable to change the image tag. Then, run:
@@ -83,12 +84,71 @@ Optionally, set the `$VERSION` environment variable to change the image tag. The
make container
```
To push your image to the registry, run:
For any specific platform, run `ARCH=<GOOS>-<GOARCH> make container`
For example, to build an image for the Power (ppc64le), run:
```bash
ARCH=linux-ppc64le make container
```
_Note: By default, ARCH is set to linux-amd64_
To push your image to the registry. For example, if you want to push the `gcr.io/my-registry/velero-amd64:master` image, run:
```bash
make push
```
For any specific platform, run `ARCH=<GOOS>-<GOARCH> make push`
For example, to push image for the Power (ppc64le), run:
```bash
ARCH=linux-ppc64le make push
```
_Note: By default, ARCH is set to linux-amd64_
To create and push your manifest to the registry. For example, if you want to create and push the `gcr.io/my-registry/velero:master` manifest, run:
```bash
make manifest
```
For any specific platform, run `MANIFEST_PLATFORMS=<GOARCH> make manifest`
For example, to create and push manifest only for amd64, run:
```bash
MANIFEST_PLATFORMS=amd64 make manifest
```
_Note: By default, MANIFEST_PLATFORMS is set to amd64, ppc64le_
To run the entire workflow, run:
`REGISTRY=<$REGISTRY> VERSION=<$VERSION> ARCH=<GOOS>-<GOARCH> MANIFEST_PLATFORMS=<GOARCH> make container push manifest`
For example, to run the workflow only for amd64
```bash
REGISTRY=myrepo VERSION=foo MANIFEST_PLATFORMS=amd64 make container push manifest
```
_Note: By default, ARCH is set to linux-amd64_
For example, to run the workflow only for ppc64le
```bash
REGISTRY=myrepo VERSION=foo ARCH=linux-ppc64le MANIFEST_PLATFORMS=ppc64le make container push manifest
```
For example, to run the workflow for all supported platforms
```bash
REGISTRY=myrepo VERSION=foo make all-containers all-push all-manifests
```
_Note: By default, MANIFEST_PLATFORMS is set to amd64, ppc64le_
Note: if you want to update the image but not change its name, you will have to trigger Kubernetes to pick up the new image. One way of doing so is by deleting the Velero deployment pod:
```bash