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

chore: replace the base image UBI-minimal by UBI-micro #6662

Closed
wants to merge 1 commit into from

Conversation

fgiloux
Copy link
Contributor

@fgiloux fgiloux commented Jan 15, 2024

Description of the change:

This pull request replaces the base image, which is used for operator images. It introduces UBI-micro instead of UBI-minimal.

Motivation for the change:

UBI-micro has a few advantages compared to UBI-minimal:

  • smaller attack surface
  • no package manager
  • size

Fixes #6652

UBI-micro has a few advantages compared to UBI-minimal:
- smaller attack surface
- no package manager
- size

Signed-off-by: Frederic Giloux <frederic.giloux@isovalent.com>
@fgiloux
Copy link
Contributor Author

fgiloux commented Jan 17, 2024

cc @varshaprasad96

@herrberk
Copy link

Why not UBI 9 micro instead?

@fgiloux
Copy link
Contributor Author

fgiloux commented Jan 19, 2024

@herrberk because UBI 8 minimal was in use before. I am not against moving from 8 to 9 but this PR is about moving from minimal to micro.

Comment on lines -22 to -31
ENV GO_VERSION 1.19

ARG TARGETARCH
RUN microdnf install -y make gcc which tar gzip
RUN curl -sSLo /tmp/go.tar.gz https://golang.org/dl/go${GO_VERSION}.linux-${TARGETARCH}.tar.gz \
&& rm -rf /usr/local/go \
&& tar -C /usr/local -xzf /tmp/go.tar.gz \
&& ln -sf /usr/local/go/bin/* /usr/local/bin/ \
&& rm -f /tmp/go.tar.gz \
&& go version
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you elaborate on why this was removed?

I believe that Go is required to be present in the final image due to the go plugin running things like go mod tidy at the end of scaffolding of files. Without Go being present in the final image, using this image will fail to scaffold Go based operator projects.

I believe that the ubi micro images don't include a package manager so we might be able to COPY --from=builder ... the necessary stuff to have Go "installed" in the final image.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That should be removed from the runtime not the builder image. go mod tidy should be run at build time in the builder image. Is that not the case?
If I understand you correctly you are saying that the same image is used for build and run time. If that's the case it should get split for introducing UBI-micro. Adding golang, tar would kill the purpose (reducing the attack surface) of the exercise.

Copy link
Contributor

@everettraven everettraven Jan 22, 2024

Choose a reason for hiding this comment

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

go mod tidy should be run at build time in the builder image. Is that not the case?

The go mod tidy operation that I am referring to is run as part of the scaffolding logic that gets run when you are creating a new Go based operator project using operator-sdk init .... Due to this, Go must be installed in the final image.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am probably missing the target. For golang operator there is in kubebuilder:
FROM gcr.io/distroless/static:nonroot
this gets replaced in operator-sdk so that operator-sdk init generates (without removing the comment about distroless :-) )
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.8
This is where I would like to see ubi-micro.

Copy link
Contributor

Choose a reason for hiding this comment

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

That replacement should only occur in an operator scaffolded with the OpenShift version of the operator-sdk and not the community (operator-framework) version of the operator-sdk.

@@ -1,4 +1,4 @@
FROM registry.access.redhat.com/ubi8:8.7
FROM registry.access.redhat.com/ubi8/ubi-micro:8.9
Copy link
Contributor

Choose a reason for hiding this comment

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

does ubi-micro include the tar command? scorecard uses this image in container within a Pod for untaring bundle contents using the tar command. Without the tar command present in this image, I believe scorecard will always fail.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe we should not migrate scorecard to UBI-Micro. It is not that important as it does not end up as a base image of the end product operator.
To answer your question: tar is not included in ubi-micro.

@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 2, 2024
@openshift-merge-robot
Copy link

PR needs rebase.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@openshift-bot
Copy link

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

@openshift-ci openshift-ci bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label May 3, 2024
@openshift-bot
Copy link

Stale issues rot after 30d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.
Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle rotten
/remove-lifecycle stale

@openshift-ci openshift-ci bot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Jun 2, 2024
@openshift-bot
Copy link

Rotten issues close after 30d of inactivity.

Reopen the issue by commenting /reopen.
Mark the issue as fresh by commenting /remove-lifecycle rotten.
Exclude this issue from closing again by commenting /lifecycle frozen.

/close

@openshift-ci openshift-ci bot closed this Jul 3, 2024
Copy link

openshift-ci bot commented Jul 3, 2024

@openshift-bot: Closed this PR.

In response to this:

Rotten issues close after 30d of inactivity.

Reopen the issue by commenting /reopen.
Mark the issue as fresh by commenting /remove-lifecycle rotten.
Exclude this issue from closing again by commenting /lifecycle frozen.

/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Investigate UBI-micro for Ansible, Helm and SDK base images
5 participants