-
Notifications
You must be signed in to change notification settings - Fork 150
Support for custom CNI file name #4382
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
base: master
Are you sure you want to change the base?
Conversation
This PR allows users to change the filename via installation manfiest.
example:
```
apiVersion: operator.tigera.io/v1
kind: Installation
metadata:
name: default
spec:
cni:
type: Calico
ipam:
type: Calico
confName: "00-calico.conflist"
```
caseydavenport
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few thoughts
| // please ensure that this field matches the same name as specified in the container runtime settings. | ||
| // Default: "10-calico.conflist" | ||
| // +optional | ||
| // +kubebuilder:validation:Type=string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should add a kubebuilder default here as well
| // +kubebuilder:validation:Type=string | |
| // +kubebuilder:validation:Type=string | |
| // +kubebuilder:default=10-calico.conflist |
|
|
||
| // ConfName is the name of the CNI config file. | ||
| // If you have changed the name of the CNI configuration file in the container runtime configuration, | ||
| // please ensure that this field matches the same name as specified in the container runtime settings. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this field needs to match anything in the container runtime settings (looks like copy/paste from the ConfDir param)
| defaultCNIConfName := "10-calico.conflist" | ||
| instance.Spec.CNI.ConfName = &defaultCNIConfName |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| defaultCNIConfName := "10-calico.conflist" | |
| instance.Spec.CNI.ConfName = &defaultCNIConfName | |
| instance.Spec.CNI.ConfName = ptr.To("10-calico.conflist") |
| } | ||
|
|
||
| if err := c.node.assertEnv(ctx, c.client, containerInstallCNI, "CNI_CONF_NAME", "10-calico.conflist"); err != nil { | ||
| if err := c.node.assertEnv(ctx, c.client, containerInstallCNI, "CNI_CONF_NAME", *install.Spec.CNI.ConfName); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of asserting the env var matches, we should get the CNI_CONF_NAME env var and update the install.Spec.CNI.ConfName field to match.
This means we can now upgrade manifest -> operator even if a custom CNI config name has been used.
|
|
||
| envVars := []corev1.EnvVar{ | ||
| {Name: "CNI_CONF_NAME", Value: "10-calico.conflist"}, | ||
| {Name: "CNI_CONF_NAME", Value: *c.cfg.Installation.CNI.ConfName}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would like to see a unit test for this field
| // Default: "10-calico.conflist" | ||
| // +optional | ||
| // +kubebuilder:validation:Type=string | ||
| ConfName *string `json:"confName,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing we are going to have to solve is what to do if this value is changed to something with less priority.
e.g., if you switch from 20-calico.conflist to 30-calico.conflist, the new configuration file will be ignored by the container runtime because the old configuration sorts higher.
We have some very rudimentary support for removing old config files here: https://github.com/projectcalico/calico/blob/master/cni-plugin/pkg/install/install.go#L413-L420
But it requires knowing the name of the file you want to remove!
Description
This PR allows users to change the filename via installation manfiest.
example:
Release Note
For PR author
make gen-filesmake gen-versionsFor PR reviewers
A note for code reviewers - all pull requests must have the following:
kind/bugif this is a bugfix.kind/enhancementif this is a a new feature.enterpriseif this PR applies to Calico Enterprise only.