Skip to content

Commit

Permalink
feat: target enrichment k8s nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
ansgarschulte committed Dec 11, 2023
1 parent 5f50bc6 commit 0570ff9
Showing 1 changed file with 52 additions and 3 deletions.
55 changes: 52 additions & 3 deletions extvm/vm_discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ func (d *vmDiscovery) DescribeEnrichmentRules() []discovery_kit_api.TargetEnrich
return []discovery_kit_api.TargetEnrichmentRule{
getToHostEnrichmentRule(),
getToContainerEnrichmentRule(),
getToKubernetesNodeEnrichmentRule(),
}
}

Expand Down Expand Up @@ -364,9 +365,53 @@ func getToHostEnrichmentRule() discovery_kit_api.TargetEnrichmentRule {
Matcher: discovery_kit_api.StartsWith,
Name: "gcp-kubernetes-engine.",
},
{
Matcher: discovery_kit_api.Equals,
Name: "gcp.zone",
},
{
Matcher: discovery_kit_api.Equals,
Name: "gcp.project.id",
},
},
}
}
func getToKubernetesNodeEnrichmentRule() discovery_kit_api.TargetEnrichmentRule {
return discovery_kit_api.TargetEnrichmentRule{
Id: "com.steadybit.extension_gcp.gcp-vm-to-k8s-node",
Version: extbuild.GetSemverVersionStringOrUnknown(),
Src: discovery_kit_api.SourceOrDestination{
Type: TargetIDVM,
Selector: map[string]string{
"gcp-vm.hostname": "${dest.host.hostname}",
},
},
Dest: discovery_kit_api.SourceOrDestination{
Type: "com.steadybit.extension_kubernetes.kubernetes-node",
Selector: map[string]string{
"host.hostname": "${src.gcp-vm.hostname}",
},
},
Attributes: []discovery_kit_api.Attribute{
{
Matcher: discovery_kit_api.StartsWith,
Name: "gcp-vm.label.",
},
{
Matcher: discovery_kit_api.StartsWith,
Name: "gcp-vm.",
},
{
Matcher: discovery_kit_api.StartsWith,
Name: "gcp.",
Name: "gcp-kubernetes-engine.",
},
{
Matcher: discovery_kit_api.Equals,
Name: "gcp.zone",
},
{
Matcher: discovery_kit_api.Equals,
Name: "gcp.project.id",
},
},
}
Expand Down Expand Up @@ -403,8 +448,12 @@ func getToContainerEnrichmentRule() discovery_kit_api.TargetEnrichmentRule {
Name: "gcp-kubernetes-engine.",
},
{
Matcher: discovery_kit_api.StartsWith,
Name: "gcp.",
Matcher: discovery_kit_api.Equals,
Name: "gcp.zone",
},
{
Matcher: discovery_kit_api.Equals,
Name: "gcp.project.id",
},
},
}
Expand Down

0 comments on commit 0570ff9

Please sign in to comment.