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

Distroless image for TF operator #1124

Merged
merged 3 commits into from
Jan 18, 2020

Conversation

krishnadurai
Copy link
Contributor

@krishnadurai krishnadurai commented Jan 3, 2020

Relates to: kubeflow/kubeflow#4590

tf_smoke.py removed
Golang updated to 1.13.5

/hold
/cc @swiftdiaries @jlewi


This change is Reviewable

@krishnadurai
Copy link
Contributor Author

krishnadurai commented Jan 3, 2020

TODOs:

  • Check CVE count
  • Test in K8s cluster

@coveralls
Copy link

coveralls commented Jan 3, 2020

Coverage Status

Coverage remained the same at 96.512% when pulling a91c401 on krishnadurai:feature/distroless-image into 0b9711d on kubeflow:master.

@TravisBuddy
Copy link

Hey @krishnadurai,
Your changes look good to me!

View build log

TravisBuddy Request Identifier: 98003e00-2dd8-11ea-a185-6fb6d15019ed

RUN chmod a+x /opt/kubeflow/tf-operator.v1

ENTRYPOINT ["/opt/kubeflow/tf-operator.v1"]
ENTRYPOINT ["/opt/tf-operator.v1"]

Choose a reason for hiding this comment

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

Probable permission issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good question. Here's the pattern for moving binaries to a distroless image given by the example:

https://github.com/GoogleContainerTools/distroless/blob/5a460b2310a3e2e3c0590835614860747d6e8769/examples/go/Dockerfile#L10-L12

The idea here is to keep the distroless image with just the essentials for golang and its binaries. That leaves this system with just the user who's running this binary. So I guess setting permissions isn't necessary as advocated by the example.

@nrchakradhar
Copy link

nrchakradhar commented Jan 3, 2020

INFO:root:Message: failed to create containerd task: OCI runtime create failed: container_linux.go:346: starting container process caused "exec: "/opt/kubeflow/tf-operator.v1": stat /opt/kubeflow/tf-operator.v1: no such file or dir
ectory": unknown

INFO:root:Command:
INFO:root:/opt/kubeflow/tf-operator.v1

command still seems to be using /opt/kubeflow/tf-operator.v1, but the change is to use /opt/.

As per the manifest its still seems to use old command. https://github.com/kubeflow/manifests/blob/9c9acdb1c319e04cc2b9fbd31a59bfd7bc062fbd/tf-training/tf-job-operator/base/deployment.yaml#L15

@krishnadurai
Copy link
Contributor Author

krishnadurai commented Jan 3, 2020

@nrchakradhar thanks for an early review. I will look to fix these issues in some time. This is still a work in progress.

@krishnadurai
Copy link
Contributor Author

/retest

@TravisBuddy
Copy link

Hey @krishnadurai,
Your changes look good to me!

View build log

TravisBuddy Request Identifier: dc7fea00-2e85-11ea-8eaa-0b08c4ee3d08

@nrchakradhar
Copy link

@nrchakradhar thanks for an early review. I will look to fix these issues in some time. This is still a work in progress.

@krishnadurai Please do not consider this as a review. I was just trying to understand why the pre-submit failed and probably provide some help.

@swiftdiaries
Copy link
Member

@krishnadurai Could you please run both the images through a vuln scanner and detail how this change improves upon the existing image?

@krishnadurai
Copy link
Contributor Author

@swiftdiaries I'm on it.

@krishnadurai
Copy link
Contributor Author

krishnadurai commented Jan 7, 2020

Report with Anchore CLI

DIstroless Image: CVE count 13 all negligible severity.

anchore-cli image vuln docker.io/krishnadurai/distless-tfop:latest all
Vulnerability ID        Package                           Severity          Fix         CVE Refs                Vulnerability URL
CVE-2007-6755           libssl1.1-1.1.1d-0+deb10u1        Negligible        None        CVE-2007-6755           https://security-tracker.debian.org/tracker/CVE-2007-6755
CVE-2007-6755           openssl-1.1.1d-0+deb10u1          Negligible        None        CVE-2007-6755           https://security-tracker.debian.org/tracker/CVE-2007-6755
CVE-2010-0928           libssl1.1-1.1.1d-0+deb10u1        Negligible        None        CVE-2010-0928           https://security-tracker.debian.org/tracker/CVE-2010-0928
CVE-2010-0928           openssl-1.1.1d-0+deb10u1          Negligible        None        CVE-2010-0928           https://security-tracker.debian.org/tracker/CVE-2010-0928
CVE-2010-4051           libc6-2.28-10                     Negligible        None        CVE-2010-4051           https://security-tracker.debian.org/tracker/CVE-2010-4051
CVE-2010-4052           libc6-2.28-10                     Negligible        None        CVE-2010-4052           https://security-tracker.debian.org/tracker/CVE-2010-4052
CVE-2010-4756           libc6-2.28-10                     Negligible        None        CVE-2010-4756           https://security-tracker.debian.org/tracker/CVE-2010-4756
CVE-2018-20796          libc6-2.28-10                     Negligible        None        CVE-2018-20796          https://security-tracker.debian.org/tracker/CVE-2018-20796
CVE-2019-1010022        libc6-2.28-10                     Negligible        None        CVE-2019-1010022        https://security-tracker.debian.org/tracker/CVE-2019-1010022
CVE-2019-1010023        libc6-2.28-10                     Negligible        None        CVE-2019-1010023        https://security-tracker.debian.org/tracker/CVE-2019-1010023
CVE-2019-1010024        libc6-2.28-10                     Negligible        None        CVE-2019-1010024        https://security-tracker.debian.org/tracker/CVE-2019-1010024
CVE-2019-1010025        libc6-2.28-10                     Negligible        None        CVE-2019-1010025        https://security-tracker.debian.org/tracker/CVE-2019-1010025
CVE-2019-9192           libc6-2.28-10                     Negligible        None        CVE-2019-9192           https://security-tracker.debian.org/tracker/CVE-2019-9192

@krishnadurai
Copy link
Contributor Author

Report with Anchore CLI

TF operator current image (gcr.io/kubeflow-images-public/tf_operator:v0.7.0): CVE count 38 - 34 Medium and 4 Low

anchore-cli image vuln gcr.io/kubeflow-images-public/tf_operator:v0.7.0 all
Vulnerability ID        Package                                        Severity        Fix                     CVE Refs                                                                                  Vulnerability URL
RHSA-2019:3575          elfutils-default-yama-scope-0.174-6.el8        Low             0:0.176-5.el8           CVE-2019-7149,CVE-2019-7665,CVE-2019-7150,CVE-2019-7146,CVE-2019-7664                     https://access.redhat.com/errata/RHSA-2019:3575
RHSA-2019:3575          elfutils-libelf-0.174-6.el8                    Low             0:0.176-5.el8           CVE-2019-7149,CVE-2019-7665,CVE-2019-7150,CVE-2019-7146,CVE-2019-7664                     https://access.redhat.com/errata/RHSA-2019:3575
RHSA-2019:3575          elfutils-libs-0.174-6.el8                      Low             0:0.176-5.el8           CVE-2019-7149,CVE-2019-7665,CVE-2019-7150,CVE-2019-7146,CVE-2019-7664                     https://access.redhat.com/errata/RHSA-2019:3575
RHSA-2019:3700          openssl-libs-1.1.1-8.el8                       Low             1:1.1.1c-2.el8          CVE-2018-0734,CVE-2018-0735,CVE-2019-1543                                                 https://access.redhat.com/errata/RHSA-2019:3700
RHSA-2019:3513          glibc-2.28-42.el8_0.1                          Medium          0:2.28-72.el8           CVE-2016-10739                                                                            https://access.redhat.com/errata/RHSA-2019:3513
RHSA-2019:3513          glibc-common-2.28-42.el8_0.1                   Medium          0:2.28-72.el8           CVE-2016-10739                                                                            https://access.redhat.com/errata/RHSA-2019:3513
RHSA-2019:3513          glibc-minimal-langpack-2.28-42.el8_0.1         Medium          0:2.28-72.el8           CVE-2016-10739                                                                            https://access.redhat.com/errata/RHSA-2019:3513
RHSA-2019:3520          platform-python-3.6.8-4.el8_0                  Medium          0:3.6.8-15.1.el8        CVE-2019-9740,CVE-2019-9947,CVE-2019-5010,CVE-2019-9948                                   https://access.redhat.com/errata/RHSA-2019:3520
RHSA-2019:3520          python3-libs-3.6.8-4.el8_0                     Medium          0:3.6.8-15.1.el8        CVE-2019-9740,CVE-2019-9947,CVE-2019-5010,CVE-2019-9948                                   https://access.redhat.com/errata/RHSA-2019:3520
RHSA-2019:3530          glib2-2.56.4-1.el8                             Medium          0:2.56.4-7.el8          CVE-2019-12450                                                                            https://access.redhat.com/errata/RHSA-2019:3530
RHSA-2019:3583          dnf-4.0.9.2-5.el8                              Medium          0:4.2.7-6.el8           CVE-2019-3817,CVE-2018-20534                                                              https://access.redhat.com/errata/RHSA-2019:3583
RHSA-2019:3583          dnf-data-4.0.9.2-5.el8                         Medium          0:4.2.7-6.el8           CVE-2019-3817,CVE-2018-20534                                                              https://access.redhat.com/errata/RHSA-2019:3583
RHSA-2019:3583          libcomps-0.1.8-13.el8                          Medium          0:0.1.11-2.el8          CVE-2019-3817,CVE-2018-20534                                                              https://access.redhat.com/errata/RHSA-2019:3583
RHSA-2019:3583          libdnf-0.22.5-5.el8_0                          Medium          0:0.35.1-8.el8          CVE-2019-3817,CVE-2018-20534                                                              https://access.redhat.com/errata/RHSA-2019:3583
RHSA-2019:3583          librepo-1.9.2-1.el8                            Medium          0:1.10.3-3.el8          CVE-2019-3817,CVE-2018-20534                                                              https://access.redhat.com/errata/RHSA-2019:3583
RHSA-2019:3583          librhsm-0.0.3-2.el8                            Medium          0:0.0.3-3.el8           CVE-2019-3817,CVE-2018-20534                                                              https://access.redhat.com/errata/RHSA-2019:3583
RHSA-2019:3583          libsolv-0.6.35-6.el8                           Medium          0:0.7.4-3.el8           CVE-2019-3817,CVE-2018-20534                                                              https://access.redhat.com/errata/RHSA-2019:3583
RHSA-2019:3583          python3-dnf-4.0.9.2-5.el8                      Medium          0:4.2.7-6.el8           CVE-2019-3817,CVE-2018-20534                                                              https://access.redhat.com/errata/RHSA-2019:3583
RHSA-2019:3583          python3-dnf-plugins-core-4.0.2.2-3.el8         Medium          0:4.0.8-3.el8           CVE-2019-3817,CVE-2018-20534                                                              https://access.redhat.com/errata/RHSA-2019:3583
RHSA-2019:3583          python3-hawkey-0.22.5-5.el8_0                  Medium          0:0.35.1-8.el8          CVE-2019-3817,CVE-2018-20534                                                              https://access.redhat.com/errata/RHSA-2019:3583
RHSA-2019:3583          python3-libcomps-0.1.8-13.el8                  Medium          0:0.1.11-2.el8          CVE-2019-3817,CVE-2018-20534                                                              https://access.redhat.com/errata/RHSA-2019:3583
RHSA-2019:3583          python3-libdnf-0.22.5-5.el8_0                  Medium          0:0.35.1-8.el8          CVE-2019-3817,CVE-2018-20534                                                              https://access.redhat.com/errata/RHSA-2019:3583
RHSA-2019:3583          python3-librepo-1.9.2-1.el8                    Medium          0:1.10.3-3.el8          CVE-2019-3817,CVE-2018-20534                                                              https://access.redhat.com/errata/RHSA-2019:3583
RHSA-2019:3583          yum-4.0.9.2-5.el8                              Medium          0:4.2.7-6.el8           CVE-2019-3817,CVE-2018-20534                                                              https://access.redhat.com/errata/RHSA-2019:3583
RHSA-2019:3592          systemd-239-13.el8_0.5                         Medium          0:239-18.el8            CVE-2019-15718                                                                            https://access.redhat.com/errata/RHSA-2019:3592
RHSA-2019:3592          systemd-libs-239-13.el8_0.5                    Medium          0:239-18.el8            CVE-2019-15718                                                                            https://access.redhat.com/errata/RHSA-2019:3592
RHSA-2019:3592          systemd-pam-239-13.el8_0.5                     Medium          0:239-18.el8            CVE-2019-15718                                                                            https://access.redhat.com/errata/RHSA-2019:3592
RHSA-2019:3600          gnutls-3.6.5-2.el8                             Medium          0:3.6.8-8.el8           CVE-2019-3829,CVE-2019-3836                                                               https://access.redhat.com/errata/RHSA-2019:3600
RHSA-2019:3624          libseccomp-2.3.3-3.el8                         Medium          0:2.4.1-1.el8           CVE-2019-9893                                                                             https://access.redhat.com/errata/RHSA-2019:3624
RHSA-2019:3698          libarchive-3.3.2-3.el8                         Medium          0:3.3.2-7.el8           CVE-2017-14503,CVE-2018-1000878,CVE-2018-1000877,CVE-2019-1000019,CVE-2019-1000020        https://access.redhat.com/errata/RHSA-2019:3698
RHSA-2019:3701          curl-7.61.1-8.el8                              Medium          0:7.61.1-11.el8         CVE-2018-20483,CVE-2019-3822,CVE-2019-3823,CVE-2018-16890                                 https://access.redhat.com/errata/RHSA-2019:3701
RHSA-2019:3701          libcurl-7.61.1-8.el8                           Medium          0:7.61.1-11.el8         CVE-2018-20483,CVE-2019-3822,CVE-2019-3823,CVE-2018-16890                                 https://access.redhat.com/errata/RHSA-2019:3701
RHSA-2019:3706          lua-libs-5.3.4-10.el8                          Medium          0:5.3.4-11.el8          CVE-2019-6706                                                                             https://access.redhat.com/errata/RHSA-2019:3706
RHSA-2019:3707          dbus-1.12.8-7.el8                              Medium          1:1.12.8-9.el8          CVE-2019-12749                                                                            https://access.redhat.com/errata/RHSA-2019:3707
RHSA-2019:3707          dbus-common-1.12.8-7.el8                       Medium          1:1.12.8-9.el8          CVE-2019-12749                                                                            https://access.redhat.com/errata/RHSA-2019:3707
RHSA-2019:3707          dbus-daemon-1.12.8-7.el8                       Medium          1:1.12.8-9.el8          CVE-2019-12749                                                                            https://access.redhat.com/errata/RHSA-2019:3707
RHSA-2019:3707          dbus-libs-1.12.8-7.el8                         Medium          1:1.12.8-9.el8          CVE-2019-12749                                                                            https://access.redhat.com/errata/RHSA-2019:3707
RHSA-2019:3707          dbus-tools-1.12.8-7.el8                        Medium          1:1.12.8-9.el8          CVE-2019-12749                                                                            https://access.redhat.com/errata/RHSA-2019:3707

@krishnadurai
Copy link
Contributor Author

/assign @swiftdiaries @jlewi @nrchakradhar

This is ready for review.

/hold cancel

@krishnadurai krishnadurai changed the title [WIP] Distroless image for TF operator Distroless image for TF operator Jan 7, 2020

ADD . /go/src/github.com/kubeflow/tf-operator

WORKDIR /go/src/github.com/kubeflow/tf-operator

RUN go build -o tf-operator.v1 ./cmd/tf-operator.v1

FROM registry.access.redhat.com/ubi8/ubi:latest
FROM gcr.io/distroless/base-debian10
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jlewi This is a good point.
The sizes are:
base: 60301780
base-debian10: 62581637

I observed that the CVE counts with base image are a little higher: 16 Low priority

anchore-cli image vuln docker.io/krishnadurai/distless-tfop:base all
Vulnerability ID        Package                          Severity          Fix         CVE Refs                Vulnerability URL
CVE-2007-6755           libssl1.1-1.1.0l-1~deb9u1        Negligible        None        CVE-2007-6755           https://security-tracker.debian.org/tracker/CVE-2007-6755
CVE-2007-6755           openssl-1.1.0l-1~deb9u1          Negligible        None        CVE-2007-6755           https://security-tracker.debian.org/tracker/CVE-2007-6755
CVE-2010-0928           libssl1.1-1.1.0l-1~deb9u1        Negligible        None        CVE-2010-0928           https://security-tracker.debian.org/tracker/CVE-2010-0928
CVE-2010-0928           openssl-1.1.0l-1~deb9u1          Negligible        None        CVE-2010-0928           https://security-tracker.debian.org/tracker/CVE-2010-0928
CVE-2010-4051           libc6-2.24-11+deb9u4             Negligible        None        CVE-2010-4051           https://security-tracker.debian.org/tracker/CVE-2010-4051
CVE-2010-4052           libc6-2.24-11+deb9u4             Negligible        None        CVE-2010-4052           https://security-tracker.debian.org/tracker/CVE-2010-4052
CVE-2010-4756           libc6-2.24-11+deb9u4             Negligible        None        CVE-2010-4756           https://security-tracker.debian.org/tracker/CVE-2010-4756
CVE-2015-8985           libc6-2.24-11+deb9u4             Negligible        None        CVE-2015-8985           https://security-tracker.debian.org/tracker/CVE-2015-8985
CVE-2018-20796          libc6-2.24-11+deb9u4             Negligible        None        CVE-2018-20796          https://security-tracker.debian.org/tracker/CVE-2018-20796
CVE-2019-1010022        libc6-2.24-11+deb9u4             Negligible        None        CVE-2019-1010022        https://security-tracker.debian.org/tracker/CVE-2019-1010022
CVE-2019-1010023        libc6-2.24-11+deb9u4             Negligible        None        CVE-2019-1010023        https://security-tracker.debian.org/tracker/CVE-2019-1010023
CVE-2019-1010024        libc6-2.24-11+deb9u4             Negligible        None        CVE-2019-1010024        https://security-tracker.debian.org/tracker/CVE-2019-1010024
CVE-2019-1010025        libc6-2.24-11+deb9u4             Negligible        None        CVE-2019-1010025        https://security-tracker.debian.org/tracker/CVE-2019-1010025
CVE-2019-6488           libc6-2.24-11+deb9u4             Negligible        None        CVE-2019-6488           https://security-tracker.debian.org/tracker/CVE-2019-6488
CVE-2019-7309           libc6-2.24-11+deb9u4             Negligible        None        CVE-2019-7309           https://security-tracker.debian.org/tracker/CVE-2019-7309
CVE-2019-9192           libc6-2.24-11+deb9u4             Negligible        None        CVE-2019-9192           https://security-tracker.debian.org/tracker/CVE-2019-9192

Should we stick to a lower CVE count rather than opting for lesser size?

Copy link
Member

Choose a reason for hiding this comment

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

@jlewi Do you have other questions about it?

Copy link
Contributor

Choose a reason for hiding this comment

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

Looking at the guidance here:
https://github.com/GoogleContainerTools/distroless/tree/master/base

Unless we need glibc, libssl, or openssl we should be able to use the static image.

The "-debian" suffix is explained here.
https://github.com/GoogleContainerTools/distroless#base-operating-system

So IIUC it looks like base = "base-debian9" which likely has more CVE's then "debian10" probably because it is newer.

So I think we want to use "static-debian10" ?

I checked and it looks like the static images are an order of magnitude smaller than the non static images.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jlewi it seems the go binary which we are using requires C runtime for imports like 'net' packages.

If we build and run on 'static-debian10' we run into this problem:

standard_init_linux.go:211: exec user process caused "no such file or directory"

Since go starts looking for C runtime packages which we are building against.

Copy link
Member

Choose a reason for hiding this comment

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

I think you need to build with CGO_ENABLED=0.
Could you try this?
CGO_ENABLED=0 GOOS=linux go build -o tf-operator.v1 -ldflags "-w" -a ./cmd/tf-operator.v1

@krishnadurai krishnadurai requested a review from jlewi January 8, 2020 02:23
@krishnadurai krishnadurai force-pushed the feature/distroless-image branch from f5de369 to 60d4fed Compare January 9, 2020 00:14
@krishnadurai
Copy link
Contributor Author

/retest

TF operator packed in distroless container
tf_smoke.py removed
@krishnadurai krishnadurai force-pushed the feature/distroless-image branch from 60d4fed to 10392b6 Compare January 9, 2020 20:18
@TravisBuddy
Copy link

Hey @krishnadurai,
Your changes look good to me!

View build log

TravisBuddy Request Identifier: ab1dda70-331d-11ea-afd1-237c04ec133e

@krishnadurai
Copy link
Contributor Author

/assign @richardsliu

@TravisBuddy
Copy link

Hey @krishnadurai,
Your changes look good to me!

View build log

TravisBuddy Request Identifier: 4cb22440-331e-11ea-afd1-237c04ec133e

@krishnadurai
Copy link
Contributor Author

@jlewi @richardsliu could you PTAL?

Copy link
Member

@johnugeorge johnugeorge left a comment

Choose a reason for hiding this comment

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

/lgtm
/assign @gaocegege

@gaocegege
Copy link
Member

/lgtm But I am not sure if @jlewi has questions.

Thanks for your contribution! 🎉 👍

Copy link
Contributor Author

@krishnadurai krishnadurai left a comment

Choose a reason for hiding this comment

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

@jlewi I've addressed your comments.

Thanks @gaocegege and @johnugeorge!


ADD . /go/src/github.com/kubeflow/tf-operator

WORKDIR /go/src/github.com/kubeflow/tf-operator

RUN go build -o tf-operator.v1 ./cmd/tf-operator.v1

FROM registry.access.redhat.com/ubi8/ubi:latest
FROM gcr.io/distroless/base-debian10
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jlewi it seems the go binary which we are using requires C runtime for imports like 'net' packages.

If we build and run on 'static-debian10' we run into this problem:

standard_init_linux.go:211: exec user process caused "no such file or directory"

Since go starts looking for C runtime packages which we are building against.

@jlewi
Copy link
Contributor

jlewi commented Jan 17, 2020

Thanks @krishnadurai

/lgtm
/approve

@krishnadurai
Copy link
Contributor Author

/hold cancel

@krishnadurai
Copy link
Contributor Author

@gaocegege you may have to approve it?

@johnugeorge
Copy link
Member

/approve

@k8s-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jlewi, johnugeorge

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@johnugeorge
Copy link
Member

/retest

2 similar comments
@johnugeorge
Copy link
Member

/retest

@johnugeorge
Copy link
Member

/retest

@jlewi
Copy link
Contributor

jlewi commented Jan 18, 2020

/test all

@johnugeorge
Copy link
Member

/retest

@k8s-ci-robot k8s-ci-robot merged commit 9238906 into kubeflow:master Jan 18, 2020
@krishnadurai
Copy link
Contributor Author

Thanks @jlewi and @johnugeorge!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants