Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add slim image #84

Merged
merged 1 commit into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 28 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
## Using the builder this way keeps us from having to install wget and adding an extra
## fat step that just does a chmod on the kubelet binary

FROM alpine:latest as builder-amd64
ARG BASE_IMAGE=registry.k8s.io/build-image/debian-iptables:bookworm-v1.0.0
ARG SLIM_PACKAGES="ca-certificates libcap2 ethtool iproute2 nfs-common socat util-linux"

FROM alpine:latest AS builder-amd64

ARG TARGETARCH
ARG KUBELET_VER
Expand All @@ -13,7 +16,7 @@ RUN wget -q -O /kubelet ${KUBELET_URL} \
&& echo "${KUBELET_SHA512_AMD64} /kubelet" | sha512sum -cw \
&& chmod +x /kubelet

FROM alpine:latest as builder-arm64
FROM alpine:latest AS builder-arm64

ARG TARGETARCH
ARG KUBELET_VER
Expand All @@ -26,35 +29,46 @@ RUN wget -q -O /kubelet ${KUBELET_URL} \
&& chmod +x /kubelet

ARG TARGETARCH
FROM builder-${TARGETARCH} as builder
FROM builder-${TARGETARCH} AS builder

########################

FROM registry.k8s.io/build-image/debian-iptables:bookworm-v1.0.0 as container
FROM ${BASE_IMAGE} AS container-fat

RUN clean-install \
--allow-change-held-packages \
procps \
${SLIM_PACKAGES} \
bash \
ca-certificates \
libcap2 \
ceph-common \
cifs-utils \
e2fsprogs \
xfsprogs \
ethtool \
glusterfs-client \
iproute2 \
jq \
nfs-common \
socat \
procps \
ucf \
udev \
util-linux \
ceph-common
xfsprogs

COPY --from=builder /kubelet /usr/local/bin/kubelet

# Add wrapper for iscsiadm
COPY files/iscsiadm /usr/local/sbin/iscsiadm

LABEL org.opencontainers.image.source https://github.com/siderolabs/kubelet
LABEL org.opencontainers.image.source="https://github.com/siderolabs/kubelet"

ENTRYPOINT ["/usr/local/bin/kubelet"]

########################

FROM ${BASE_IMAGE} AS container-slim

RUN clean-install \
--allow-change-held-packages \
${SLIM_PACKAGES}

COPY --from=builder /kubelet /usr/local/bin/kubelet

LABEL org.opencontainers.image.source="https://github.com/siderolabs/kubelet"

ENTRYPOINT ["/usr/local/bin/kubelet"]
15 changes: 14 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@ KUBELET_VER := v1.31.0-rc.1
KUBELET_SHA512_AMD64 := b52716aadd95d73c408b3b30baae288fd10f8c024424671392e233f00316d3f0546a6c6780e81f5ddac039020bcc80dfa85202939ac70ccec74a7b6bbdf26097
KUBELET_SHA512_ARM64 := 2122ffaca810410ff0ac2cb0b6c1b05908fcdeda1dc64f310ae982a58278917a51f77fdfdc89713fbf5c3fe0ee16c9626c0464bb358a863900a38a19b8a421f7

# For kubelet versions >= 1.31.0, the slim image is the default one, and previous image is labeled as -fat.
# For kubelet versions < 1.31.0, the fat image is the default one, and previous image is labeled as -slim.
USE_SLIM := $(shell (printf "%s\n" "$(KUBELET_VER)" "v1.30.99" | sort -V -C) && echo false || echo true)

ifeq ($(USE_SLIM),true)
SLIM_TAG_SUFFIX :=
FAT_TAG_SUFFIX := -fat
else
SLIM_TAG_SUFFIX := -slim
FAT_TAG_SUFFIX :=
endif

BUILD := docker buildx build
PLATFORM ?= linux/amd64,linux/arm64
PROGRESS ?= auto
Expand Down Expand Up @@ -38,7 +50,8 @@ local-%: ## Builds the specified target defined in the Dockerfile using the loca
@$(MAKE) target-$* TARGET_ARGS="--output=type=local,dest=$(DEST) $(TARGET_ARGS)"

docker-%: ## Builds the specified target defined in the Dockerfile using the default output type.
@$(MAKE) target-$* TARGET_ARGS="--tag $(REGISTRY_AND_USERNAME)/$(NAME):$(TAG) $(TARGET_ARGS)"
@$(MAKE) target-$*-fat TARGET_ARGS="--tag $(REGISTRY_AND_USERNAME)/$(NAME):$(TAG)$(FAT_TAG_SUFFIX) $(TARGET_ARGS)"
@$(MAKE) target-$*-slim TARGET_ARGS="--tag $(REGISTRY_AND_USERNAME)/$(NAME):$(TAG)$(SLIM_TAG_SUFFIX) $(TARGET_ARGS)"

.PHONY: container
container:
Expand Down
2 changes: 1 addition & 1 deletion files/iscsiadm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/usr/bin/sh

iscsid_pid=$(pgrep iscsid)

Expand Down