Documentation ¶
Overview ¶
package k8s implements Kubernetes resources stored in a Kube API server.
Class ¶
A k8s class corresponds to a kind of Kubernetes resource, the class name is `KIND.VERSION.GROUP` VERSION and/or GROUP can be omitted if there is no ambiguity. Example class names: `k8s:Pod.v1`, `ks8:Pod`, `k8s:Deployment.v1.apps`, `k8s:Deployment.apps`, `k8s:Deployment`
Object ¶
Objects are represented by the standard Go types used by `k8s.io/client-go/api`, and by Kube-generated CRD struct types. Rules starting from the k8s domain should use the capitalized Go field names rather than the lowercase JSON field names.
Query ¶
Queries are the JSON-serialized form of this struct: Query
For example:
k8s:Pod.v1.:{"namespace":"openshift-cluster-version","name":"cluster-version-operator-8d86bcb65-btlgn"}
Store ¶
k8s stores connects to the current logged-in Kubernetes cluster, no other configuration is needed than:
domain: k8s
Index ¶
- Variables
- func Create(c client.Client, objs ...client.Object) error
- func EventFor(o client.Object, name string) *corev1.Event
- func GetConfig() (*rest.Config, error)
- func GroupVersionKind(o client.Object) schema.GroupVersionKind
- func NamespacedName(namespace, name string) types.NamespacedName
- func New[T any, PT interface{ ... }](namespace, name string) PT
- func NewClient(cfg *rest.Config) (c client.Client, err error)
- func NewHTTPClient() (*http.Client, error)
- func NewStore(c client.Client, cfg *rest.Config) (korrel8r.Store, error)
- func SetLogger(l logr.Logger)
- type Class
- func (c Class) Description() string
- func (c Class) Domain() korrel8r.Domain
- func (c Class) GVK() schema.GroupVersionKind
- func (c Class) ID(o korrel8r.Object) any
- func (c Class) Name() string
- func (c Class) New() korrel8r.Object
- func (c Class) Preview(o korrel8r.Object) string
- func (c Class) String() string
- type Object
- type Query
- type Store
Constants ¶
This section is empty.
Variables ¶
var Domain = domain{}
Domain for Kubernetes resources stored in a Kube API server.
var Scheme = apiruntime.NewScheme()
Functions ¶
func GroupVersionKind ¶ added in v0.4.0
func GroupVersionKind(o client.Object) schema.GroupVersionKind
GroupVersionKind returns the GVK of o, which must be a pointer to a typed API resource struct. Returns empty if o is not a known resource type.
func NamespacedName ¶
func NamespacedName(namespace, name string) types.NamespacedName
func NewClient ¶ added in v0.1.1
NewClient provides a general-purpose k8s client. It may be used by other domains that need to talk to the cluster. If cfg is nil, use GetConfig() to get a default config.
func NewHTTPClient ¶ added in v0.5.7
NewHTTPClient returns a new client for GetConfig()
Types ¶
type Class ¶
type Class schema.GroupVersionKind
Class represents a kind of kubernetes resource.
func ClassOf ¶
ClassOf returns the Class of o, which must be a pointer to a typed API resource struct.
func (Class) Description ¶ added in v0.1.2
func (Class) GVK ¶
func (c Class) GVK() schema.GroupVersionKind
type Query ¶
type Query struct { // Namespace restricts the search to a namespace. Namespace string `json:"namespace,omitempty"` Name string `json:"name,omitempty"` // Labels restricts the search to objects with matching label values (optional) Labels client.MatchingLabels `json:"labels,omitempty"` // Fields restricts the search to objects with matching field values (optional) Fields client.MatchingFields `json:"fields,omitempty"` // K8sClass is the underlying k8s.Class object. K8sClass Class }
Query represents a Kubernetes resource query.