diff --git a/Makefile b/Makefile index 28820a01213e..a5abe1203949 100644 --- a/Makefile +++ b/Makefile @@ -108,7 +108,7 @@ SHA512SUM=$(shell command -v sha512sum || echo "shasum -a 512") # gvisor tag to automatically push changes to # to update minikubes default, update deploy/addons/gvisor -GVISOR_TAG ?= latest +GVISOR_TAG ?= v0.0.1 # auto-pause-hook tag to push changes to AUTOPAUSE_HOOK_TAG ?= v0.0.5 @@ -787,13 +787,15 @@ out/gvisor-addon: ## Build gvisor addon $(Q)GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o $@ cmd/gvisor/gvisor.go .PHONY: gvisor-addon-image -gvisor-addon-image: out/gvisor-addon ## Build docker image for gvisor - docker build --platform=linux/amd64 -t $(REGISTRY)/gvisor-addon:$(GVISOR_TAG) -f deploy/gvisor/Dockerfile . +gvisor-addon-image: + docker build -t $(REGISTRY)/gvisor-addon:$(GVISOR_TAG) -f deploy/gvisor/Dockerfile . .PHONY: push-gvisor-addon-image -push-gvisor-addon-image: gvisor-addon-image +push-gvisor-addon-image: docker-multi-arch-build docker login gcr.io/k8s-minikube - $(MAKE) push-docker IMAGE=$(REGISTRY)/gvisor-addon:$(GVISOR_TAG) + docker buildx create --name multiarch --bootstrap + docker buildx build --push --builder multiarch --platform linux/amd64,linux/arm64 -t $(REGISTRY)/gvisor-addon:$(GVISOR_TAG) -t $(REGISTRY)/gvisor-addon:latest -f deploy/gvisor/Dockerfile . + docker buildx rm multiarch .PHONY: release-iso release-iso: minikube-iso-aarch64 minikube-iso-x86_64 checksum ## Build and release .iso files diff --git a/deploy/gvisor/Dockerfile b/deploy/gvisor/Dockerfile index dbe6d37aa938..b128bbcc8baf 100644 --- a/deploy/gvisor/Dockerfile +++ b/deploy/gvisor/Dockerfile @@ -12,8 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. +FROM golang:1.22.1 AS builder +WORKDIR /app +COPY go.mod go.sum ./ +RUN go mod download +COPY ./ ./ +RUN GOOS=linux CGO_ENABLED=0 go build -o gvisor-addon cmd/gvisor/gvisor.go + # Need an image with chroot FROM alpine:3 RUN apk -U add ca-certificates -COPY out/gvisor-addon /gvisor-addon +COPY --from=builder /app/gvisor-addon /gvisor-addon CMD ["/gvisor-addon"] diff --git a/hack/update/golang_version/update_golang_version.go b/hack/update/golang_version/update_golang_version.go index f7d5f79ac6be..22a6223aca7c 100644 --- a/hack/update/golang_version/update_golang_version.go +++ b/hack/update/golang_version/update_golang_version.go @@ -69,6 +69,11 @@ var ( `golang:.* AS`: `golang:{{.StableVersion}} AS`, }, }, + "deploy/gvisor/Dockerfile": { + Replace: map[string]string{ + `golang:.* AS`: `golang:{{.StableVersion}} AS`, + }, + }, } ) diff --git a/pkg/minikube/assets/addons.go b/pkg/minikube/assets/addons.go index 8b995f2bc655..8f3acc1f05b4 100644 --- a/pkg/minikube/assets/addons.go +++ b/pkg/minikube/assets/addons.go @@ -521,7 +521,7 @@ var Addons = map[string]*Addon{ "gvisor-runtimeclass.yaml", "0640"), }, false, "gvisor", "minikube", "", "https://github.com/kubernetes/minikube/blob/master/deploy/addons/gvisor/README.md", map[string]string{ - "GvisorAddon": "k8s-minikube/gvisor-addon:4@sha256:4bdc0bec3f36a32e534d9da98552810c832dd58fd0a361e5c0b836606b164bc2", + "GvisorAddon": "k8s-minikube/gvisor-addon:v0.0.1@sha256:d29adbddc7a44dab4c675c0eaea398907fe1f33f5f723274b0d40195b3076cae", }, map[string]string{ "GvisorAddon": "gcr.io", }),