kube

package module
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 9, 2022 License: MIT Imports: 15 Imported by: 2

README

Simple K8s client with common K8s operations

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FlattenLabelSelector

func FlattenLabelSelector(labelSelector *metav1.LabelSelector) (string, error)

func GetDeploymentAnnotations

func GetDeploymentAnnotations(deploy appsv1.Deployment) map[string]string

func GetDeploymentResourceVersion

func GetDeploymentResourceVersion(deploy appsv1.Deployment) string

func GetStsAnnotations

func GetStsAnnotations(sts appsv1.StatefulSet) map[string]string

func GetStsResourceVersion

func GetStsResourceVersion(sts appsv1.StatefulSet) string

func MockDeployment

func MockDeployment(name, namespace string) *v1.Deployment

func MockIngress

func MockIngress(name, namespace string) *netv1.Ingress

func MockPod

func MockPod(name, namespace string) *corev1.Pod

func MockReplicaset

func MockReplicaset(name, namespace string) *v1.ReplicaSet

func MockSecret

func MockSecret(name, namespace string, data map[string][]byte) *corev1.Secret

func MockStatefulSet

func MockStatefulSet(name, namespace string) *v1.StatefulSet

func MockTemplateSpec

func MockTemplateSpec(containerName, image, pullSecret string) corev1.PodTemplateSpec

func ParseDeploymentInfo

func ParseDeploymentInfo(deploy appsv1.Deployment, conIndx int) (string, string, error)

ParseDeploymentInfo returns image and its pull secret for a given container in the Deployment

func ParseStatefulSetInfo

func ParseStatefulSetInfo(sts appsv1.StatefulSet, conIndx int) (string, string, error)

ParseStatefulSetInfo returns image and its pull secret for a given container in the StatefulSet

func RemoveDeploymentAnnotation

func RemoveDeploymentAnnotation(deploy appsv1.Deployment, annotation, value string)

func RemoveStsAnnotation

func RemoveStsAnnotation(sts appsv1.StatefulSet, annotation, value string)

func SetDeploymentAnnotation

func SetDeploymentAnnotation(deploy appsv1.Deployment, annotation, value string)

func SetDeploymentImage

func SetDeploymentImage(deploy appsv1.Deployment, image string, conIndx int)

func SetDeploymentImagePullSecret

func SetDeploymentImagePullSecret(deploy appsv1.Deployment, imagePullSecret string)

func SetStatefulSetImage

func SetStatefulSetImage(sts appsv1.StatefulSet, image string, conIndx int)

func SetStsAnnotation

func SetStsAnnotation(sts appsv1.StatefulSet, annotation, value string)

func SetStsImagePullSecret

func SetStsImagePullSecret(sts appsv1.StatefulSet, imagePullSecret string)

Types

type K8sClient

type K8sClient struct {
	Client kubernetes.Interface
}

Client for K8s API interactions

func NewClient

func NewClient(conf *rest.Config) (*K8sClient, error)

NewClient returns an initialized K8sClient object

func NewMockClient

func NewMockClient(obj ...runtime.Object) *K8sClient

NewMockClient returns an initialized Mock Client object

func (*K8sClient) CreateNamespace

func (c *K8sClient) CreateNamespace(name string) error

CreateNamespace creates a namespace with a given name

func (*K8sClient) CreateRole added in v0.1.2

func (c *K8sClient) CreateRole(name, namespace string, rules []rbacv1.PolicyRule) error

func (*K8sClient) CreateRoleBinding added in v0.1.2

func (c *K8sClient) CreateRoleBinding(name, namespace string, roleRef rbacv1.RoleRef, subject rbacv1.Subject) error

func (*K8sClient) CreateSecret

func (c *K8sClient) CreateSecret(name, namespace string, secType corev1.SecretType, data map[string]interface{}) error

CreateSecret creates a K8s secret with a given name from a given map

func (*K8sClient) CreateServiceAccount added in v0.1.2

func (c *K8sClient) CreateServiceAccount(name, namespace string) (*corev1.ServiceAccount, error)

func (*K8sClient) DeleteIngress

func (c *K8sClient) DeleteIngress(namespace, name string) error

func (*K8sClient) DeleteSecret

func (c *K8sClient) DeleteSecret(name, namespace string) error

DeleteSecret delete a K8s secret with a given name

func (*K8sClient) GetAnnotatedPullSecrets

func (c *K8sClient) GetAnnotatedPullSecrets(namespace string, annotations map[string]string) ([]corev1.Secret, error)

GetAnnotatedPullSecrets get a K8s secret with a given name and annotations

func (*K8sClient) GetDeployment

func (c *K8sClient) GetDeployment(namespace, name string) (*appsv1.Deployment, error)

func (*K8sClient) GetIngress

func (c *K8sClient) GetIngress(namespace, name string) (*netv1.Ingress, error)

func (*K8sClient) GetRole added in v0.1.2

func (c *K8sClient) GetRole(name, namespace string) (*rbacv1.Role, error)

func (*K8sClient) GetRoleBinding added in v0.1.2

func (c *K8sClient) GetRoleBinding(name, namespace string) (*rbacv1.RoleBinding, error)

func (*K8sClient) GetSecrets

func (c *K8sClient) GetSecrets(namespace string) ([]corev1.Secret, error)

GetSecrets get a K8s secret with a given name

func (*K8sClient) GetServiceAccount added in v0.1.2

func (c *K8sClient) GetServiceAccount(name, namespace string) (*corev1.ServiceAccount, error)

func (*K8sClient) GetStatefulSet

func (c *K8sClient) GetStatefulSet(namespace, name string) (*appsv1.StatefulSet, error)

func (*K8sClient) ListDeployments

func (c *K8sClient) ListDeployments(namespace string) (*appsv1.DeploymentList, error)

func (*K8sClient) ListIngresses

func (c *K8sClient) ListIngresses(namespace string) (*netv1.IngressList, error)

func (*K8sClient) ListRoles added in v0.1.2

func (c *K8sClient) ListRoles(namespace string) (*rbacv1.RoleList, error)

func (*K8sClient) ListStatefulSets

func (c *K8sClient) ListStatefulSets(namespace string) (*appsv1.StatefulSetList, error)

ListStatefulSets returns a list of stateful sets in a given namespace with enabled auto updates

func (*K8sClient) ReadSecret

func (c *K8sClient) ReadSecret(name, namespace string) (map[string][]byte, error)

ReadSecret reads a K8s secret with a given name

func (*K8sClient) UpdateDeployment

func (c *K8sClient) UpdateDeployment(deploy *appsv1.Deployment) error

UpdateDeployment applies update with given deployment

func (*K8sClient) UpdateSecret

func (c *K8sClient) UpdateSecret(name, namespace string, data map[string]interface{}) error

UpdateSecret updates a K8s secret with a given name from a given map and creates one if it's absent

func (*K8sClient) UpdateStatefulSet

func (c *K8sClient) UpdateStatefulSet(sts *appsv1.StatefulSet) error

UpdateStatefulSet applies update with given deployment

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL