Skip to content

Commit 67daf73

Browse files
authored
Merge pull request #397 from justinblalock87/fix-cleanup-release
Add multi-arch manifest for node cleanup controller
2 parents bf6f281 + 520cc34 commit 67daf73

File tree

3 files changed

+52
-12
lines changed

3 files changed

+52
-12
lines changed

Makefile

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ all: build-container-linux-amd64
4040
cross: init-buildx \
4141
$(addprefix build-and-push-container-linux-,$(LINUX_ARCH)) \
4242
$(addprefix build-and-push-node-cleanup-controller-linux-,$(LINUX_ARCH)) \
43-
$(addprefix build-and-push-container-windows-,$(WINDOWS_DISTROS))
43+
$(addprefix build-and-push-container-windows-,$(WINDOWS_DISTROS)) \
44+
$(addprefix build-and-push-node-cleanup-controller-windows-,$(WINDOWS_DISTROS))
4445
.PHONY: cross
4546

4647
verify:
@@ -68,7 +69,7 @@ build-container-linux-%:
6869
build-node-cleanup-controller-linux-%:
6970
CGO_ENABLED=0 GOOS=linux GOARCH=$* go build -a -ldflags '-extldflags "-static"' -mod vendor -o _output/linux/$*/local-volume-node-cleanup ./cmd/node-cleanup
7071
$(DOCKER) buildx build --file=./cmd/node-cleanup/Dockerfile --platform=linux/$* \
71-
-t $(STAGINGIMAGENODECLEANUPCONTROLLER):$(STAGINGVERSION) --output=type=$(OUTPUT_TYPE) \
72+
-t $(STAGINGIMAGENODECLEANUPCONTROLLER):$(STAGINGVERSION)_linux_$* --output=type=$(OUTPUT_TYPE) \
7273
--build-arg OS=linux \
7374
--build-arg ARCH=$* .
7475

@@ -83,7 +84,7 @@ build-and-push-container-linux-%: init-buildx
8384
build-and-push-node-cleanup-controller-linux-%: init-buildx
8485
CGO_ENABLED=0 GOOS=linux GOARCH=$* go build -a -ldflags '-extldflags "-static"' -mod vendor -o _output/linux/$*/local-volume-node-cleanup ./cmd/node-cleanup
8586
$(DOCKER) buildx build --file=./cmd/node-cleanup/Dockerfile --platform=linux/$* \
86-
-t $(STAGINGIMAGENODECLEANUPCONTROLLER):$(STAGINGVERSION) \
87+
-t $(STAGINGIMAGENODECLEANUPCONTROLLER):$(STAGINGVERSION)_linux_$* \
8788
--build-arg OS=linux \
8889
--build-arg ARCH=$* \
8990
--push .
@@ -95,6 +96,13 @@ build-and-push-container-windows-%: init-buildx
9596
--build-arg OSVERSION=$* \
9697
--push .
9798

99+
build-and-push-node-cleanup-controller-windows-%: init-buildx
100+
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -a -ldflags='-extldflags="-static" -X="main.version=${STAGINGVERSION}"' -mod vendor -o _output/windows/amd64/local-volume-node-cleanup.exe ./cmd/node-cleanup
101+
$(DOCKER) buildx build --file=./cmd/node-cleanup/Dockerfile.Windows --platform=windows/amd64 \
102+
-t $(STAGINGIMAGENODECLEANUPCONTROLLER):$(STAGINGVERSION)_windows_$* \
103+
--build-arg OSVERSION=$* \
104+
--push .
105+
98106
test: build-container-linux-amd64
99107
go test ./cmd/... ./pkg/...
100108
docker run --privileged -v $(PWD)/deployment/docker/test.sh:/test.sh --entrypoint bash $(STAGINGIMAGE):$(STAGINGVERSION)_linux_amd64 /test.sh
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Copyright 2023 The Kubernetes Authors.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
ARG OSVERSION
16+
FROM mcr.microsoft.com/windows/nanoserver:${OSVERSION}
17+
LABEL description="Local Volume Provisioner Node Cleanup Controller"
18+
19+
ARG OS=windows
20+
ARG ARCH=amd64
21+
ARG binary=./_output/${OS}/${ARCH}/local-volume-node-cleanup.exe
22+
COPY ${binary} main.exe
23+
24+
USER ContainerAdministrator
25+
ENTRYPOINT ["/main.exe"]

hack/release.sh

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ go version
110110
IMAGE="$REGISTRY/local-volume-provisioner"
111111
NODECLEANUPCONTROLLERIMAGE="$REGISTRY/local-volume-node-cleanup"
112112

113-
if [ -z "$REGISTRY" ];
113+
if [ -z "$REGISTRY" ]; then
114114
echo "error: REGISTRY must be set"
115115
exit 1
116116
fi
@@ -223,19 +223,19 @@ else
223223
echo "info: build and push is skipped"
224224
fi
225225

226-
echo "info: create multi-arch manifest for $IMAGE:$VERSION"
227226
function docker_create_multi_arch() {
228227
# tag_version is the version used in the docker manifest that ties
229228
# all of the images that were tagged with $VERSION
230229
local tag_version=${1}
231-
local manifest_image=$IMAGE:$tag_version
230+
local image=${2}
231+
local manifest_image=$image:$tag_version
232232

233233
# get the list of all the images created
234234
local linux_images=$(echo "${LINUX_ARCH}" | tr ' ' '\n' | while read -r arch; do \
235-
echo $IMAGE:${VERSION}_linux_${arch}; \
235+
echo $image:${VERSION}_linux_${arch}; \
236236
done);
237237
local windows_images=$(echo "${WINDOWS_DISTROS}" | tr ' ' '\n' | while read -r distro; do \
238-
echo $IMAGE:${VERSION}_windows_${distro}; \
238+
echo $image:${VERSION}_windows_${distro}; \
239239
done);
240240
local all_images="${linux_images} ${windows_images}"
241241
@@ -245,14 +245,14 @@ function docker_create_multi_arch() {
245245
# annotate the linux images with the right arch
246246
# from https://github.com/kubernetes/release/blob/8dbca63a6875e59e2234954ad3876d9490bbeede/images/build/debian-base/Makefile#L67-L70
247247
echo "${LINUX_ARCH}" | tr ' ' '\n' | while read -r arch; do
248-
local linux_image=$IMAGE:${VERSION}_linux_${arch}
248+
local linux_image=$image:${VERSION}_linux_${arch}
249249
docker manifest annotate --arch $arch $manifest_image $linux_image
250250
done
251251
252252
# annotate the windows images with the base image os-version
253253
# from https://github.com/kubernetes-csi/csi-release-tools/blob/5b9a1e06794ddb137ff7e2d565416cc6934ec380/build.make#L181-L189
254254
echo "${WINDOWS_DISTROS}" | tr ' ' '\n' | while read -r distro; do
255-
local windows_image=$IMAGE:${VERSION}_windows_${distro}
255+
local windows_image=$image:${VERSION}_windows_${distro}
256256
# the image matches the value in the Makefile
257257
local os_version=$(docker manifest inspect mcr.microsoft.com/windows/servercore:${distro} | grep "os.version" | head -n 1 | awk '{print $2}' | sed -e 's/"//g')
258258
docker manifest annotate --os-version ${os_version} $manifest_image $windows_image
@@ -261,7 +261,11 @@ function docker_create_multi_arch() {
261261
docker manifest push --purge $manifest_image
262262
}
263263
264-
docker_create_multi_arch $VERSION
264+
echo "info: create multi-arch manifest for $IMAGE:$VERSION"
265+
docker_create_multi_arch $VERSION $IMAGE
266+
267+
echo "info: create multi-arch manifest for $NODECLEANUPCONTROLLERIMAGE:$VERSION"
268+
docker_create_multi_arch $VERSION $NODECLEANUPCONTROLLERIMAGE
265269
266270
if ! is_stable_version "$VERSION" || [ -n "$SKIP_PUSH_LATEST" ]; then
267271
echo "info: VERSION '$VERSION' is not stable version or SKIP_PUSH_LATEST is set, skip pushing $VERSION as the latest image"
@@ -283,4 +287,7 @@ if [ "$VERSION" != "$latest_stable_version" ]; then
283287
fi
284288
285289
echo "info: VERSION '$VERSION' is latest stable version, tagging $IMAGE as latest"
286-
docker_create_multi_arch latest
290+
docker_create_multi_arch latest $IMAGE
291+
292+
echo "info: VERSION '$VERSION' is latest stable version, tagging $NODECLEANUPCONTROLLERIMAGE as latest"
293+
docker_create_multi_arch latest $NODECLEANUPCONTROLLERIMAGE

0 commit comments

Comments
 (0)