Skip to content

use minimal base docker image #2196

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

Merged
merged 1 commit into from
Aug 26, 2021

Conversation

M00nF1sh
Copy link
Collaborator

@M00nF1sh M00nF1sh commented Aug 26, 2021

Issue

Description

Use a minimal base image for AWSLoadBalancerController docker image.
The minimal base image contains minimal packages and don't have no shells, which reduce attack surface and help us avoid noises reported by image scanners.

Notes to reviewer:

  1. -linkmode=external -extldflags '-static-pie' is added to provide a static-pie, our prior builds produces a dynamically-linked binary post golang 1.15.
  2. -tags 'osusergo,netgo,static_build' instructs the golang to use the go version of os/user and net packages instead of CGO.
  3. cross-compile don't work when CGO enabled, switched to use --platform=${TARGETPLATFORM} instead of --platform=${BUILDPLATFORM}, which is required to provide multi-arch binaries in OSX. Our internal pipeline is not affected given different arch building separately in different OS.
  4. updated to use latest go1.16 to be consistent with our go.mod

Checklist

  • Added tests that cover your change (if possible)
  • Added/modified documentation as required (such as the README.md, or the docs directory)
  • Manually tested
  • Made sure the title of the PR is a good description that can go into the release notes

BONUS POINTS checklist: complete for good vibes and maybe prizes?! 🤯

  • Backfilled missing tests for code in same general area 🎉
  • Refactored something and made the world a better place 🌟

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Aug 26, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: M00nF1sh

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

@k8s-ci-robot k8s-ci-robot requested a review from kishorj August 26, 2021 18:18
@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 26, 2021
@@ -1,6 +1,6 @@
# syntax=docker/dockerfile:experimental

FROM --platform=${BUILDPLATFORM} golang:1.16.3 AS base
FROM --platform=${TARGETPLATFORM} golang:1.16 AS base
Copy link
Collaborator

Choose a reason for hiding this comment

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

why is the change in the golang version?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

to be consistent with our go.mod.
this will make sure we are using latest golang 1.16 series for new builds


COPY --from=build /out/controller /controller
USER 1002
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this included in the base image?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@kishorj kishorj added the tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. label Aug 26, 2021
@codecov-commenter
Copy link

Codecov Report

Merging #2196 (9f74828) into main (a789f51) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #2196   +/-   ##
=======================================
  Coverage   52.29%   52.29%           
=======================================
  Files         132      132           
  Lines        7234     7234           
=======================================
  Hits         3783     3783           
  Misses       3157     3157           
  Partials      294      294           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a789f51...9f74828. Read the comment docs.

@kishorj
Copy link
Collaborator

kishorj commented Aug 26, 2021

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 26, 2021
@k8s-ci-robot k8s-ci-robot merged commit 4055b97 into kubernetes-sigs:main Aug 26, 2021
Timothy-Dougherty pushed a commit to adammw/aws-load-balancer-controller that referenced this pull request Nov 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants