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

VPC-CNI minimal image builds #2146

Merged
merged 5 commits into from
Dec 7, 2022
Merged

VPC-CNI minimal image builds #2146

merged 5 commits into from
Dec 7, 2022

Conversation

jdn5126
Copy link
Contributor

@jdn5126 jdn5126 commented Nov 21, 2022

What type of PR is this?
Enhancement

Which issue does this PR fix:
N/A

What does this PR do / Why do we need it:
This pull request migrates the VPC-CNI and VPC-CNI init images to use EKS minimal build image. This PR applied the diff from #1726 and updated it to handle recent changes. It was also tested to be compatible with #2137 , but those changes were left commented out as #2137 is not yet complete.

The VPC CNI image is based on public.ecr.aws/eks-distro-build-tooling/eks-distro-minimal-base-iptables:latest.2, which installs iptables-legacy and iptables-nft, but sets iptables-legacy as the default using update-alternatives.

The VPC CNI init image is based on public.ecr.aws/eks-distro-build-tooling/eks-distro-minimal-base-glibc:latest.2. The reason I could not use the base image is that the binaries are built in pie mode for security reasons, and building with pie requires the loader to be loaded despite the binary being static.

I considered splitting this into two PRs: one to add the Golang entrypoints and one to do the move, but concluded that it is easiest to do as one PR, and if there are any issues, it is simple to just revert the move.

If an issue # is not available please add repro steps and logs from IPAMD/CNI showing the issue:
N/A

Testing done on this change:
I manually verified that all integration tests pass against this change. Output for init container:

$ kubectl logs aws-node-rg6rm -n kube-system -c aws-vpc-cni-init
time="2022-11-21T19:35:43Z" level=info msg="Copying CNI plugin binaries ..."
time="2022-11-21T19:35:43Z" level=info msg="Copied all CNI plugin binaries to /host/opt/cni/bin\n"
Installed /host/opt/cni/bin/loopback
Installed /host/opt/cni/bin/portmap
Installed /host/opt/cni/bin/bandwidth
Installed /host/opt/cni/bin/aws-cni-support.sh
time="2022-11-21T19:35:43Z" level=info msg="Found primaryMAC 0a:55:51:01:a4:d1"
time="2022-11-21T19:35:43Z" level=info msg="Found primaryIF eth0"
time="2022-11-21T19:35:43Z" level=info msg="Updated net/ipv4/conf/eth0/rp_filter to 2"
time="2022-11-21T19:35:43Z" level=info msg="Updated net/ipv4/tcp_early_demux to 1"
time="2022-11-21T19:35:43Z" level=info msg="CNI init container done"

Output for VPC-CNI:

$ kubectl logs aws-node-rg6rm -n kube-system -c aws-node
time="2022-11-21T19:35:43Z" level=info msg="Install CNI binaries.."
Installed /host/opt/cni/bin/aws-cni
time="2022-11-21T19:35:43Z" level=info msg="Starting IPAM daemon... "
time="2022-11-21T19:35:43Z" level=info msg="Checking for IPAM connectivity... "
Installed /host/opt/cni/bin/egress-v4-cni
time="2022-11-21T19:35:44Z" level=info msg="Copying config file... "
time="2022-11-21T19:35:44Z" level=info msg="Successfully copied CNI plugin binary and config file."

Automation added to e2e:
N/A

Will this PR introduce any new dependencies?:
No, it will actually reduce dependencies.

Will this break upgrades or downgrades. Has updating a running cluster been tested?:
This will not break upgrades or downgrades. Upgrade and downgrade has been tested with a running cluster.

Does this change require updates to the CNI daemonset config files to work?:
No

Does this PR introduce any user-facing change?:
The image base is different.

Move VPC CNI and VPC CNI init images to use EKS minimal base image.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@jdn5126 jdn5126 requested a review from a team as a code owner November 21, 2022 20:05
@bwagner5
Copy link
Contributor

Nice! Do you know the full image size differences?

@jdn5126
Copy link
Contributor Author

jdn5126 commented Nov 22, 2022

Nice! Do you know the full image size differences?

Comparing upstream (v1.12.0) to my personal ECR:
VPC-CNI Init: 277.24 MB -> 19.90MB
VPC-CNI: 293.37 MB -> 47.67MB

scripts/dockerfiles/Dockerfile.init Show resolved Hide resolved
scripts/dockerfiles/Dockerfile.release Show resolved Hide resolved
cmd/aws-vpc-cni-init/main.go Outdated Show resolved Hide resolved
cmd/aws-vpc-cni-init/main.go Outdated Show resolved Hide resolved
utils/sysctl/sysctl.go Outdated Show resolved Hide resolved
cmd/aws-vpc-cni/main.go Outdated Show resolved Hide resolved
cmd/aws-vpc-cni/main.go Outdated Show resolved Hide resolved
cmd/aws-vpc-cni/main.go Outdated Show resolved Hide resolved
Since init container is required to always run, let binary installation
for external plugins happen in init container. This simplifies the main
container entrypoint and the dockerfile for each image.
@bryantbiggs
Copy link
Member

awesome work @jdn5126 🎉

@jdn5126 jdn5126 merged commit 261af6c into aws:master Dec 7, 2022
@jdn5126 jdn5126 deleted the minimal_build branch December 7, 2022 20:46
jdn5126 added a commit that referenced this pull request Dec 12, 2022
* create publisher with logger (#2119)

* Add missing rules when NodePort support is disabled (#2026)

* Add missing rules when NodePort support is disabled

* the rules that need to be installed for NodePort support and SNAT
  support are very similar. The same traffic mark is needed for both. As
  a result, rules that are currently installed only when NodePort
  support is enabled should also be installed when external SNAT is
  disabled, which is the case by default.
* remove "-m state --state NEW" from a rule in the nat table. This is
  always true for packets that traverse the nat table.
* fix typo in one rule's name (extra whitespace).

Fixes #2025

Co-authored-by: Quan Tian <qtian@vmware.com>

Signed-off-by: Antonin Bas <abas@vmware.com>

* Fix typos and unit tests

Signed-off-by: Antonin Bas <abas@vmware.com>

* Minor improvement to code comment

Signed-off-by: Antonin Bas <abas@vmware.com>

* Address review comments

* Delete legacy nat rule
* Fix an unrelated log message

Signed-off-by: Antonin Bas <abas@vmware.com>

Signed-off-by: Antonin Bas <abas@vmware.com>
Co-authored-by: Jayanth Varavani <1111446+jayanthvn@users.noreply.github.com>
Co-authored-by: Sushmitha Ravikumar <58063229+sushrk@users.noreply.github.com>

* downgrade test go.mod to align with root go.mod (#2128)

* skip addon installation when addon info is not available (#2131)

* Merging test/Makefile and test/go.mod to the root Makefil and go.mod, adjust the .github/workflows and integration test instructions (#2129)

* update troubleshooting docs for CNI image (#2132)

fix location where make command is run

* fix env name in test script (#2136)

* optionally allow CLUSTER_ENDPOINT to be used rather than the cluster-ip (#2138)

* optionally allow CLUSTER_ENDPOINT to be used rather than the kubernetes cluster ip

* remove check for kube-proxy

* add version to readme

* Add resources config option to cni metrics helper (#2141)

* Add resources config option to cni metrics helper

* Remove default-empty resources block; replace with conditional

* Add metrics for ec2 api calls made by CNI and expose via prometheus (#2142)

Co-authored-by: Jay Deokar <jsdeokar@amazon.com>

* increase workflow role duration to 4 hours (#2148)

* Update golang 1.19.2 EKS-D (#2147)

* Update golang

* Move to EKS distro builds

* [HELM]: Move CRD resources to a separate folder as per helm standard (#2144)

Co-authored-by: Jay Deokar <jsdeokar@amazon.com>

* VPC-CNI minimal image builds (#2146)

* VPC-CNI minimal image builds

* update dependencies for ginkgo when running integration tests

* address review comments and break up init main function

* review comments for sysctl

* Simplify binary installation, fix review comments

Since init container is required to always run, let binary installation
for external plugins happen in init container. This simplifies the main
container entrypoint and the dockerfile for each image.

* when IPAMD connection fails, try to teardown pod network using prevResult (#2145)

* add env var to enable nftables (#2155)

* fix failing weekly cron tests (#2154)

* Deprecate AWS_VPC_K8S_CNI_CONFIGURE_RPFILTER and remove no-op setter (#2153)

* Deprecate AWS_VPC_K8S_CNI_CONFIGURE_RPFILTER

* update release version comments

Signed-off-by: Antonin Bas <abas@vmware.com>
Co-authored-by: Jeffrey Nelson <jdnelson@amazon.com>
Co-authored-by: Antonin Bas <antonin.bas@gmail.com>
Co-authored-by: Jayanth Varavani <1111446+jayanthvn@users.noreply.github.com>
Co-authored-by: Sushmitha Ravikumar <58063229+sushrk@users.noreply.github.com>
Co-authored-by: Jerry He <37866862+jerryhe1999@users.noreply.github.com>
Co-authored-by: Brandon Wagner <wagnerbm@amazon.com>
Co-authored-by: Jonathan Ogilvie <679297+jcogilvie@users.noreply.github.com>
Co-authored-by: Jay Deokar <jsdeokar@amazon.com>
haouc pushed a commit to haouc/amazon-vpc-cni-k8s that referenced this pull request Dec 13, 2022
* VPC-CNI minimal image builds

* update dependencies for ginkgo when running integration tests

* address review comments and break up init main function

* review comments for sysctl

* Simplify binary installation, fix review comments

Since init container is required to always run, let binary installation
for external plugins happen in init container. This simplifies the main
container entrypoint and the dockerfile for each image.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants