apiclient

package
v1.8.5 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// APICallRetryInterval defines how long kubeadm should wait before retrying a failed API operation
	APICallRetryInterval = 500 * time.Millisecond
)

Variables

This section is empty.

Functions

func CreateCustomResourceDefinitionIfNeed

func CreateCustomResourceDefinitionIfNeed(client *crdsclient.Clientset, obj *apiextensionsv1.CustomResourceDefinition) error

CreateCustomResourceDefinitionIfNeed creates a CustomResourceDefinition if the target resource doesn't exist. If the resource exists already, this function will update the resource instead.

func CreateNamespace

func CreateNamespace(client clientset.Interface, ns *corev1.Namespace) error

CreateNamespace creates given namespace when the namespace is not existing.

func CreateOrUpdateAPIService

func CreateOrUpdateAPIService(apiRegistrationClient *aggregator.Clientset, apiservice *apiregistrationv1.APIService) error

CreateOrUpdateAPIService creates a APIService if the target resource doesn't exist. If the resource exists already, this function will update the resource instead.

func CreateOrUpdateClusterRole added in v1.7.0

func CreateOrUpdateClusterRole(client clientset.Interface, clusterrole *rbacv1.ClusterRole) error

CreateOrUpdateClusterRole creates a Clusterrole if the target resource doesn't exist. If the resource exists already, this function will update the resource instead.

func CreateOrUpdateDeployment

func CreateOrUpdateDeployment(client clientset.Interface, deployment *appsv1.Deployment) error

CreateOrUpdateDeployment creates a Deployment if the target resource doesn't exist. If the resource exists already, this function will update the resource instead.

func CreateOrUpdateMutatingWebhookConfiguration

func CreateOrUpdateMutatingWebhookConfiguration(client clientset.Interface, mwc *admissionregistrationv1.MutatingWebhookConfiguration) error

CreateOrUpdateMutatingWebhookConfiguration creates a MutatingWebhookConfiguration if the target resource doesn't exist. If the resource exists already, this function will update the resource instead.

func CreateOrUpdateSecret

func CreateOrUpdateSecret(client clientset.Interface, secret *corev1.Secret) error

CreateOrUpdateSecret creates a Sercret if the target resource doesn't exist. If the resource exists already, this function will update the resource instead.

func CreateOrUpdateService

func CreateOrUpdateService(client clientset.Interface, service *corev1.Service) error

CreateOrUpdateService creates a Service if the target resource doesn't exist. If the resource exists already, this function will update the resource instead.

func CreateOrUpdateStatefulSet

func CreateOrUpdateStatefulSet(client clientset.Interface, statefulSet *appsv1.StatefulSet) error

CreateOrUpdateStatefulSet creates a StatefulSet if the target resource doesn't exist. If the resource exists already, this function will update the resource instead.

func CreateOrUpdateValidatingWebhookConfiguration

func CreateOrUpdateValidatingWebhookConfiguration(client clientset.Interface, vwc *admissionregistrationv1.ValidatingWebhookConfiguration) error

CreateOrUpdateValidatingWebhookConfiguration creates a ValidatingWebhookConfiguration if the target resource doesn't exist. If the resource exists already, this function will update the resource instead.

func DeleteDeploymentIfHasLabels

func DeleteDeploymentIfHasLabels(client clientset.Interface, name, namespace string, ls labels.Set) error

DeleteDeploymentIfHasLabels deletes a Deployment that exists the given labels.

func DeleteSecretIfHasLabels

func DeleteSecretIfHasLabels(client clientset.Interface, name, namespace string, ls labels.Set) error

DeleteSecretIfHasLabels deletes a secret that exists the given labels.

func DeleteServiceIfHasLabels

func DeleteServiceIfHasLabels(client clientset.Interface, name, namespace string, ls labels.Set) error

DeleteServiceIfHasLabels deletes a service that exists the given labels.

func DeleteStatefulSetIfHasLabels

func DeleteStatefulSetIfHasLabels(client clientset.Interface, name, namespace string, ls labels.Set) error

DeleteStatefulSetIfHasLabels deletes a StatefulSet that exists the given labels.

func GetService

func GetService(client clientset.Interface, name, namespace string) (*corev1.Service, error)

GetService returns service resource with specified name and namespace.

func NewAPIRegistrationClient

func NewAPIRegistrationClient(c *rest.Config) (*aggregator.Clientset, error)

NewAPIRegistrationClient is to create an apiregistration ClientSet

func NewCRDsClient

func NewCRDsClient(c *rest.Config) (*crdsclient.Clientset, error)

NewCRDsClient is to create a Clientset

func PatchCustomResourceDefinition

func PatchCustomResourceDefinition(client *crdsclient.Clientset, name string, data []byte) error

PatchCustomResourceDefinition patches a crd resource.

func TryRunCommand

func TryRunCommand(f func() error, failureThreshold int) error

TryRunCommand runs a function a maximum of failureThreshold times, and retries on error. If failureThreshold is hit; the last error is returned

Types

type KarmadaWaiter

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

KarmadaWaiter is an implementation of Waiter that is backed by a Kubernetes client

func (*KarmadaWaiter) SetTimeout

func (w *KarmadaWaiter) SetTimeout(timeout time.Duration)

SetTimeout adjusts the timeout to the specified duration

func (*KarmadaWaiter) WaitForAPI

func (w *KarmadaWaiter) WaitForAPI() error

WaitForAPI waits for the API Server's /healthz endpoint to report "ok"

func (*KarmadaWaiter) WaitForAPIService

func (w *KarmadaWaiter) WaitForAPIService(name string) error

WaitForAPIService waits for the APIService condition to become "true"

func (*KarmadaWaiter) WaitForPods

func (w *KarmadaWaiter) WaitForPods(label, namespace string) error

WaitForPods will lookup pods with the given label and wait until they are all reporting status as running.

func (*KarmadaWaiter) WaitForSomePods

func (w *KarmadaWaiter) WaitForSomePods(label, namespace string, podNum int32) error

WaitForSomePods lookup pods with the given label and wait until desired number of pods reporting status as running.

type Waiter

type Waiter interface {
	// WaitForAPI waits for the API Server's /healthz endpoint to become "ok"
	WaitForAPI() error
	// WaitForAPIService waits for the APIService condition to become "true"
	WaitForAPIService(name string) error
	// WaitForPods waits for Pods in the namespace to become Ready
	WaitForPods(label, namespace string) error
	// WaitForSomePods waits for the specified number of Pods in the namespace to become Ready
	WaitForSomePods(label, namespace string, podNum int32) error
	// SetTimeout adjusts the timeout to the specified duration
	SetTimeout(timeout time.Duration)
}

Waiter is an interface for waiting for criteria in Karmada to happen

func NewKarmadaWaiter

func NewKarmadaWaiter(config *rest.Config, client clientset.Interface, timeout time.Duration) Waiter

NewKarmadaWaiter returns a karmada waiter, the rest config is to create crd client or aggregate client.

Jump to

Keyboard shortcuts

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