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

Make aws-cni config more flexible and generalized #11816

Merged

Conversation

moshevayner
Copy link
Member

Fixes #11144
/cc @hakman

@k8s-ci-robot k8s-ci-robot requested a review from hakman June 19, 2021 14:01
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. area/addons area/api size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jun 19, 2021
@hakman hakman requested a review from rifelpet June 19, 2021 15:38
// Specifies whether ipamd should configure rp filter for primary interface.
// Setting this to false will require rp filter to be configured through init container.
AwsVpcK8sCniConfigureRpFilter string `json:"awsVpcK8sCniConfigureRpFilter,omitempty"`
Env []EnvVar `json:"env,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

Should not remove the documentation comment

@@ -248,12 +248,19 @@ type RomanaNetworkingSpec struct {

// AmazonVPCNetworkingSpec declares that we want Amazon VPC CNI networking
type AmazonVPCNetworkingSpec struct {
// Specifies whether ipamd should configure rp filter for primary interface.
Copy link
Member

Choose a reason for hiding this comment

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

Doc comment needs to start with the name of the field.

// Setting this to false will require rp filter to be configured through init container.
AwsVpcK8sCniConfigureRpFilter string `json:"awsVpcK8sCniConfigureRpFilter,omitempty"`
Env []EnvVar `json:"env,omitempty"`
// If ENABLE_POD_ENI is set to true, in order for the kubelet to connect via TCP (for liveness or readiness probes) to pods that are using per pod security groups,
Copy link
Member

Choose a reason for hiding this comment

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

Doc comment needs to start with the name of the field.

@moshevayner
Copy link
Member Author

Thanks for the review, @johngmyers !
I've addressed all your comments, please have a look when you get a chance and let me know if you had any other concerns 😄 🙏🏻

InitImageName string `json:"initImageName,omitempty"`
// AwsVpcK8sCniConfigureRpFilter specifies whether ipamd should configure rp filter for primary interface.
// Setting this to false will require rp filter to be configured through init container.
AwsVpcK8sCniConfigureRpFilter string `json:"awsVpcK8sCniConfigureRpFilter,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

All of this refers to the AWS VPC CNI, so that part of the name is redundant.

"RP" is an acronym for "Reverse Path".

The possible values are "true" and "false", so it's a boolean.

Suggested change
AwsVpcK8sCniConfigureRpFilter string `json:"awsVpcK8sCniConfigureRpFilter,omitempty"`
ConfigureRPFilter *bool `json:"configureRPFilter,omitempty"`

// The init container image name to use
InitImageName string `json:"initImageName,omitempty"`
// AwsVpcK8sCniConfigureRpFilter specifies whether ipamd should configure rp filter for primary interface.
// Setting this to false will require rp filter to be configured through init container.
Copy link
Member

Choose a reason for hiding this comment

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

Should mention the default is true.

// in order for the kubelet to connect via TCP (for liveness or readiness probes) to pods that are using per pod security groups.
// This will increase the local TCP connection latency slightly.
// To use this setting, a Linux kernel version of at least 4.6 is needed on the worker node.
DisableTCPEarlyDemux string `json:"disableTCPEarlyDemux,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

Also a boolean.

We try to avoid negative booleans.

Suggested change
DisableTCPEarlyDemux string `json:"disableTCPEarlyDemux,omitempty"`
TCPEarlyDemux *bool `json:"enableTCPEarlyDemux,omitempty"`

pkg/apis/kops/networking.go Show resolved Hide resolved
pkg/apis/kops/networking.go Show resolved Hide resolved
upup/pkg/fi/cloudup/template_functions.go Show resolved Hide resolved
Copy link
Member

@hakman hakman left a comment

Choose a reason for hiding this comment

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

I still think that initializing the Env vars with the options kOps overrides by default in template functions is better and also allows users to change those too in a generic way, without adding extra options.

pkg/apis/kops/networking.go Show resolved Hide resolved
pkg/apis/kops/networking.go Show resolved Hide resolved
@moshevayner
Copy link
Member Author

I still think that initializing the Env vars with the options kOps overrides by default in template functions is better and also allows users to change those too in a generic way, without adding extra options.

So I did that with everything else, however it seems like these two are actually different from the default values according to the docs, so I needed to make an override on them. Is there a better way to handle that, than the one I used?

@moshevayner
Copy link
Member Author

/retest

@moshevayner moshevayner force-pushed the fix-11144-aws-cni-config branch 3 times, most recently from 6ffaba3 to dd26563 Compare June 21, 2021 21:56
@hakman
Copy link
Member

hakman commented Jun 22, 2021

Hey @MoShitrit, sorry for the delay, but was traveling for the past few days. Will take another look at this today.

@hakman
Copy link
Member

hakman commented Jun 22, 2021

I would add a template function like this:

	if cluster.Spec.Networking != nil && cluster.Spec.Networking.AmazonVPC != nil {
		c := cluster.Spec.Networking.AmazonVPC
		dest["AmazonVpcEnvVars"] = func() map[string]string {
			envVars := map[string]string{
				"AWS_VPC_K8S_CNI_CONFIGURE_RPFILTER": "false",
			}
			for _, e := range c.Env {
				envVars[e.Name] = e.Value
			}
			return envVars
		}
	}

and change the template to use it instead of directly accessing the env vars:

        {{- range $name, $value := AmazonVpcEnvVars }}
        - "name": "{{ $name }}"
          "value": "{{ $value }}"
        {{- end }}

This way we can change the defaults, but still allow overwriting them.

Copy link
Member

@hakman hakman left a comment

Choose a reason for hiding this comment

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

These are just some remaining nits, otherwise looks good from my point of view. Maybe also squash the commits.
@rifelpet Want to take a look too?

…mplate functions for ease of customization

Update auto-generated files
@moshevayner moshevayner requested a review from hakman June 22, 2021 09:30
@rifelpet
Copy link
Member

/lgtm

Will let @hakman do the final approval

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 22, 2021
Copy link
Member

@hakman hakman left a comment

Choose a reason for hiding this comment

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

Thanks @MoShitrit!

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hakman

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 added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 23, 2021
@moshevayner
Copy link
Member Author

/retest

1 similar comment
@moshevayner
Copy link
Member Author

/retest

@k8s-ci-robot k8s-ci-robot merged commit 82c050c into kubernetes:master Jun 23, 2021
@k8s-ci-robot k8s-ci-robot added this to the v1.22 milestone Jun 23, 2021
@moshevayner moshevayner deleted the fix-11144-aws-cni-config branch June 23, 2021 15:13
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. area/addons area/api 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/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
5 participants