Skip to content

Commit 1574c93

Browse files
committed
feat: use cosign to verify kubelet binaries
Fixes #68 The benefit is that we can probably turn this into a workflow that is triggered on kubelet version, as we don't need to change source code most of the time to trigger a release build (there is no sha256/sha512 to update anymore). Signed-off-by: Andrey Smirnov <[email protected]>
1 parent 8a8d8cb commit 1574c93

File tree

2 files changed

+11
-30
lines changed

2 files changed

+11
-30
lines changed

Dockerfile

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,24 @@
44
ARG BASE_IMAGE=registry.k8s.io/build-image/debian-iptables:bookworm-v1.0.0
55
ARG SLIM_PACKAGES="ca-certificates libcap2 ethtool iproute2 nfs-common socat util-linux"
66

7-
FROM alpine:latest AS builder-amd64
7+
FROM alpine:latest AS builder
88

9-
ARG TARGETARCH
10-
ARG KUBELET_VER
11-
ARG KUBELET_SHA512_AMD64
12-
ARG KUBELET_URL=https://dl.k8s.io/release/${KUBELET_VER}/bin/linux/${TARGETARCH}/kubelet
13-
14-
RUN wget -q -O /kubelet ${KUBELET_URL} \
15-
&& sha512sum /kubelet \
16-
&& echo "${KUBELET_SHA512_AMD64} /kubelet" | sha512sum -cw \
17-
&& chmod +x /kubelet
18-
19-
FROM alpine:latest AS builder-arm64
9+
RUN apk add --no-cache cosign
2010

2111
ARG TARGETARCH
2212
ARG KUBELET_VER
23-
ARG KUBELET_SHA512_ARM64
2413
ARG KUBELET_URL=https://dl.k8s.io/release/${KUBELET_VER}/bin/linux/${TARGETARCH}/kubelet
2514

26-
RUN wget -q -O /kubelet ${KUBELET_URL} \
27-
&& sha512sum /kubelet \
28-
&& echo "${KUBELET_SHA512_ARM64} /kubelet" | sha512sum -cw \
29-
&& chmod +x /kubelet
15+
RUN wget -q -O /kubelet ${KUBELET_URL}
16+
RUN wget -q -O /kubelet.sig ${KUBELET_URL}.sig
17+
RUN wget -q -O /kubelet.cert ${KUBELET_URL}.cert
3018

31-
ARG TARGETARCH
32-
FROM builder-${TARGETARCH} AS builder
19+
# see https://kubernetes.io/docs/tasks/administer-cluster/verify-signed-artifacts/
20+
RUN cosign verify-blob "/kubelet" \
21+
--signature "/kubelet.sig" \
22+
--certificate "/kubelet.cert" \
23+
--certificate-identity [email protected] \
24+
--certificate-oidc-issuer https://accounts.google.com
3325

3426
########################
3527

Makefile

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD)
66
REGISTRY_AND_USERNAME := $(REGISTRY)/$(USERNAME)
77
NAME := kubelet
88
KUBELET_VER := v1.35.0-alpha.2
9-
KUBELET_SHA512_AMD64 := 1b4bfe455eafec7aa5f5bc1510d4b9eebe1e62ac85544871409ffca9ee0b7e226862356110acc3d96bad5d9205e9e46032c05c238cb51d50cb438de51d9cfedf
10-
KUBELET_SHA512_ARM64 := e2fffce6c95c367c8441c194ecb9dadbf5c394a834a6b8d4535b550694a3e03ca0d41183818a7623a2a09e934d49522d8b9721d838ba77d8a675c15e376ac162
119

1210
# For kubelet versions >= 1.31.0, the slim image is the default one, and previous image is labeled as -fat.
1311
# For kubelet versions < 1.31.0, the fat image is the default one, and previous image is labeled as -slim.
@@ -33,8 +31,6 @@ COMMON_ARGS += --build-arg=REGISTRY_AND_USERNAME=$(REGISTRY_AND_USERNAME)
3331
COMMON_ARGS += --build-arg=NAME=$(NAME)
3432
COMMON_ARGS += --build-arg=TAG=$(TAG)
3533
COMMON_ARGS += --build-arg=KUBELET_VER=$(KUBELET_VER)
36-
COMMON_ARGS += --build-arg=KUBELET_SHA512_AMD64=$(KUBELET_SHA512_AMD64)
37-
COMMON_ARGS += --build-arg=KUBELET_SHA512_ARM64=$(KUBELET_SHA512_ARM64)
3834

3935
KRES_IMAGE ?= ghcr.io/siderolabs/kres:latest
4036

@@ -57,13 +53,6 @@ docker-%: ## Builds the specified target defined in the Dockerfile using the def
5753
container:
5854
@$(MAKE) docker-$@ TARGET_ARGS="--push=$(PUSH)"
5955

60-
.PHONY: update-sha
61-
update-sha: update-sha-amd64 update-sha-arm64 ## Updates the kubelet sha512 checksums in the Makefile.
62-
63-
update-sha-%:
64-
sha512=`curl -sL https://dl.k8s.io/release/$(KUBELET_VER)/bin/linux/${*}/kubelet.sha512`; \
65-
sed -i "s/KUBELET_SHA512_$(shell echo '$*' | tr '[:lower:]' '[:upper:]') := .*/KUBELET_SHA512_$(shell echo '$*' | tr '[:lower:]' '[:upper:]') := $${sha512}/" Makefile
66-
6756
.PHONY: rekres
6857
rekres:
6958
@docker pull $(KRES_IMAGE)

0 commit comments

Comments
 (0)