Skip to content
Draft
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ test: test-build ## test the build against all target platforms.
$(MAKE) build-image
IMAGE=$(IMAGE) \
KUBECTL_VERSION=$(KUBECTL_VERSION) HELM_VERSION=$(HELM_VERSION) \
KUSTOMIZE_VERSION=$(KUSTOMIZE_VERSION) K9S_VERSION=$(K9S_VERSION) \
KUSTOMIZE_VERSION=$(KUSTOMIZE_VERSION) \
./hack/test

test-build:
Expand Down
12 changes: 1 addition & 11 deletions hack/make/deps.mk
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,7 @@ KUSTOMIZE_SUM_amd64 := 6703a3a70a0c47cf0b37694030b54f1175a9dfeb17b3818b623ed58b9
# renovate: datasource=github-release-attachments depName=kubernetes-sigs/kustomize versioning=regex:^kustomize/v(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)$ digestVersion=kustomize/v5.5.0
KUSTOMIZE_SUM_s390x := 37dcd2429ef93886319b39671071b2e1c5307993cdb6a5c097cfefc97177d296

# renovate: datasource=github-release-attachments depName=derailed/k9s
K9S_VERSION := v0.32.6
# renovate: datasource=github-release-attachments depName=derailed/k9s digestVersion=v0.32.6
K9S_SUM_arm64 := dfe0bb78e17a4b72ff151e18e548467b6073608e1af4e2efb30a884eed772ea0
# renovate: datasource=github-release-attachments depName=derailed/k9s digestVersion=v0.32.6
K9S_SUM_amd64 := 3f5fa5b3563cf2962ecd78381df59a72a01d824d87f3c70493f7748807243755
# renovate: datasource=github-release-attachments depName=derailed/k9s digestVersion=v0.32.6
K9S_SUM_s390x := 261074c92d1d2e9b181700b2cf8d7166acff30d2bb425437c9f5027815de44b6

# Reduces the code duplication on Makefile by keeping all args into a single variable.
IMAGE_ARGS := --build-arg HELM_VERSION=$(HELM_VERSION) \
--build-arg KUBECTL_VERSION=$(KUBECTL_VERSION) --build-arg KUBECTL_SUM_arm64=$(KUBECTL_SUM_arm64) --build-arg KUBECTL_SUM_amd64=$(KUBECTL_SUM_amd64) --build-arg KUBECTL_SUM_s390x=$(KUBECTL_SUM_s390x) \
--build-arg KUSTOMIZE_VERSION=$(KUSTOMIZE_VERSION) --build-arg KUSTOMIZE_SUM_arm64=$(KUSTOMIZE_SUM_arm64) --build-arg KUSTOMIZE_SUM_amd64=$(KUSTOMIZE_SUM_amd64) --build-arg KUSTOMIZE_SUM_s390x=$(KUSTOMIZE_SUM_s390x) \
--build-arg K9S_VERSION=$(K9S_VERSION) --build-arg K9S_SUM_arm64=$(K9S_SUM_arm64) --build-arg K9S_SUM_amd64=$(K9S_SUM_amd64) --build-arg K9S_SUM_s390x=$(K9S_SUM_s390x)
--build-arg KUSTOMIZE_VERSION=$(KUSTOMIZE_VERSION) --build-arg KUSTOMIZE_SUM_arm64=$(KUSTOMIZE_SUM_arm64) --build-arg KUSTOMIZE_SUM_amd64=$(KUSTOMIZE_SUM_amd64) --build-arg KUSTOMIZE_SUM_s390x=$(KUSTOMIZE_SUM_s390x)
3 changes: 1 addition & 2 deletions hack/test
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ function expected_file(){

function check_files(){
echo "checking expected binaries:"
expected_file "/usr/bin/k9s" "0:0" "755"
expected_file "/usr/local/bin/helm" "0:0" "755"
expected_file "/usr/local/bin/helm-cmd" "0:0" "755"
expected_file "/usr/local/bin/k9s" "0:0" "755"
expected_file "/usr/local/bin/kubectl" "0:0" "755"
expected_file "/usr/local/bin/kustomize" "0:0" "755"
expected_file "/usr/local/bin/welcome" "0:0" "755"
Expand Down Expand Up @@ -63,7 +63,6 @@ function check_versions(){
echo "checking command versions:"
expected_version "helm" "${HELM_VERSION}"
expected_version "kustomize" "${KUSTOMIZE_VERSION}"
expected_version "k9s" "${K9S_VERSION}"
# --client=true is used so that it does not fail trying to
# identify the server version.
expected_version "kubectl --client=true" "${KUBECTL_VERSION}"
Expand Down
24 changes: 14 additions & 10 deletions package/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,27 +43,31 @@ RUN curl --output /tmp/kustomize.tar.gz -sLf "https://github.com/kubernetes-sigs
echo "${!KUSTOMIZE_SUM} /tmp/kustomize.tar.gz" | sha256sum -c - && \
tar -xvzf /tmp/kustomize.tar.gz -C / kustomize

# Stage k9s into build
Comment thread
mallardduck marked this conversation as resolved.
ENV K9S_SUM="K9S_SUM_${TARGETARCH}"
RUN curl --output /tmp/k9s.tar.gz -sLf "https://github.com/derailed/k9s/releases/download/${K9S_VERSION}/k9s_Linux_${TARGETARCH}.tar.gz" && \
echo "${!K9S_SUM} /tmp/k9s.tar.gz" | sha256sum -c - && \
tar -xvzf /tmp/k9s.tar.gz -C / k9s

FROM registry.suse.com/bci/bci-base:${BCI_VERSION} AS zypper

ARG BCI_VERSION=15.6
ENV BCI_VERSION=${BCI_VERSION}

# Creates the based dir for the target image, and hydrates it with the
# original contents of the final image.
RUN mkdir /chroot
COPY --from=final / /chroot/

# Setup repo needed to install k9s package
RUN zypper --non-interactive ar https://download.opensuse.org/repositories/devel:kubic/${BCI_VERSION}/devel:kubic.repo \
&& zypper --non-interactive ar https://download.opensuse.org/repositories/devel:/kubic/openSUSE_Factory_ARM/ devel_kubic_arm \
&& zypper --non-interactive ar https://download.opensuse.org/repositories/devel:/kubic/openSUSE_Factory_zSystems/ devel_kubic_zed \
Comment thread
mallardduck marked this conversation as resolved.
&& rpm --import https://download.opensuse.org/repositories/devel:/kubic/${BCI_VERSION}/repodata/repomd.xml.key \
--import https://download.opensuse.org/repositories/devel:/kubic/openSUSE_Factory_ARM/repodata/repomd.xml.key \
--import https://download.opensuse.org/repositories/devel:/kubic/openSUSE_Factory_zSystems/repodata/repomd.xml.key \
&& zypper --non-interactive refresh

# The final image does not contain zypper, --installroot is used to
# install all artefacts within a dir (/chroot) that can then be copied
# over to a scratch image.
RUN zypper --non-interactive refresh && \
zypper --installroot /chroot -n rm busybox-vi busybox-links && \
zypper --installroot /chroot -n in bash-completion jq vim curl && \
zypper --installroot /chroot clean -a && \
rm -rf /chroot/var/cache/zypp/* /chroot/var/log/zypp/* /chroot/etc/zypp/
zypper --installroot /chroot -n in bash-completion jq vim curl k9s
Comment on lines 68 to +70
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really understand this part, why are you installing k9s into /chroot/ that you copied from the busybox image? What's the advantage of this added complexity, when in the end you copy everything into a scratch image anyway?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dcermak The final image is largely a copy of the bci-busybox plus the zypper installed components (and other downloaded/built artefacts).

The copy into scratch avoids redundant layers if this were to be copied into another bci-busybox final image.

Given that bci-busybox does not include zypper, is there a better approach to be able to zipper in on it?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just install everything into the image based on bci-base and copy everything out of it into the scratch image. The intermediate step of running the zypper in in a chroot based on busybox is only asking for trouble, as your shell is now POSIX /bin/sh and not bash, which too many rpm scriptlets do not support.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dcermak good point, this is actually a practice we observed in other teams using OBS/IBS. Issues with the rpm scriptlets would make the zypper operation fail or would it be a silent, resulting in potential unexpected behaviours executing the installed app?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The failure could be either silent or you could end up with a broken package, it's impossible to tell in advance. You'd probably see a failure in the rpm installation log, but you'd have to inspect them manually.



RUN echo 'shell:x:1000:1000:shell,,,:/home/shell:/bin/bash' > /chroot/etc/passwd && \
Expand All @@ -84,7 +88,7 @@ FROM scratch

COPY --from=zypper /chroot /
COPY --chown=root:root --chmod=0755 --from=helm /helm/bin/helm /usr/local/bin/
COPY --chown=root:root --chmod=0755 --from=build /kubectl /k9s /kustomize* /usr/local/bin/
COPY --chown=root:root --chmod=0755 --from=build /kubectl /kustomize* /usr/local/bin/
COPY --chown=root:root --chmod=0755 package/helm-cmd package/welcome /usr/local/bin/
COPY --chown=1000:1000 --chmod=0755 package/kustomize.sh /home/shell/

Expand Down