Skip to content

Commit ff1c3a0

Browse files
authored
Support reporting webhook services to Otterize cloud, for supporting auto-allow traffic to webhook services in cloud shadow mode (#303)
1 parent 24ee0ad commit ff1c3a0

17 files changed

+1070
-18
lines changed

helm-charts

Submodule helm-charts updated 76 files

src/mapper/cmd/main.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"github.com/otterize/network-mapper/src/mapper/pkg/metrics_collection_traffic"
2727
"github.com/otterize/network-mapper/src/mapper/pkg/networkpolicyreport"
2828
"github.com/otterize/network-mapper/src/mapper/pkg/resourcevisibility"
29+
"github.com/otterize/network-mapper/src/mapper/pkg/webhook_traffic"
2930
"github.com/otterize/network-mapper/src/shared/echologrus"
3031
"golang.org/x/sync/errgroup"
3132
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
@@ -258,6 +259,12 @@ func main() {
258259
logrus.WithError(err).Panic("unable to create endpoints reconciler")
259260
}
260261

262+
webhookServicesHandler := webhook_traffic.NewWebhookServicesHandler(mgr.GetClient(), cloudClient, kubeFinder)
263+
webhookTrafficReconcilerManager := webhook_traffic.NewWebhookTrafficReconcilerManager(mgr.GetClient(), webhookServicesHandler)
264+
if err = webhookTrafficReconcilerManager.SetupWithManager(mgr); err != nil {
265+
logrus.WithError(err).Panic("unable to create validating webhooks reconciler")
266+
}
267+
261268
netpolReconciler := networkpolicyreport.NewNetworkPolicyReconciler(mgr.GetClient(), cloudClient)
262269
if err := netpolReconciler.SetupWithManager(mgr); err != nil {
263270
logrus.WithError(err).Panic("unable to create network policy reconciler")

src/mapper/pkg/cloudclient/cloud_client.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ type CloudClient interface {
2121
ReportK8sResourceEligibleForMetricsCollection(ctx context.Context, namespace string, reason EligibleForMetricsCollectionReason, resources []K8sResourceEligibleForMetricsCollectionInput) error
2222
ReportNetworkPolicies(ctx context.Context, namespace string, policies []NetworkPolicyInput) error
2323
ReportCiliumClusterWideNetworkPolicies(ctx context.Context, policies []NetworkPolicyInput) error
24+
ReportK8sWebhookServices(ctx context.Context, services []K8sWebhookServiceInput) error
2425
}
2526

2627
type CloudClientImpl struct {
@@ -202,3 +203,14 @@ func (c *CloudClientImpl) ReportCiliumClusterWideNetworkPolicies(
202203

203204
return nil
204205
}
206+
207+
func (c *CloudClientImpl) ReportK8sWebhookServices(ctx context.Context, services []K8sWebhookServiceInput) error {
208+
logrus.Infof("Reporting webhook services")
209+
210+
_, err := ReportK8sWebhookServices(ctx, c.client, services)
211+
if err != nil {
212+
return errors.Wrap(err)
213+
}
214+
215+
return nil
216+
}

src/mapper/pkg/cloudclient/generated.go

Lines changed: 74 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/mapper/pkg/cloudclient/genqlient.graphql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,8 @@ mutation ReportNetworkPolicies($namespace: String!, $networkPolicies: [NetworkPo
4747

4848
mutation ReportCiliumClusterWideNetworkPolicies($networkPolicies: [NetworkPolicyInput!]!) {
4949
reportNetworkPolicies(networkPolicies: $networkPolicies)
50+
}
51+
52+
mutation ReportK8sWebhookServices($services: [K8sWebhookServiceInput!]!) {
53+
reportK8sWebhookServices(services: $services)
5054
}

src/mapper/pkg/cloudclient/mocks/mocks.go

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)