Documentation ¶
Overview ¶
Package k8s provides datagatherers for different parts of the Kubernetes API.
Index ¶
- Variables
- func NewClientSet(kubeconfigPath string) (kubernetes.Interface, error)
- func NewDiscoveryClient(kubeconfigPath string) (discovery.DiscoveryClient, error)
- func NewDynamicClient(kubeconfigPath string) (dynamic.Interface, error)
- func Redact(fields []string, resource *unstructured.Unstructured) error
- func Select(fields []string, resource *unstructured.Unstructured) error
- type ConfigDiscovery
- type ConfigDynamic
- type DataGathererDiscovery
- type DataGathererDynamic
Constants ¶
This section is empty.
Variables ¶
var RedactFields = []string{
"metadata.managedFields",
"/metadata/annotations/kubectl.kubernetes.io~1last-applied-configuration",
}
RedactFields are removed from all objects
var RouteSelectedFields = []string{
"kind",
"apiVersion",
"metadata.annotations",
"metadata.name",
"metadata.namespace",
"metadata.ownerReferences",
"metadata.selfLink",
"metadata.uid",
"spec.host",
"spec.to.kind",
"spec.to.port",
"spec.to.name",
"spec.to.weight",
"spec.tls.termination",
"spec.tls.certificate",
"spec.tls.caCertificate",
"spec.tls.destinationCACertificate",
"spec.tls.insecureEdgeTerminationPolicy",
"spec.wildcardPolicy",
"status",
}
RouteSelectedFields is the list of fields sent from OpenShift Route objects to the backend
var SecretSelectedFields = []string{
"kind",
"apiVersion",
"metadata.annotations",
"metadata.name",
"metadata.namespace",
"metadata.ownerReferences",
"metadata.selfLink",
"metadata.uid",
"type",
"/data/tls.crt",
"/data/ca.crt",
}
SecretSelectedFields is the list of fields sent from Secret objects to the backend
Functions ¶
func NewClientSet ¶ added in v0.1.37
func NewClientSet(kubeconfigPath string) (kubernetes.Interface, error)
NewClientSet creates a new kubernetes clientset using the provided kubeconfig. If kubeconfigPath is not set/empty, it will attempt to load configuration using the default loading rules.
func NewDiscoveryClient ¶ added in v0.1.17
func NewDiscoveryClient(kubeconfigPath string) (discovery.DiscoveryClient, error)
NewDiscoveryClient creates a new 'discovery' client using the provided kubeconfig. If kubeconfigPath is not set/empty, it will attempt to load configuration using the default loading rules.
func NewDynamicClient ¶
NewDynamicClient creates a new 'dynamic' clientset using the provided kubeconfig. If kubeconfigPath is not set/empty, it will attempt to load configuration using the default loading rules.
func Redact ¶ added in v0.1.23
func Redact(fields []string, resource *unstructured.Unstructured) error
Redact removes the supplied fields from the resource
func Select ¶ added in v0.1.23
func Select(fields []string, resource *unstructured.Unstructured) error
Select removes all but the supplied fields from the resource
Types ¶
type ConfigDiscovery ¶ added in v0.1.17
type ConfigDiscovery struct { // KubeConfigPath is the path to the kubeconfig file. If empty, will assume it runs in-cluster. KubeConfigPath string `yaml:"kubeconfig"` }
ConfigDiscovery contains the configuration for the k8s-discovery data-gatherer
func (*ConfigDiscovery) NewDataGatherer ¶ added in v0.1.17
func (c *ConfigDiscovery) NewDataGatherer(ctx context.Context) (datagatherer.DataGatherer, error)
NewDataGatherer constructs a new instance of the generic K8s data-gatherer for the provided GroupVersionResource.
func (*ConfigDiscovery) UnmarshalYAML ¶ added in v0.1.17
func (c *ConfigDiscovery) UnmarshalYAML(unmarshal func(interface{}) error) error
UnmarshalYAML unmarshals the Config resolving GroupVersionResource.
type ConfigDynamic ¶ added in v0.1.17
type ConfigDynamic struct { // KubeConfigPath is the path to the kubeconfig file. If empty, will assume it runs in-cluster. KubeConfigPath string `yaml:"kubeconfig"` // GroupVersionResource identifies the resource type to gather. GroupVersionResource schema.GroupVersionResource // ExcludeNamespaces is a list of namespaces to exclude. ExcludeNamespaces []string `yaml:"exclude-namespaces"` // IncludeNamespaces is a list of namespaces to include. IncludeNamespaces []string `yaml:"include-namespaces"` // FieldSelectors is a list of field selectors to use when listing this resource FieldSelectors []string `yaml:"field-selectors"` }
ConfigDynamic contains the configuration for the data-gatherer.
func (*ConfigDynamic) NewDataGatherer ¶ added in v0.1.17
func (c *ConfigDynamic) NewDataGatherer(ctx context.Context) (datagatherer.DataGatherer, error)
NewDataGatherer constructs a new instance of the generic K8s data-gatherer for the provided
func (*ConfigDynamic) UnmarshalYAML ¶ added in v0.1.17
func (c *ConfigDynamic) UnmarshalYAML(unmarshal func(interface{}) error) error
UnmarshalYAML unmarshals the ConfigDynamic resolving GroupVersionResource.
type DataGathererDiscovery ¶ added in v0.1.17
type DataGathererDiscovery struct {
// contains filtered or unexported fields
}
DataGathererDiscovery stores the config for a k8s-discovery datagatherer
func (*DataGathererDiscovery) Delete ¶ added in v0.1.29
func (g *DataGathererDiscovery) Delete() error
func (*DataGathererDiscovery) Fetch ¶ added in v0.1.17
func (g *DataGathererDiscovery) Fetch() (interface{}, int, error)
Fetch will fetch discovery data from the apiserver, or return an error
func (*DataGathererDiscovery) Run ¶ added in v0.1.29
func (g *DataGathererDiscovery) Run(stopCh <-chan struct{}) error
func (*DataGathererDiscovery) WaitForCacheSync ¶ added in v0.1.29
func (g *DataGathererDiscovery) WaitForCacheSync(stopCh <-chan struct{}) error
type DataGathererDynamic ¶ added in v0.1.17
type DataGathererDynamic struct {
// contains filtered or unexported fields
}
DataGathererDynamic is a generic gatherer for Kubernetes. It knows how to request a list of generic resources from the Kubernetes apiserver. It does not deserialize the objects into structured data, instead utilising the Kubernetes `Unstructured` type for data handling. This is to allow us to support arbitrary CRDs and resources that Preflight does not have registered as part of its `runtime.Scheme`.
func (*DataGathererDynamic) Delete ¶ added in v0.1.29
func (g *DataGathererDynamic) Delete() error
Delete will flush the cache being used to stored resources gathered by the informer
func (*DataGathererDynamic) Fetch ¶ added in v0.1.17
func (g *DataGathererDynamic) Fetch() (interface{}, int, error)
Fetch will fetch the requested data from the apiserver, or return an error if fetching the data fails.
func (*DataGathererDynamic) Run ¶ added in v0.1.29
func (g *DataGathererDynamic) Run(stopCh <-chan struct{}) error
Run starts the dynamic data gatherer's informers for resource collection. Returns error if the data gatherer informer wasn't initialized
func (*DataGathererDynamic) WaitForCacheSync ¶ added in v0.1.29
func (g *DataGathererDynamic) WaitForCacheSync(stopCh <-chan struct{}) error
WaitForCacheSync waits for the data gatherer's informers cache to sync before collecting the resources.