Merge pull request #18453 from spowelljr/buildMultiarchGvisor

Addon gvisor: Add building arm64 image
pull/18462/head
Medya Ghazizadeh 2024-03-20 10:46:41 -07:00 committed by GitHub
commit 137c5ef835
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 21 additions and 7 deletions

View File

@ -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

View File

@ -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"]

View File

@ -69,6 +69,11 @@ var (
`golang:.* AS`: `golang:{{.StableVersion}} AS`,
},
},
"deploy/gvisor/Dockerfile": {
Replace: map[string]string{
`golang:.* AS`: `golang:{{.StableVersion}} AS`,
},
},
}
)

View File

@ -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",
}),