diff --git a/Dockerfile-velero-ppc64le b/Dockerfile-velero-ppc64le index 4a2ab0d583..a70a97d7e1 100644 --- a/Dockerfile-velero-ppc64le +++ b/Dockerfile-velero-ppc64le @@ -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 " - -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 " +ADD /bin/linux/ppc64le/restic /usr/bin/restic ADD /bin/linux/ppc64le/velero /velero diff --git a/Dockerfile-velero-restic-restore-helper-ppc64le b/Dockerfile-velero-restic-restore-helper-ppc64le index dcf4804c65..d5e0072f4a 100644 --- a/Dockerfile-velero-restic-restore-helper-ppc64le +++ b/Dockerfile-velero-restic-restore-helper-ppc64le @@ -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 " +LABEL maintainer="Prajyot Parab " ADD /bin/linux/ppc64le/velero-restic-restore-helper . diff --git a/Makefile b/Makefile index d1866bc78b..91c94e4877 100644 --- a/Makefile +++ b/Makefile @@ -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) diff --git a/changelogs/unreleased/1768-prajyot-parab b/changelogs/unreleased/1768-prajyot-parab new file mode 100644 index 0000000000..4c9e94290f --- /dev/null +++ b/changelogs/unreleased/1768-prajyot-parab @@ -0,0 +1 @@ +added support for ppc64le images and manifest lists diff --git a/hack/docker-push.sh b/hack/docker-push.sh index dfcda9b8cc..6096be14f4 100755 --- a/hack/docker-push.sh +++ b/hack/docker-push.sh @@ -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 diff --git a/hack/get-restic-ppc64le.sh b/hack/get-restic-ppc64le.sh new file mode 100755 index 0000000000..afaae8576e --- /dev/null +++ b/hack/get-restic-ppc64le.sh @@ -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 + diff --git a/site/docs/master/build-from-source.md b/site/docs/master/build-from-source.md index f2e204be33..b658f0279e 100644 --- a/site/docs/master/build-from-source.md +++ b/site/docs/master/build-from-source.md @@ -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=- 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=- 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= 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=- MANIFEST_PLATFORMS= 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 diff --git a/site/docs/v1.2.0/build-from-source.md b/site/docs/v1.2.0/build-from-source.md index f2e204be33..b658f0279e 100644 --- a/site/docs/v1.2.0/build-from-source.md +++ b/site/docs/v1.2.0/build-from-source.md @@ -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=- 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=- 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= 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=- MANIFEST_PLATFORMS= 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