k8sutils

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type K8sUtils

type K8sUtils struct {
	KubernetesClient *KubernetesClient
	InformerFactory  informers.SharedInformerFactory
	SecretInformer   informerv1.SecretInformer
	Namespace        string
	CertDirectory    string
	// contains filtered or unexported fields
}

K8sUtils stores the configuration of the k8s client, k8s client and the informer

func Init

func Init(namespace, certDirectory string, inCluster bool, resyncPeriod time.Duration) (*K8sUtils, error)

Init - Initializes the k8s client and creates the secret informer

func (*K8sUtils) GetCertFileFromSecret

func (utils *K8sUtils) GetCertFileFromSecret(secret *corev1.Secret) (string, error)

GetCertFileFromSecret - Given a k8s secret, creates a certificate file and returns the file name

func (*K8sUtils) GetCertFileFromSecretName

func (utils *K8sUtils) GetCertFileFromSecretName(secretName string) (string, error)

GetCertFileFromSecretName - Given a secret name, reads the secret and creates a corresponding cert file and returns the file name

func (*K8sUtils) GetCredentialsFromSecret

func (utils *K8sUtils) GetCredentialsFromSecret(secret *corev1.Secret) (*common.Credentials, error)

GetCredentialsFromSecret - Given a secret object, returns credentials

func (*K8sUtils) GetCredentialsFromSecretName

func (utils *K8sUtils) GetCredentialsFromSecretName(secretName string) (*common.Credentials, error)

GetCredentialsFromSecretName - Given a secret name, reads the secret and returns credentials

func (*K8sUtils) StartInformer

func (utils *K8sUtils) StartInformer(callback func(UtilsInterface, *corev1.Secret)) error

StartInformer - starts the informer to listen for any events related to secrets in the namespace being watched

func (*K8sUtils) StopInformer

func (utils *K8sUtils) StopInformer()

StopInformer - stops the informer

type KubernetesClient

type KubernetesClient struct {
	Clientset *kubernetes.Clientset
}

KubernetesClient - client connection

func (*KubernetesClient) CreateInClusterKubeClient

func (c *KubernetesClient) CreateInClusterKubeClient() error

CreateInClusterKubeClient - creates the in-cluster config

func (*KubernetesClient) CreateKubeClient

func (c *KubernetesClient) CreateKubeClient(inCluster bool) error

CreateKubeClient - Creates a k8s client - either InCluster or OutOfCluster

func (*KubernetesClient) CreateOutOfClusterKubeClient

func (c *KubernetesClient) CreateOutOfClusterKubeClient() error

CreateOutOfClusterKubeClient - Creates a Kubernetes Clientset

func (*KubernetesClient) GetSecret

func (c *KubernetesClient) GetSecret(namespace, secretName string) (*corev1.Secret, error)

GetSecret - Given a namespace and secret name, returns a pointer to the secret object

type UtilsInterface

type UtilsInterface interface {
	GetCertFileFromSecret(*corev1.Secret) (string, error)
	GetCertFileFromSecretName(string) (string, error)
	GetCredentialsFromSecret(*corev1.Secret) (*common.Credentials, error)
	GetCredentialsFromSecretName(string) (*common.Credentials, error)
	StartInformer(func(UtilsInterface, *corev1.Secret)) error
	StopInformer()
}

UtilsInterface - interface which provides helper methods related to k8s

Jump to

Keyboard shortcuts

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