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

Handle passwords #37

Merged
merged 3 commits into from
Sep 8, 2023
Merged

Handle passwords #37

merged 3 commits into from
Sep 8, 2023

Conversation

fedepaol
Copy link
Member

Handling passwords as secret references.

cmd/main.go Outdated
)

flag.StringVar(&metricsAddr, "metrics-bind-address", ":8080", "The address the metric endpoint binds to.")
flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.")
flag.StringVar(&logLevel, "log-level", "info", fmt.Sprintf("log level. must be one of: [%s]", logging.Levels.String()))
flag.StringVar(&nodeName, "node-name", "", "The node this daemon is running on.")
flag.StringVar(&namespace, "namespace", "", "The namespace this demon is deployed in")
Copy link
Member

Choose a reason for hiding this comment

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

nit: daemon

Copy link
Member

Choose a reason for hiding this comment

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

nit: I think this belongs better to the next commit

}
srcPass, ok := secret.Data["password"]
if !ok {
return "", fmt.Errorf("password not specified in the secret %q/%q", secret.Namespace, secret.Name)
Copy link
Member

Choose a reason for hiding this comment

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

nit: password -> password field?

}

for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
frr, err := apiToFRR(test.fromK8s)
frr, err := apiToFRR(test.fromK8s, test.secrets)
if test.err != nil && err == nil {
Copy link
Member

Choose a reason for hiding this comment

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

unrelated question: should we start comparing test.err and err when != nil?

Copy link
Member Author

Choose a reason for hiding this comment

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

either that or just "expect err" as bool. Let me do that in a separate commit

Copy link
Member

Choose a reason for hiding this comment

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

is there a reason we don't add a Watches for secrets?

Copy link
Member Author

Choose a reason for hiding this comment

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

oops. Adding a test too

Copy link
Member

Choose a reason for hiding this comment

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

does it make sense to append this to the existing role.yaml instead of a different file?

Copy link
Member Author

Choose a reason for hiding this comment

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

nope, because the current role is generated by kubebuilder and gets overridden. And given the controller is mixed (mostly cluster scoped, secrets namespace scoped) kubebuilder generates a cluster role (which we don't want, as we don't want the controller to receive and read all the secrets but only the local ones)

Comment on lines 12 to 13
corev1 "k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"
Copy link
Member

Choose a reason for hiding this comment

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

nit: imported twice

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@@ -40,14 +53,32 @@ func PeersForContainers(frrs []*frrcontainer.FRR, ipFam ipfamily.Family, modify
FRR: *f,
}

if f.RouterConfig.Password != "" {
Copy link
Member

Choose a reason for hiding this comment

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

neat

@oribon
Copy link
Member

oribon commented Aug 29, 2023

Also, there's the // TODO hide secrets when we have them to fix now :)

@fedepaol
Copy link
Member Author

Also, there's the // TODO hide secrets when we have them to fix now :)

done

@fedepaol fedepaol force-pushed the passwordsecrets branch 6 times, most recently from 5636a3e to bf55891 Compare August 29, 2023 12:38
corev1 "k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"
Copy link
Member

Choose a reason for hiding this comment

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

nit: imported twice


config, err := apiToFRR(cfgs, secrets)
secretNotFound := SecretNotFoundError{}
if errors.As(err, &secretNotFound) { // This might be a receiving order issue so we need to return the error and retry
Copy link
Member

Choose a reason for hiding this comment

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

is this necessary now that we listen for secret events?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'd rather be on the paranoid side. It should converge anyway

@oribon
Copy link
Member

oribon commented Sep 3, 2023

also, multiple configs for the same neighbor specifying a different password should be considered invalid?

@fedepaol
Copy link
Member Author

fedepaol commented Sep 5, 2023

also, multiple configs for the same neighbor specifying a different password should be considered invalid?

you already added the check

if n1.Password != n2.Password {

Copy link
Member

@oribon oribon left a comment

Choose a reason for hiding this comment

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

lgtm

We allow users to configure the passwords of a given bgp session using
secrets created in the frr-k8s namespace.

Signed-off-by: Federico Paolinelli <[email protected]>
@fedepaol fedepaol force-pushed the passwordsecrets branch 2 times, most recently from c89ac75 to 0012e20 Compare September 6, 2023 09:12
Include Regenerating the all-in-one manifests for secrets rbac

Signed-off-by: Federico Paolinelli <[email protected]>
Creating the secrets and configuring the neighbors so the session uses
the password. The EBGP-multihop session is left without password so we
validate it keeps working.

Signed-off-by: Federico Paolinelli <[email protected]>
@fedepaol fedepaol added this pull request to the merge queue Sep 8, 2023
Merged via the queue into metallb:main with commit 53b057d Sep 8, 2023
9 checks passed
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.

2 participants