Documentation ¶
Index ¶
- Constants
- Variables
- func FakeClusterRole(name string) *rbacv1.ClusterRole
- func FakeClusterRoleBinding(name string) *rbacv1.ClusterRoleBinding
- func FakeEndpoint(name string, namespace string, ports []int32) *discoveryv1.EndpointSlice
- func FakeNode(name string, providerID string) *corev1.Node
- func FakePod(namespace string, name string, status string) *corev1.Pod
- func FakePort(name string, port int32) *discoveryv1.EndpointPort
- func FakeRole(namespace string, name string) *rbacv1.Role
- func FakeRoleBinding(namespace, name string) *rbacv1.RoleBinding
- type ClusterRoleBindingIngestor
- type ClusterRoleIngestor
- type CollectorClient
- func ClientFactory(ctx context.Context, cfg *config.KubehoundConfig) (CollectorClient, error)
- func NewFileCollector(ctx context.Context, cfg *config.KubehoundConfig) (CollectorClient, error)
- func NewK8sAPICollector(ctx context.Context, cfg *config.KubehoundConfig) (CollectorClient, error)
- func NewTestK8sAPICollector(ctx context.Context, clientset *fake.Clientset) CollectorClient
- type EndpointIngestor
- type FileCollector
- func (c *FileCollector) Close(_ context.Context) error
- func (c *FileCollector) ClusterInfo(ctx context.Context) (*config.ClusterInfo, error)
- func (c *FileCollector) ComputeMetadata(ctx context.Context, ingestor MetadataIngestor) error
- func (c *FileCollector) HealthCheck(_ context.Context) (bool, error)
- func (c *FileCollector) Name() string
- func (c *FileCollector) StreamClusterRoleBindings(ctx context.Context, ingestor ClusterRoleBindingIngestor) error
- func (c *FileCollector) StreamClusterRoles(ctx context.Context, ingestor ClusterRoleIngestor) error
- func (c *FileCollector) StreamEndpoints(ctx context.Context, ingestor EndpointIngestor) error
- func (c *FileCollector) StreamNodes(ctx context.Context, ingestor NodeIngestor) error
- func (c *FileCollector) StreamPods(ctx context.Context, ingestor PodIngestor) error
- func (c *FileCollector) StreamRoleBindings(ctx context.Context, ingestor RoleBindingIngestor) error
- func (c *FileCollector) StreamRoles(ctx context.Context, ingestor RoleIngestor) error
- type GenericIngestor
- type Metadata
- type MetadataIngestor
- type Metrics
- type NodeIngestor
- type PodIngestor
- type RoleBindingIngestor
- type RoleIngestor
Constants ¶
const ( NodePath = "nodes.json" EndpointPath = "endpointslices.discovery.k8s.io.json" ClusterRolesPath = "clusterroles.rbac.authorization.k8s.io.json" ClusterRoleBindingsPath = "clusterrolebindings.rbac.authorization.k8s.io.json" PodPath = "pods.json" RolesPath = "roles.rbac.authorization.k8s.io.json" RoleBindingsPath = "rolebindings.rbac.authorization.k8s.io.json" MetadataPath = "metadata.json" )
Expect a file structure of the following |____<namespace> | |____rolebindings.rbac.authorization.k8s.io.json | |____pods.json | |____endpointslices.discovery.k8s.io.json | |____roles.rbac.authorization.k8s.io.json |____<namespace> | |____rolebindings.rbac.authorization.k8s.io.json | |____pods.json | |____endpointslices.discovery.k8s.io.json | |____roles.rbac.authorization.k8s.io.json |____nodes.json |____clusterroles.rbac.authorization.k8s.io.json |____clusterrolebindings.rbac.authorization.k8s.io.json
const (
FileCollectorName = "local-file-collector"
)
const (
K8sAPICollectorName = "k8s-api-collector"
)
Variables ¶
var (
CollectorUserAgent = fmt.Sprintf("KubeHound-Collector-v%s", config.BuildVersion)
)
Functions ¶
func FakeClusterRole ¶ added in v1.3.1
func FakeClusterRole(name string) *rbacv1.ClusterRole
func FakeClusterRoleBinding ¶ added in v1.3.1
func FakeClusterRoleBinding(name string) *rbacv1.ClusterRoleBinding
func FakeEndpoint ¶ added in v1.3.1
func FakeEndpoint(name string, namespace string, ports []int32) *discoveryv1.EndpointSlice
func FakePort ¶ added in v1.3.1
func FakePort(name string, port int32) *discoveryv1.EndpointPort
func FakeRoleBinding ¶ added in v1.3.1
func FakeRoleBinding(namespace, name string) *rbacv1.RoleBinding
Types ¶
type ClusterRoleBindingIngestor ¶
type ClusterRoleBindingIngestor interface { IngestClusterRoleBinding(context.Context, types.ClusterRoleBindingType) error Complete(context.Context) error }
ClusterRoleBindingIngestor defines the interface to allow an ingestor to consume cluster role binding inputs from a collector.
type ClusterRoleIngestor ¶
type ClusterRoleIngestor interface { IngestClusterRole(context.Context, types.ClusterRoleType) error Complete(context.Context) error }
ClusterRoleIngestor defines the interface to allow an ingestor to consume cluster role inputs from a collector.
type CollectorClient ¶
type CollectorClient interface { services.Dependency // ClusterInfo returns the target cluster information for the current run. ClusterInfo(ctx context.Context) (*config.ClusterInfo, error) // Compute the metrics and gather all the metadata and dump it through the ingestor.DumpMetadata ComputeMetadata(ctx context.Context, ingestor MetadataIngestor) error // StreamNodes will iterate through all NodeType objects collected by the collector and invoke the ingestor.IngestNode method on each. // Once all the NodeType objects have been exhausted the ingestor.Complete method will be invoked to signal the end of the stream. StreamNodes(ctx context.Context, ingestor NodeIngestor) error // StreamPods will iterate through all PodType objects collected by the collector and invoke the ingestor.IngestPod method on each. // Once all the PodType objects have been exhausted the ingestor.Complete method will be invoked to signal the end of the stream. StreamPods(ctx context.Context, ingestor PodIngestor) error // StreamRoles will iterate through all RoleType objects collected by the collector and invoke ingestor.IngestRole method on each. // Once all the RoleType objects have been exhausted the ingestor.Complete method will be invoked to signal the end of the stream. StreamRoles(ctx context.Context, ingestor RoleIngestor) error // StreamClusterRoles will iterate through all ClusterRoleType objects collected by the collector and invoke the ingestor.IngestRole method on each. // Once all the ClusterRoleType objects have been exhausted the ingestor.Complete method will be invoked to signal the end of the stream. StreamClusterRoles(ctx context.Context, ingestor ClusterRoleIngestor) error // StreamRoleBindings will iterate through all RoleBindingType objects collected by the collector and invoke the ingestor.IngestRoleBinding method on each. // Once all the RoleBindingType objects have been exhausted the ingestor.Complete method will be invoked to signal the end of the stream. StreamRoleBindings(ctx context.Context, ingestor RoleBindingIngestor) error // StreamClusterRoleBindings will iterate through all ClusterRoleBindingType objects collected by the collector and invoke the ingestor.ClusterRoleBinding method on each. // Once all the ClusterRoleBindingType objects have been exhausted the ingestor.Complete method will be invoked to signal the end of the stream. StreamClusterRoleBindings(ctx context.Context, ingestor ClusterRoleBindingIngestor) error // StreamEndpoints will iterate through all EndpointType objects collected by the collector and invoke the ingestor.IngestEndpoint method on each. // Once all the EndpointType objects have been exhausted the ingestor.Complete method will be invoked to signal the end of the stream. StreamEndpoints(ctx context.Context, ingestor EndpointIngestor) error // Close cleans up any resources used by the collector client implementation. Client cannot be reused after this call. Close(ctx context.Context) error }
func ClientFactory ¶
func ClientFactory(ctx context.Context, cfg *config.KubehoundConfig) (CollectorClient, error)
ClientFactory creates an initialized instance of a collector client based on the provided application configuration.
func NewFileCollector ¶
func NewFileCollector(ctx context.Context, cfg *config.KubehoundConfig) (CollectorClient, error)
NewFileCollector creates a new instance of the file collector from the provided application config.
func NewK8sAPICollector ¶
func NewK8sAPICollector(ctx context.Context, cfg *config.KubehoundConfig) (CollectorClient, error)
NewK8sAPICollector creates a new instance of the k8s live API collector from the provided application config.
func NewTestK8sAPICollector ¶ added in v1.3.1
func NewTestK8sAPICollector(ctx context.Context, clientset *fake.Clientset) CollectorClient
type EndpointIngestor ¶
type EndpointIngestor interface { IngestEndpoint(context.Context, types.EndpointType) error Complete(context.Context) error }
EndpointIngestor defines the interface to allow an ingestor to consume endpoint slice inputs from a collector.
type FileCollector ¶
type FileCollector struct {
// contains filtered or unexported fields
}
FileCollector implements a collector based on local K8s API json files generated outside the KubeHound application via e.g kubectl.
func (*FileCollector) ClusterInfo ¶ added in v1.2.0
func (c *FileCollector) ClusterInfo(ctx context.Context) (*config.ClusterInfo, error)
func (*FileCollector) ComputeMetadata ¶ added in v1.5.0
func (c *FileCollector) ComputeMetadata(ctx context.Context, ingestor MetadataIngestor) error
This function has no meaning in the file collector as it should already have all the metadata gathered in the dumped files.
func (*FileCollector) HealthCheck ¶
func (c *FileCollector) HealthCheck(_ context.Context) (bool, error)
func (*FileCollector) Name ¶
func (c *FileCollector) Name() string
func (*FileCollector) StreamClusterRoleBindings ¶
func (c *FileCollector) StreamClusterRoleBindings(ctx context.Context, ingestor ClusterRoleBindingIngestor) error
func (*FileCollector) StreamClusterRoles ¶
func (c *FileCollector) StreamClusterRoles(ctx context.Context, ingestor ClusterRoleIngestor) error
func (*FileCollector) StreamEndpoints ¶
func (c *FileCollector) StreamEndpoints(ctx context.Context, ingestor EndpointIngestor) error
func (*FileCollector) StreamNodes ¶
func (c *FileCollector) StreamNodes(ctx context.Context, ingestor NodeIngestor) error
func (*FileCollector) StreamPods ¶
func (c *FileCollector) StreamPods(ctx context.Context, ingestor PodIngestor) error
func (*FileCollector) StreamRoleBindings ¶
func (c *FileCollector) StreamRoleBindings(ctx context.Context, ingestor RoleBindingIngestor) error
func (*FileCollector) StreamRoles ¶
func (c *FileCollector) StreamRoles(ctx context.Context, ingestor RoleIngestor) error
type GenericIngestor ¶ added in v1.3.1
type GenericIngestor interface { NodeIngestor PodIngestor RoleIngestor ClusterRoleIngestor RoleBindingIngestor ClusterRoleBindingIngestor EndpointIngestor }
Generic interface to allow an ingestor to consume stream inputs from a collector.
type MetadataIngestor ¶ added in v1.5.0
MetadataIngestor defines the interface to allow an ingestor to computed metrics and metadata from a collector.
type NodeIngestor ¶
type NodeIngestor interface { IngestNode(context.Context, types.NodeType) error Complete(context.Context) error }
NodeIngestor defines the interface to allow an ingestor to consume node inputs from a collector.
type PodIngestor ¶
type PodIngestor interface { IngestPod(context.Context, types.PodType) error Complete(context.Context) error }
PodIngestor defines the interface to allow an ingestor to consume pod inputs from a collector.
type RoleBindingIngestor ¶
type RoleBindingIngestor interface { IngestRoleBinding(context.Context, types.RoleBindingType) error Complete(context.Context) error }
RoleBindingIngestor defines the interface to allow an ingestor to consume role binding inputs from a collector.