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

Add an ingress uid label to tunnels #293

Merged
merged 1 commit into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions helm/ingress-controller/Chart.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
dependencies:
- name: common
repository: https://charts.bitnami.com/bitnami
version: 2.6.0
digest: sha256:6657a16696e9c132a98eb257951876f491f213b55aac7b4894993d260b2bae09
generated: "2023-07-13T14:02:39.574375-04:00"
version: 2.8.0
digest: sha256:83dc5879aedee09c5d5d1865ed9e861feeeea6df10e56c41787911b54e141af9
generated: "2023-08-18T09:47:25.793815648-04:00"
2 changes: 1 addition & 1 deletion internal/controllers/base_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func (r *baseController[T]) reconcile(ctx context.Context, req ctrl.Request, cr
}
} else {
if hasFinalizer(cr) {
if r.statusID == nil || r.statusID(cr) != "" {
if r.statusID != nil && r.statusID(cr) != "" {
sid := r.statusID(cr)
r.Recorder.Event(cr, v1.EventTypeNormal, "Deleting", fmt.Sprintf("Deleting %s: %s", r.kubeType, crName))
if err := r.delete(ctx, cr); err != nil {
Expand Down
14 changes: 8 additions & 6 deletions internal/store/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const (
labelControllerName = "k8s.ngrok.com/controller-name"
labelDomain = "k8s.ngrok.com/domain"
labelNamespace = "k8s.ngrok.com/namespace"
labelIngressUid = "k8s.ngrok.com/ingress-uid"
labelService = "k8s.ngrok.com/service"
labelPort = "k8s.ngrok.com/port"
)
Expand Down Expand Up @@ -452,7 +453,7 @@ func (d *Driver) calculateHTTPSEdges() map[string]ingressv1alpha1.HTTPSEdge {
Match: httpIngressPath.Path,
MatchType: matchType,
Backend: ingressv1alpha1.TunnelGroupBackend{
Labels: d.ngrokLabels(ingress.Namespace, serviceName, servicePort),
Labels: d.ngrokLabels(ingress, serviceName, servicePort),
},
CircuitBreaker: modSet.Modules.CircuitBreaker,
Compression: modSet.Modules.Compression,
Expand Down Expand Up @@ -519,7 +520,7 @@ func (d *Driver) calculateTunnels() map[tunnelKey]ingressv1alpha1.Tunnel {
},
Spec: ingressv1alpha1.TunnelSpec{
ForwardsTo: targetAddr,
Labels: d.ngrokLabels(ingress.Namespace, serviceName, servicePort),
Labels: d.ngrokLabels(ingress, serviceName, servicePort),
BackendConfig: &ingressv1alpha1.BackendConfig{
Protocol: protocol,
},
Expand Down Expand Up @@ -651,10 +652,11 @@ func (d *Driver) tunnelLabels(serviceName string, port int32) map[string]string
}

// Generates a labels map for matching ngrok Routes to Agent Tunnels
func (d *Driver) ngrokLabels(namespace, serviceName string, port int32) map[string]string {
func (d *Driver) ngrokLabels(ingress *netv1.Ingress, serviceName string, port int32) map[string]string {
return map[string]string{
labelNamespace: namespace,
labelService: serviceName,
labelPort: strconv.Itoa(int(port)),
labelNamespace: ingress.Namespace,
labelIngressUid: string(ingress.UID),
labelService: serviceName,
labelPort: strconv.Itoa(int(port)),
}
}