Skip to content

Add cluster context to config resource to allow multi-cluster setup#66

Merged
linki merged 4 commits intomasterfrom
cluster-context
Feb 12, 2026
Merged

Add cluster context to config resource to allow multi-cluster setup#66
linki merged 4 commits intomasterfrom
cluster-context

Conversation

@linki
Copy link
Copy Markdown
Collaborator

@linki linki commented Feb 9, 2026

Attempt to implement https://github.com/zalando-build/cloud-platform/issues/7743#issuecomment-3843594776

Since it's using the plain struct as the key to the map, just adding another field holding the cluster should create two entries if the same egress config is used in two different clusters:

configsCache map[provider.Resource]map[string]*net.IPNet

This way removing one config in one cluster will leave another entry in the cache which will lead to the rule not being deleted from the CF stack prematurely.

The Cluster field can be anything that identifies the cluster. Previously I used the cluster alias but I figured that using the master URL is just as fine and we can keep the CLI semantic unchanged (i.e. it's backwards compatible).

@linki linki removed the do-not-merge label Feb 9, 2026
Comment thread kube/configmap.go Outdated
log.Errorf("Failed to get ConfigMap object")
return
}
func (c *ConfigMapWatcher) add(cluster string) func(obj interface{}) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

without knowing much about the code base and spending some time checking it, why are we now returning a func?

Copy link
Copy Markdown
Collaborator Author

@linki linki Feb 11, 2026

Choose a reason for hiding this comment

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

add was used as the event handler directly further above. Since I needed to customize it, I generate the function dynamically via this function now. I could rename it to addFuncFactory or something like that if that's more clear.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

it was mainly to learn here and understand what I'm approving 😄
I think your suggestion to rename the function make it easier to understand, I would rename the 3 functions to mention it's a factory.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I changed it to use a separate struct for the event handler (parameterized by the cluster) so the functions are less obscure. How about this?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

looks good

Comment thread main.go
clients := map[string]kubernetes.Interface{}
for _, master := range cfg.Masters {
clients = append(clients, newKubeClient(cfg, master, kubeconfig))
clients[master] = newKubeClient(cfg, master, kubeconfig)
Copy link
Copy Markdown

@tcondeixa tcondeixa Feb 10, 2026

Choose a reason for hiding this comment

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

what exactly is master? is it the URL for the API?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yes, plain URL for the master endpoint, like https://kube-1...

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

would not be better we call it apiServerURL or something similar?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Sure, but that's existing code (including the --master) flag. I don't really want to change that here.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

ok, let's keep it

@linki linki merged commit 06bf1e1 into master Feb 12, 2026
2 checks passed
@linki linki deleted the cluster-context branch February 12, 2026 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants