Skip to content
This repository has been archived by the owner on Apr 17, 2019. It is now read-only.

ingress: nginx controller watches referenced tls secrets #1063

Conversation

simonswine
Copy link
Contributor

This enables the controller to reload certificates on changes in the secrets.

We are maintaining a list of referenced certificates in secrMetadata to only reload/sync the controller when something in referenced certificates changes.

@simonswine
Copy link
Contributor Author

simonswine commented May 25, 2016

@alanhartless @aledbf

fixes #800 #1054

for _, tls := range ing.Spec.TLS {
secretName := tls.SecretName
secrMetadata[fmt.Sprintf("%s/%s", ing.Namespace, secretName)] = true
secret, err := lbc.client.Secrets(ing.Namespace).Get(secretName)
Copy link
Contributor

Choose a reason for hiding this comment

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

@simonswine can you change this to use secrLister instead of api.Client?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@aledbf thanks for that hint, now using the secrLister

@simonswine simonswine force-pushed the feature-nginx-ingress-watch-secrets branch from aba8c84 to a7101cd Compare May 25, 2016 14:03
@simonswine simonswine force-pushed the feature-nginx-ingress-watch-secrets branch from a7101cd to fc63f57 Compare May 27, 2016 09:29
@aledbf
Copy link
Contributor

aledbf commented May 31, 2016

LGTM

@@ -797,9 +860,24 @@ func (lbc *loadBalancerController) getPemsFromIngress(data []interface{}) map[st
}
}

lbc.secrMetadataLock.Lock()

Choose a reason for hiding this comment

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

do we really need to maintain this map/locks or can we just relist all ingresses on secret update and break on first name match ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bprashanth I had the feeling that this would be too expensive, but I can modify the code accordingly

Choose a reason for hiding this comment

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

I'm fine if you think it's required. I usually try to avoid locking unless I absolutely need to. If you just need a locked map, suggest using cache.Store (or cache.ThreadSafeStore as the need may be:https://github.com/kubernetes/kubernetes/blob/master/pkg/client/cache/thread_safe_store.go).

@simonswine simonswine force-pushed the feature-nginx-ingress-watch-secrets branch from fc63f57 to 9b9c7da Compare June 3, 2016 16:41
@bprashanth
Copy link

I see you already modified it per my last comment, @simonswine thanks! LGTM, will merge on green

@simonswine
Copy link
Contributor Author

@bprashanth, seems like it has happened in the same minute :)

@bprashanth bprashanth merged commit a828b5f into kubernetes-retired:master Jun 3, 2016
@bprashanth
Copy link

Merged, but no new image. If you need this in an image please send a pr with the version bump and I can push it out.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants