Skip to content

Commit b2dcdb5

Browse files
authored
Enhance cloud app network insights and visibility by reporting the ip addresses of workloads (#294)
1 parent 5581349 commit b2dcdb5

20 files changed

+939
-632
lines changed

src/mapper/cmd/main.go

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
"github.com/otterize/network-mapper/src/mapper/pkg/externaltrafficholder"
2323
"github.com/otterize/network-mapper/src/mapper/pkg/gcpintentsholder"
2424
"github.com/otterize/network-mapper/src/mapper/pkg/incomingtrafficholder"
25-
"github.com/otterize/network-mapper/src/mapper/pkg/labelreporter"
25+
"github.com/otterize/network-mapper/src/mapper/pkg/metadatareporter"
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"
@@ -237,14 +237,8 @@ func main() {
237237
logrus.WithError(err).Panic("unable to create service reconciler")
238238
}
239239

240-
podReconciler := labelreporter.NewPodReconciler(mgr.GetClient(), cloudClient, serviceIdResolver)
241-
if err := podReconciler.SetupWithManager(mgr); err != nil {
242-
logrus.WithError(err).Panic("unable to create pod reconciler")
243-
}
244-
245-
namespaceReconciler := labelreporter.NewNamespaceReconciler(mgr.GetClient(), cloudClient)
246-
if err := namespaceReconciler.SetupWithManager(mgr); err != nil {
247-
logrus.WithError(err).Panic("unable to create namespace reconciler")
240+
if err := metadatareporter.Setup(mgr.GetClient(), cloudClient, serviceIdResolver, mgr); err != nil {
241+
logrus.WithError(err).Panic("unable to create metadata reporter")
248242
}
249243

250244
metricsCollectionTrafficHandler := metrics_collection_traffic.NewMetricsCollectionTrafficHandler(mgr.GetClient(), serviceidresolver.NewResolver(mgr.GetClient()), cloudClient)

src/mapper/pkg/cloudclient/cloud_client.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ type CloudClient interface {
1717
ReportK8sIngresses(ctx context.Context, namespace string, ingresses []K8sIngressInput) error
1818
ReportTrafficLevels(ctx context.Context, trafficLevels []TrafficLevelInput) error
1919
ReportNamespaceLabels(ctx context.Context, namespace string, labels []LabelInput) error
20-
ReportWorkloadsLabels(ctx context.Context, workloadsLabels []ReportServiceMetadataInput) error
20+
ReportWorkloadsMetadata(ctx context.Context, workloadsLabels []ReportServiceMetadataInput) error
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
@@ -148,13 +148,13 @@ func (c *CloudClientImpl) ReportNamespaceLabels(ctx context.Context, namespace s
148148
return nil
149149
}
150150

151-
func (c *CloudClientImpl) ReportWorkloadsLabels(ctx context.Context, workloadsLabels []ReportServiceMetadataInput) error {
151+
func (c *CloudClientImpl) ReportWorkloadsMetadata(ctx context.Context, workloadsMetadata []ReportServiceMetadataInput) error {
152152
logrus.Debugf("Uploading workloads labels to cloud")
153153

154-
_, err := ReportWorkloadsLabels(
154+
_, err := ReportWorkloadsMetadata(
155155
ctx,
156156
c.client,
157-
workloadsLabels,
157+
workloadsMetadata,
158158
)
159159
if err != nil {
160160
return errors.Wrap(err)

src/mapper/pkg/cloudclient/generated.go

Lines changed: 32 additions & 20 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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ mutation ReportNamespaceLabels($name: String!, $labels: [LabelInput!]!) {
3737
reportNamespaceLabels(name: $name, labels: $labels)
3838
}
3939

40-
mutation ReportWorkloadsLabels($workloadsLabels: [ReportServiceMetadataInput!]!) {
40+
mutation ReportWorkloadsMetadata($workloadsLabels: [ReportServiceMetadataInput!]!) {
4141
reportServicesMetadata(servicesMeta: $workloadsLabels)
4242
}
4343

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

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

src/mapper/pkg/cloudclient/schema.graphql

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -845,6 +845,7 @@ input ExternalTrafficIntentInput {
845845
clientName: String!
846846
target: DNSIPPairInput!
847847
connectionsCount: ConnectionsCount
848+
ttl: Time
848849
}
849850

850851
input ExternallyAccessibleServiceInput {
@@ -2149,6 +2150,7 @@ type Mutation {
21492150
namespace: String
21502151
networkPolicies: [NetworkPolicyInput!]
21512152
): Boolean!
2153+
computeNetworkPoliciesForOrg: Boolean!
21522154
"""Create a new organization"""
21532155
createOrganization(
21542156
name: String
@@ -2208,6 +2210,9 @@ type Mutation {
22082210
userEmail: String!
22092211
feedback: String!
22102212
): Boolean!
2213+
saveOrgMemberships(
2214+
memberships: [UserOrgMembershipInput!]!
2215+
): Boolean!
22112216
createOrActivateTutorial(
22122217
tutorialName: TutorialName!
22132218
): Boolean!
@@ -2335,13 +2340,21 @@ type Organization {
23352340
type OrganizationMembership {
23362341
role: AuthRole!
23372342
restrictions: OrganizationMembershipRestrictions
2343+
restrictionResources: OrganizationMembershipRestrictionResources
23382344
}
23392345

23402346
input OrganizationMembershipInput {
23412347
role: AuthRole!
23422348
restrictions: OrganizationMembershipRestrictionsInput
23432349
}
23442350

2351+
type OrganizationMembershipRestrictionResources {
2352+
clusters: [Cluster!]!
2353+
services: [Service!]!
2354+
namespaces: [Namespace!]!
2355+
environments: [Environment!]!
2356+
}
2357+
23452358
type OrganizationMembershipRestrictions {
23462359
clusterIds: IDFilterValue
23472360
serviceIds: IDFilterValue
@@ -2630,6 +2643,8 @@ type Query {
26302643
): TerraformResourceInfo!
26312644
"""List users"""
26322645
users: [User!]!
2646+
"""List users with restriction resources"""
2647+
orgUsersWithRestrictionResources: UsersWithRestrictionResources!
26332648
orgUsers: [UserOrganizationAssociation!]!
26342649
"""Get user"""
26352650
user(
@@ -2902,6 +2917,8 @@ input ServiceMetadataInput {
29022917
tags: [String!]
29032918
awsRoles: [String!]
29042919
labels: [LabelInput!]
2920+
podIps: [String!]
2921+
serviceIps: [String!]
29052922
}
29062923

29072924
enum ServiceType {
@@ -3141,6 +3158,11 @@ enum UserErrorType {
31413158
TIMEOUT
31423159
}
31433160

3161+
input UserOrgMembershipInput {
3162+
userId: ID!
3163+
membership: OrganizationMembershipInput!
3164+
}
3165+
31443166
type UserOrganizationAssociation {
31453167
org: Organization!
31463168
user: User!
@@ -3159,6 +3181,11 @@ type UserTutorial {
31593181
stepSeen: String!
31603182
}
31613183

3184+
type UsersWithRestrictionResources {
3185+
orgUsers: [UserOrganizationAssociation!]!
3186+
restrictionResources: OrganizationMembershipRestrictionResources
3187+
}
3188+
31623189
""" Used to validate ID based filters """
31633190
type ValidIDFilter {
31643191
clusterIds: IDFilterValue

src/mapper/pkg/labelreporter/pod_labels_cache.go

Lines changed: 0 additions & 54 deletions
This file was deleted.

0 commit comments

Comments
 (0)