diff --git a/deploy/charts/disco-agent/templates/configmap.yaml b/deploy/charts/disco-agent/templates/configmap.yaml index 231a26cd..85d7d063 100644 --- a/deploy/charts/disco-agent/templates/configmap.yaml +++ b/deploy/charts/disco-agent/templates/configmap.yaml @@ -107,3 +107,9 @@ data: resource-type: version: v1 resource: pods + - kind: k8s-dynamic + name: ark/configmaps + config: + resource-type: + version: v1 + resource: configmaps diff --git a/deploy/charts/disco-agent/tests/__snapshot__/configmap_test.yaml.snap b/deploy/charts/disco-agent/tests/__snapshot__/configmap_test.yaml.snap index 2c70df00..88a0c103 100644 --- a/deploy/charts/disco-agent/tests/__snapshot__/configmap_test.yaml.snap +++ b/deploy/charts/disco-agent/tests/__snapshot__/configmap_test.yaml.snap @@ -95,6 +95,12 @@ custom-cluster-description: resource-type: version: v1 resource: pods + - kind: k8s-dynamic + name: ark/configmaps + config: + resource-type: + version: v1 + resource: configmaps kind: ConfigMap metadata: labels: @@ -202,6 +208,12 @@ custom-cluster-name: resource-type: version: v1 resource: pods + - kind: k8s-dynamic + name: ark/configmaps + config: + resource-type: + version: v1 + resource: configmaps kind: ConfigMap metadata: labels: @@ -309,6 +321,12 @@ custom-period: resource-type: version: v1 resource: pods + - kind: k8s-dynamic + name: ark/configmaps + config: + resource-type: + version: v1 + resource: configmaps kind: ConfigMap metadata: labels: @@ -416,6 +434,12 @@ defaults: resource-type: version: v1 resource: pods + - kind: k8s-dynamic + name: ark/configmaps + config: + resource-type: + version: v1 + resource: configmaps kind: ConfigMap metadata: labels: diff --git a/examples/machinehub.yaml b/examples/machinehub.yaml index ea0b28e5..4b5f0282 100644 --- a/examples/machinehub.yaml +++ b/examples/machinehub.yaml @@ -125,3 +125,11 @@ data-gatherers: resource-type: version: v1 resource: pods + +# Gather Kubernetes configmaps +- name: ark/configmaps + kind: "k8s-dynamic" + config: + resource-type: + version: v1 + resource: configmaps \ No newline at end of file diff --git a/examples/machinehub/input.json b/examples/machinehub/input.json index 2cdba65c..244f39a9 100644 --- a/examples/machinehub/input.json +++ b/examples/machinehub/input.json @@ -118,6 +118,12 @@ "items": [] } }, + { + "data-gatherer": "ark/configmaps", + "data": { + "items": [] + } + }, { "data-gatherer": "ark/serviceaccounts", "data": { diff --git a/internal/cyberark/dataupload/dataupload.go b/internal/cyberark/dataupload/dataupload.go index b9ccb5f5..63502660 100644 --- a/internal/cyberark/dataupload/dataupload.go +++ b/internal/cyberark/dataupload/dataupload.go @@ -82,6 +82,8 @@ type Snapshot struct { Daemonsets []runtime.Object `json:"daemonsets"` // Pods is a list of Pod resources in the cluster. Pods []runtime.Object `json:"pods"` + // ConfigMaps is a list of ConfigMap resources in the cluster. + ConfigMaps []runtime.Object `json:"configmaps"` } // PutSnapshot PUTs the supplied snapshot to an [AWS presigned URL] which it obtains via the CyberArk inventory API. diff --git a/pkg/client/client_cyberark.go b/pkg/client/client_cyberark.go index c9310265..5c0e7578 100644 --- a/pkg/client/client_cyberark.go +++ b/pkg/client/client_cyberark.go @@ -186,6 +186,9 @@ var defaultExtractorFunctions = map[string]func(*api.DataReading, *dataupload.Sn "ark/pods": func(r *api.DataReading, s *dataupload.Snapshot) error { return extractResourceListFromReading(r, &s.Pods) }, + "ark/configmaps": func(r *api.DataReading, s *dataupload.Snapshot) error { + return extractResourceListFromReading(r, &s.ConfigMaps) + }, } // convertDataReadings processes a list of DataReadings using the provided diff --git a/pkg/client/client_cyberark_test.go b/pkg/client/client_cyberark_test.go index f0df5c64..75a95505 100644 --- a/pkg/client/client_cyberark_test.go +++ b/pkg/client/client_cyberark_test.go @@ -89,6 +89,7 @@ var defaultDynamicDatagathererNames = []string{ "ark/statefulsets", "ark/daemonsets", "ark/pods", + "ark/configmaps", } // fakeReadings returns a set of fake readings that includes a discovery reading diff --git a/pkg/datagatherer/k8s/dynamic.go b/pkg/datagatherer/k8s/dynamic.go index 92f10c33..244c76fc 100644 --- a/pkg/datagatherer/k8s/dynamic.go +++ b/pkg/datagatherer/k8s/dynamic.go @@ -144,6 +144,9 @@ var kubernetesNativeResources = map[schema.GroupVersionResource]sharedInformerFu corev1.SchemeGroupVersion.WithResource("pods"): func(sharedFactory informers.SharedInformerFactory) k8scache.SharedIndexInformer { return sharedFactory.Core().V1().Pods().Informer() }, + corev1.SchemeGroupVersion.WithResource("configmaps"): func(sharedFactory informers.SharedInformerFactory) k8scache.SharedIndexInformer { + return sharedFactory.Core().V1().ConfigMaps().Informer() + }, corev1.SchemeGroupVersion.WithResource("nodes"): func(sharedFactory informers.SharedInformerFactory) k8scache.SharedIndexInformer { return sharedFactory.Core().V1().Nodes().Informer() },