k8s

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2025 License: Apache-2.0 Imports: 27 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrClientNotConnected = errors.New("kubernetes client not connected")

ErrClientNotConnected kubernetes clients is not able to access the API.

View Source
var ErrIngressDomainNotFound = fmt.Errorf("ingress domain not found")

ErrIngressDomainNotFound returned when the OpenShift ingress domain is empty.

Functions

func DeleteClusterRoleBindings

func DeleteClusterRoleBindings(
	ctx context.Context,
	kube *Kube,
	namespace string,
) error

DeleteClusterRoleBindings deletes Kubernetes ClusterRoleBindings by label.

func DeleteClusterRoles

func DeleteClusterRoles(
	ctx context.Context,
	kube *Kube,
	namespace string,
) error

DeleteClusterRoles deletes Kubernetes ClusterRoles by label.

func DeleteResources

func DeleteResources(
	ctx context.Context,
	kube *Kube,
	namespace string,
) error

DeleteResources deletes temporary Kubernetes resources created during deployment.

func DeleteRoleBindings

func DeleteRoleBindings(
	ctx context.Context,
	kube *Kube,
	namespace string,
) error

DeleteRoleBindings deletes Kuberbetes RoleBindings by label.

func DeleteRoles

func DeleteRoles(
	ctx context.Context,
	kube *Kube,
	namespace string,
) error

DeleteRoles deletes Kubernetes Roles by label.

func DeleteSecret

func DeleteSecret(
	ctx context.Context,
	kube *Kube,
	name types.NamespacedName,
) error

DeleteSecret deletes a Kubernetes secret.

func DeleteServiceAccounts

func DeleteServiceAccounts(
	ctx context.Context,
	kube *Kube,
	namespace string,
) error

DeleteServiceAccounts deletes Kubernetes ServiceAccounts by label.

func EnsureOpenShiftProject

func EnsureOpenShiftProject(
	ctx context.Context,
	logger *slog.Logger,
	kube *Kube,
	projectName string,
) error

EnsureOpenShiftProject ensures the OpenShift project exists.

func GetOpenShiftIngressDomain

func GetOpenShiftIngressDomain(ctx context.Context, kube *Kube) (string, error)

GetOpenShiftIngressDomain returns the OpenShift Ingress domain.

func GetOpenShiftIngressRouteCA

func GetOpenShiftIngressRouteCA(ctx context.Context, kube *Kube) (string, error)

GetOpenShiftIngressRouteCA returns base64-encoded root certificate for openshift-ingress route. Uses either what's defines in spec->defaultCertificate of IngressController or if that's not defined uses `router-ca` secret from `openshift-ingress-operator` namespace. Related documentation: https://docs.openshift.com/container-platform/4.18/security/certificates/replacing-default-ingress-certificate.html#replacing-default-ingress

func GetOpenShiftVersion

func GetOpenShiftVersion(ctx context.Context, kube *Kube) (string, error)

GetOpenShiftVersion returns the OpenShift version.

func GetSecret

func GetSecret(
	ctx context.Context,
	kube *Kube,
	name types.NamespacedName,
) (*corev1.Secret, error)

GetSecret retrieves a Kubernetes secret by full name.

func Retry

func Retry(attempts int, sleep time.Duration, fn func() error) error

Retry defines retry.

func RetryDeleteResources

func RetryDeleteResources(
	ctx context.Context,
	kube *Kube,
	namespace string,
) error

RetryDeleteResources deletes temporary resources with retry 5 times.

func SecretExists

func SecretExists(
	ctx context.Context,
	kube *Kube,
	name types.NamespacedName,
) (bool, error)

SecretExists checks if a Kubernetes secret exists.

Types

type FakeKube

type FakeKube struct {
	// contains filtered or unexported fields
}

func NewFakeKube

func NewFakeKube(objects ...runtime.Object) *FakeKube

func (*FakeKube) ClientSet

func (f *FakeKube) ClientSet(string) (kubernetes.Interface, error)

func (*FakeKube) Connected

func (f *FakeKube) Connected() error

func (*FakeKube) CoreV1ClientSet

func (f *FakeKube) CoreV1ClientSet(
	namespace string,
) (corev1client.CoreV1Interface, error)

func (*FakeKube) DiscoveryClient

func (f *FakeKube) DiscoveryClient(
	namespace string,
) (discovery.DiscoveryInterface, error)

func (*FakeKube) DynamicClient

func (f *FakeKube) DynamicClient(namespace string) (dynamic.Interface, error)

func (*FakeKube) GetDynamicClientForObjectRef

func (f *FakeKube) GetDynamicClientForObjectRef(
	objectRef *corev1.ObjectReference,
) (dynamic.ResourceInterface, error)

func (*FakeKube) RBACV1ClientSet

func (f *FakeKube) RBACV1ClientSet(
	namespace string,
) (rbacv1client.RbacV1Interface, error)

func (*FakeKube) RESTClientGetter

func (f *FakeKube) RESTClientGetter(_ string) genericclioptions.RESTClientGetter

type Interface

type Interface interface {
	ClientSet(string) (kubernetes.Interface, error)
	Connected() error
	CoreV1ClientSet(string) (corev1client.CoreV1Interface, error)
	DiscoveryClient(string) (discovery.DiscoveryInterface, error)
	DynamicClient(string) (dynamic.Interface, error)
	GetDynamicClientForObjectRef(*corev1.ObjectReference) (dynamic.ResourceInterface, error)
	RBACV1ClientSet(string) (rbacv1client.RbacV1Interface, error)
	RESTClientGetter(string) genericclioptions.RESTClientGetter
}

type Kube

type Kube struct {
	// contains filtered or unexported fields
}

Kube represents the Kubernetes client helper.

func NewKube

func NewKube(flags *flags.Flags) *Kube

NewKube instantiates the Kubernetes client helper.

func (*Kube) BatchV1ClientSet

func (k *Kube) BatchV1ClientSet(
	namespace string,
) (batchv1client.BatchV1Interface, error)

BatchV1ClientSet returns a "batchv1" Kubernetes Clientset.l

func (*Kube) ClientSet

func (k *Kube) ClientSet(namespace string) (kubernetes.Interface, error)

ClientSet returns a "corev1" Kubernetes Clientset.

func (*Kube) Connected

func (k *Kube) Connected() error

Connected reads the cluster's version, to assert if the client is working. For this purpose it assumes namespace "default".

func (*Kube) CoreV1ClientSet

func (k *Kube) CoreV1ClientSet(
	namespace string,
) (corev1client.CoreV1Interface, error)

CoreV1ClientSet returns a "corev1" Kubernetes Clientset.

func (*Kube) DiscoveryClient

func (k *Kube) DiscoveryClient(namespace string) (discovery.DiscoveryInterface, error)

DiscoveryClient instantiates a discovery client for the given namespace.

func (*Kube) DynamicClient

func (k *Kube) DynamicClient(namespace string) (dynamic.Interface, error)

DynamicClient instantiates a dynamic client for the given namespace.

func (*Kube) GetDynamicClientForObjectRef

func (k *Kube) GetDynamicClientForObjectRef(
	objectRef *corev1.ObjectReference,
) (dynamic.ResourceInterface, error)

GetDynamicClientForObjectRef returns a dynamic client for the object reference.

func (*Kube) RBACV1ClientSet

func (k *Kube) RBACV1ClientSet(namespace string) (rbacv1client.RbacV1Interface, error)

RBACV1ClientSet returns a "rbacv1" Kubernetes Clientset.

func (*Kube) RESTClientGetter

func (k *Kube) RESTClientGetter(namespace string) genericclioptions.RESTClientGetter

RESTClientGetter returns a REST client getter for the given namespace.

Jump to

Keyboard shortcuts

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