Skip to content

Commit 23d5465

Browse files
authored
[Framework] implement ingress operator (#75)
### **Description** Full description in the LLD that linked to this Jira - https://iguazio.atlassian.net/browse/NUC-498 This PR introduces a new IngressWatcher component that uses Kubernetes informers to watch for Ingress resource changes and updates an internal IngressHostCache accordingly. The watcher handles add, update, and delete events, extracts relevant data (host, path, target list), and reflects those changes in the in-memory cache. ### **Affected Areas** - `pkg/kube/ingress.go` – new file with the IngressWatcher implementation - Uses `IngressHostCache` from `pkg/ingresscache` - Integrates with `k8s.io/client-go` for informers ### **Testing** - Unit tests coverage for all event handler paths (add, update, delete) correctly modify the ingress cache. - Unit tests validates cache sync behavior and logging of edge cases (e.g., missing host/path). - Integrations tests are out of scope for this PR, will be introduced as part of the code changes in `Nuclio` ### **Changes Made** - Added `IngressWatcher` struct to manage and respond to Kubernetes Ingress resource changes. - Implemented handlers for Add, Update, and Delete events. - Extracted ingress data: host, path, targets via helper methods. - Registered shared informer factory with label selector support. ### **Additional notes** - Assumes each Ingress contains exactly one rule and one path. - Includes detailed error logging for resilience and observability. - Additional PR for integrating the ingress cache and ingress watcher is needed
1 parent 5b0d9bc commit 23d5465

File tree

4 files changed

+949
-9
lines changed

4 files changed

+949
-9
lines changed

go.mod

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ module github.com/v3io/scaler
33
go 1.23.8
44

55
require (
6+
github.com/dghubble/trie v0.1.0
67
github.com/nuclio/errors v0.0.4
78
github.com/nuclio/logger v0.0.1
89
github.com/nuclio/zap v0.3.1
910
github.com/stretchr/testify v1.10.0
11+
k8s.io/api v0.29.8
1012
k8s.io/apimachinery v0.29.8
1113
k8s.io/client-go v0.29.8
1214
k8s.io/metrics v0.29.8
@@ -15,27 +17,29 @@ require (
1517
require (
1618
github.com/davecgh/go-spew v1.1.1 // indirect
1719
github.com/emicklei/go-restful/v3 v3.12.2 // indirect
20+
github.com/evanphx/json-patch v4.12.0+incompatible // indirect
1821
github.com/go-logr/logr v1.4.3 // indirect
1922
github.com/go-openapi/jsonpointer v0.21.1 // indirect
2023
github.com/go-openapi/jsonreference v0.21.0 // indirect
2124
github.com/go-openapi/swag v0.23.1 // indirect
2225
github.com/gogo/protobuf v1.3.2 // indirect
2326
github.com/golang/protobuf v1.5.4 // indirect
2427
github.com/google/gnostic-models v0.6.9 // indirect
28+
github.com/google/go-cmp v0.6.0 // indirect
2529
github.com/google/gofuzz v1.2.0 // indirect
2630
github.com/google/uuid v1.6.0 // indirect
27-
github.com/imdario/mergo v0.3.7 // indirect
31+
github.com/imdario/mergo v0.3.13 // indirect
2832
github.com/josharian/intern v1.0.0 // indirect
2933
github.com/json-iterator/go v1.1.12 // indirect
3034
github.com/logrusorgru/aurora/v4 v4.0.0 // indirect
3135
github.com/mailru/easyjson v0.9.0 // indirect
3236
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
3337
github.com/modern-go/reflect2 v1.0.2 // indirect
3438
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
39+
github.com/pkg/errors v0.9.1 // indirect
3540
github.com/pmezard/go-difflib v1.0.0 // indirect
3641
github.com/spf13/pflag v1.0.6 // indirect
3742
github.com/stretchr/objx v0.5.2 // indirect
38-
github.com/dghubble/trie v0.1.0 // indirect
3943
go.uber.org/multierr v1.11.0 // indirect
4044
go.uber.org/zap v1.27.0 // indirect
4145
golang.org/x/net v0.41.0 // indirect
@@ -47,7 +51,6 @@ require (
4751
google.golang.org/protobuf v1.36.6 // indirect
4852
gopkg.in/inf.v0 v0.9.1 // indirect
4953
gopkg.in/yaml.v3 v3.0.1 // indirect
50-
k8s.io/api v0.29.8 // indirect
5154
k8s.io/klog/v2 v2.130.1 // indirect
5255
k8s.io/kube-openapi v0.0.0-20250318190949-c8a335a9a2ff // indirect
5356
k8s.io/utils v0.0.0-20250604170112-4c0f3b243397 // indirect

go.sum

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
22
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
33
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
4-
github.com/emicklei/go-restful/v3 v3.12.2 h1:DhwDP0vY3k8ZzE0RunuJy8GhNpPL6zqLkDf9B/a0/xU=
5-
github.com/emicklei/go-restful/v3 v3.12.2/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc=
64
github.com/dghubble/trie v0.1.0 h1:kJnjBLFFElBwS60N4tkPvnLhnpcDxbBjIulgI8CpNGM=
75
github.com/dghubble/trie v0.1.0/go.mod h1:sOmnzfBNH7H92ow2292dDFWNsVQuh/izuD7otCYb1ak=
6+
github.com/emicklei/go-restful/v3 v3.12.2 h1:DhwDP0vY3k8ZzE0RunuJy8GhNpPL6zqLkDf9B/a0/xU=
7+
github.com/emicklei/go-restful/v3 v3.12.2/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc=
88
github.com/evanphx/json-patch v4.12.0+incompatible h1:4onqiflcdA9EOZ4RxV643DvftH5pOlLGNtQ5lPWQu84=
99
github.com/evanphx/json-patch v4.12.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
1010
github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=
@@ -34,8 +34,8 @@ github.com/google/pprof v0.0.0-20240727154555-813a5fbdbec8 h1:FKHo8hFI3A+7w0aUQu
3434
github.com/google/pprof v0.0.0-20240727154555-813a5fbdbec8/go.mod h1:K1liHPHnj73Fdn/EKuT8nrFqBihUSKXoLYU0BuatOYo=
3535
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
3636
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
37-
github.com/imdario/mergo v0.3.7 h1:Y+UAYTZ7gDEuOfhxKWy+dvb5dRQ6rJjFSdX2HZY1/gI=
38-
github.com/imdario/mergo v0.3.7/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
37+
github.com/imdario/mergo v0.3.13 h1:lFzP57bqS/wsqKssCGmtLAb8A0wKjLGrve2q3PPVcBk=
38+
github.com/imdario/mergo v0.3.13/go.mod h1:4lJ1jqUDcsbIECGy0RUJAXNIhg+6ocWgb1ALK2O4oXg=
3939
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
4040
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
4141
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
@@ -135,8 +135,7 @@ gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntN
135135
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
136136
gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc=
137137
gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
138-
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
139-
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
138+
gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
140139
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
141140
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
142141
k8s.io/api v0.29.8 h1:ZBKg9clWnIGtQ5yGhNwMw2zyyrsIAQaXhZACcYNflQE=

0 commit comments

Comments
 (0)