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

Leaked Kubernetes resources when a service-name / service-hostname changes #4

Closed
mthaddon opened this issue Sep 2, 2022 · 2 comments · Fixed by #50
Closed

Leaked Kubernetes resources when a service-name / service-hostname changes #4

mthaddon opened this issue Sep 2, 2022 · 2 comments · Fixed by #50

Comments

@mthaddon
Copy link
Contributor

mthaddon commented Sep 2, 2022

The nginx-ingress-integrator charm creates Kubernetes resources (Services and Ingress Resources) based on the configured service-name and service-hostname.

However, if the charm is then configured with a different service-name and service-hostname, the previous resources are not removed. This happens everytime the configuration options change since the Resource names are based on the aforementioned service-name / service-hostname.

This can also happen for the service-names and service-hostnames received from relation data (+ additional-hostnames for Ingress Resources). This issue occurs on previous revisions as well.

Because the Kubernetes resource names are based on service-name / service-hostname, cleaning them up is not immediately straight-forward since the charm would have to store the previous values and compare them to the current ones.

@weiiwang01
Copy link
Contributor

Juju adds this label app.juju.is/created-by=<app-name> to all the k8s resources that ingress integrator charm created. That label can be used to select and remove unused resources.

$ microk8s kubectl describe service -n test-relation-0r1c any-service
Name:              any-service
Namespace:         test-relation-0r1c
Labels:            app.juju.is/created-by=ingress
Annotations:       <none>
Selector:          app.kubernetes.io/name=any
Type:              ClusterIP
IP Family Policy:  SingleStack
IP Families:       IPv4
IP:                10.152.183.176
IPs:               10.152.183.176
Port:              tcp-18080  18080/TCP
TargetPort:        18080/TCP
Endpoints:         10.1.75.154:18080
Port:              tcp-8080  8080/TCP
TargetPort:        8080/TCP
Endpoints:         10.1.75.154:8080
Session Affinity:  None
Events:            <none>

@mthaddon
Copy link
Contributor Author

As long as we're looking for the entire app.juju.is/created-by=$app-name string this should be fine, but note that you may have multiple ingress applications deployed in a single model and we'd need to be careful to make sure we don't remove ingresses defined by an application named ingress-extra-cool application if we're deployed as an application named ingress.

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 a pull request may close this issue.

2 participants