Documentation
¶
Overview ¶
Package kubernetes encapsulates all calls to the Kubernetes API into meaningful functions for use by the CLI and controllers
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EventInterface ¶
type EventInterface interface {
// Retrieve all events from a namespace
GetEvents(namespace string) (*v1beta1.EventList, error)
}
EventInterface has functions that interacts with pod object in the Kubernetes cluster
type NamespaceInterface ¶
type NamespaceInterface interface {
Fetch(name string) (*corev1.Namespace, error)
Create(name string) (*corev1.Namespace, error)
CreateIfNotExists(name string) (*corev1.Namespace, error)
}
NamespaceInterface has functions that interacts with namespace object in the Kubernetes cluster
func Namespace ¶
func Namespace() NamespaceInterface
Namespace will fetch the inner Kubernetes API with a default client
func NamespaceC ¶
func NamespaceC(c *client.Client) NamespaceInterface
NamespaceC will use a defined client to fetch the Kubernetes API
type PodInterface ¶
type PodInterface interface {
// Immediately return pod log
GetLogs(namespace, podName, containerName string) (string, error)
// Wait until pod is terminated and then return pod log
GetLogsWithFollow(namespace, podName, containerName string) (string, error)
}
PodInterface has functions that interacts with pod object in the Kubernetes cluster
type ResourceInterface ¶
type ResourceInterface interface {
ResourceReader
ResourceWriter
// CreateIfNotExists will fetch for the object resource in the Kubernetes cluster, if not exists, will create it.
CreateIfNotExists(resource client.Object) (err error)
// CreateIfNotExistsForOwner sets the controller owner to the given resource and creates if it not exists.
// If the given resource exists, won't update the object with the given owner.
CreateIfNotExistsForOwner(resource client.Object, owner metav1.Object, scheme *runtime.Scheme) (err error)
// CreateForOwner sets the controller owner to the given resource and creates the resource.
CreateForOwner(resource client.Object, owner metav1.Object, scheme *runtime.Scheme) error
// CreateFromYamlContent creates Kubernetes resources from a yaml string content
CreateFromYamlContent(yamlContent, namespace string, resourceRef client.Object, beforeCreate func(object interface{})) error
}
ResourceInterface has functions that interacts with any resource object in the Kubernetes cluster
type ResourceReader ¶
type ResourceReader interface {
// FetchWithKey fetches and binds a resource from the Kubernetes cluster with the defined key. If not exists, returns false.
FetchWithKey(key types.NamespacedName, resource client.Object) (exists bool, err error)
// Fetch fetches and binds a resource with given name and namespace from the Kubernetes cluster. If not exists, returns false.
Fetch(resource client.Object) (exists bool, err error)
// ListWithNamespace fetches and binds a list resource from the Kubernetes cluster with the defined namespace.
ListWithNamespace(namespace string, list client.ObjectList) error
// ListWithNamespaceAndLabel same as ListWithNamespace, but also limit the query scope by the given labels
ListWithNamespaceAndLabel(namespace string, list client.ObjectList, labels map[string]string) error
// ListAll returns a map of Kubernetes resources organized by type, based on provided List objects
ListAll(objectTypes []client.ObjectList, namespace string, ownerObject metav1.Object) (map[reflect.Type][]client.Object, error)
}
ResourceReader interface to read kubernetes object
func ResourceReaderC ¶
func ResourceReaderC(cli *kogitocli.Client) ResourceReader
ResourceReaderC provide ResourceReader reference
type ResourceWriter ¶
type ResourceWriter interface {
// Create creates a new Kubernetes object in the cluster.
// Note that no checks will be performed in the cluster. If you're not sure, use CreateIfNotExists.
Create(resource client.Object) error
// Delete delete the given object
Delete(resource client.Object) error
// Update the given object
Update(resource client.Object) error
// UpdateStatus update the given object status
UpdateStatus(resource client.Object) error
// CreateResources create provided objects
CreateResources(resources []client.Object) (bool, error)
// UpdateResources update provided objects
UpdateResources(existing []client.Object, resources []client.Object) (bool, error)
// DeleteResources delete provided objects
DeleteResources(resources []client.Object) (bool, error)
}
ResourceWriter interface to write kubernetes object
func ResourceWriterC ¶
func ResourceWriterC(cli *kogitocli.Client) ResourceWriter
ResourceWriterC provide ResourceWrite reference