Skip to content

Conversation

@rbtr
Copy link
Collaborator

@rbtr rbtr commented Jan 12, 2022

Signed-off-by: Evan Baker rbtr@users.noreply.github.

Reason for Change:

Issue Fixed:

Requirements:

Notes:

@rbtr rbtr force-pushed the cns/fix/init-from-pods branch from 53cc280 to e42a739 Compare January 14, 2022 18:13
@rbtr rbtr self-assigned this Jan 14, 2022
}
}()

clientset, err := kubernetes.NewForConfig(kubeConfig)
Copy link
Member

Choose a reason for hiding this comment

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

I still suggest to move this logic inside initCNS. It is more contained there as part of CNS initialization workflow.

Copy link
Member

Choose a reason for hiding this comment

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

podInfoByProvider is kind of an internal state which we are passing to InitCNS func.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

moving the clientset/the rest of this initialization into the initCNS breaks IOC - we should provide that func all of the objects it needs as inputs. passing it ready-to-use implementations of the interfaces it needs is the better pattern

@rbtr rbtr force-pushed the cns/fix/init-from-pods branch from f415b48 to 62b2b34 Compare January 21, 2022 22:08
} else {
logger.Printf("Initializing from Kubernetes")
podInfoByIPProvider = cns.PodInfoByIPProviderFunc(func() (map[string]cns.PodInfo, error) {
pods, err := clientset.CoreV1().Pods("").List(ctx, metav1.ListOptions{ //nolint:govet // ignore err shadow
Copy link
Member

Choose a reason for hiding this comment

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

I think I'm okay with the contents of this pr, but I do want to mention that hostnetworking pods on windows do require a hacky kubeconfig to be constructed externally and loaded via file as opposed to using an inclusterconfig, if running in hostnw on windows becomes a thing

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

good to know, we would need to update how we source the kubeconfigs in a couple of places for that

rbtr added 2 commits January 29, 2022 01:47
Signed-off-by: Evan Baker <rbtr@users.noreply.github.
Signed-off-by: Evan Baker <rbtr@users.noreply.github.com>
@rbtr rbtr force-pushed the cns/fix/init-from-pods branch from 62b2b34 to 673a4ee Compare January 29, 2022 01:49
@rbtr rbtr merged commit 427a1e4 into Azure:master Jan 31, 2022
@rbtr rbtr deleted the cns/fix/init-from-pods branch January 31, 2022 22:57
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.

3 participants