kubeclient

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2023 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 2 more Imports: 40 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// APICallRetryInterval defines how long should wait before retrying a failed API operation
	APICallRetryInterval = 500 * time.Millisecond
	// PatchNodeTimeout specifies how long should wait for applying the label and taint on the master before timing out
	PatchNodeTimeout = 2 * time.Minute
	// UpdateNodeTimeout specifies how long should wait for updating node with the initial remote configuration of kubelet before timing out
	UpdateNodeTimeout = 2 * time.Minute
	// LabelHostname specifies the lable in node.
	LabelHostname = "kubernetes.io/hostname"
)

Variables

This section is empty.

Functions

func AddNameSpaceLabel added in v0.6.0

func AddNameSpaceLabel(kubeClient kubernetes.Interface, namespaceName string, labels map[string]string) error

func AddNodeLabel added in v0.3.0

func AddNodeLabel(kubeClient kubernetes.Interface, nodeName string, labels map[string]string) error

func CheckNodeLabel added in v0.3.0

func CheckNodeLabel(kubeClient *kubernetes.Clientset, nodeName string, labels map[string]string) (bool, error)

func CompleteTemplate

func CompleteTemplate(strtmpl string, context interface{}) (string, error)

CompleteTemplate complete templates with context

func CreateOrRetainConfigMap

func CreateOrRetainConfigMap(client clientset.Interface, cm *corev1.ConfigMap, configMapName string) error

CreateOrRetainConfigMap creates a ConfigMap if the target resource doesn't exist. If the resource exists already, this function will retain the resource instead.

func CreateOrUpdateCSIDriver added in v0.6.0

func CreateOrUpdateCSIDriver(client clientset.Interface, csiDriver *storagev1.CSIDriver) error

func CreateOrUpdateClusterRole

func CreateOrUpdateClusterRole(client clientset.Interface, clusterRole *rbac.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 CreateOrUpdateClusterRoleBinding

func CreateOrUpdateClusterRoleBinding(client clientset.Interface, clusterRoleBinding *rbac.ClusterRoleBinding) error

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

func CreateOrUpdateConfigMap

func CreateOrUpdateConfigMap(client clientset.Interface, cm *corev1.ConfigMap) error

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

func CreateOrUpdateConfigMapFromFile

func CreateOrUpdateConfigMapFromFile(client clientset.Interface, cm *corev1.ConfigMap, pattern string) error

CreateOrUpdateConfigMapFromFile like kubectl create configmap --from-file

func CreateOrUpdateCronJob

func CreateOrUpdateCronJob(client clientset.Interface, cronjob *batchv1beta1.CronJob) error

CreateOrUpdateCronJob creates a Job if the target resource doesn't exist. If the resource exists already, this function will update

func CreateOrUpdateCustomResourceDefinition added in v0.6.0

func CreateOrUpdateCustomResourceDefinition(client extensionSclientset.Interface, yaml string, option interface{}) error

func CreateOrUpdateDaemonSet

func CreateOrUpdateDaemonSet(client clientset.Interface, ds *apps.DaemonSet) error

CreateOrUpdateDaemonSet creates a DaemonSet 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, deploy *apps.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 CreateOrUpdateDeploymentExtensionsV1beta1

func CreateOrUpdateDeploymentExtensionsV1beta1(client clientset.Interface, deploy *extensionsv1beta1.Deployment) error

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

func CreateOrUpdateEndpoints

func CreateOrUpdateEndpoints(client clientset.Interface, ep *corev1.Endpoints) error

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

func CreateOrUpdateIngress

func CreateOrUpdateIngress(client clientset.Interface, ing *extensionsv1beta1.Ingress) error

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

func CreateOrUpdateJob

func CreateOrUpdateJob(client clientset.Interface, job *batchv1.Job) error

CreateOrUpdateJob creates a Job if the target resource doesn't exist. If the resource exists already, this function will update

func CreateOrUpdateMutatingWebhookConfiguration

func CreateOrUpdateMutatingWebhookConfiguration(client clientset.Interface, obj *admissionv1.MutatingWebhookConfiguration) error

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

func CreateOrUpdateNamespace

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

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

func CreateOrUpdatePersistentVolume added in v0.9.0

func CreateOrUpdatePersistentVolume(client clientset.Interface, obj *corev1.PersistentVolume) error

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

func CreateOrUpdatePodSecurityPolicy added in v0.3.0

func CreateOrUpdatePodSecurityPolicy(client clientset.Interface, podSecurityPolicy *v1beta1.PodSecurityPolicy) error

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

func CreateOrUpdateRole

func CreateOrUpdateRole(client clientset.Interface, role *rbac.Role) error

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

func CreateOrUpdateRoleBinding

func CreateOrUpdateRoleBinding(client clientset.Interface, roleBinding *rbac.RoleBinding) error

CreateOrUpdateRoleBinding creates a RoleBinding 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 Secret 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, svc *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 CreateOrUpdateServiceAccount

func CreateOrUpdateServiceAccount(client clientset.Interface, sa *corev1.ServiceAccount) error

CreateOrUpdateServiceAccount creates a ServiceAccount 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, sts *apps.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 CreateOrUpdateStorageClass added in v0.6.0

func CreateOrUpdateStorageClass(client clientset.Interface, csiDriver *storagev1.StorageClass) error

func CreateOrUpdateValidatingWebhookConfiguration

func CreateOrUpdateValidatingWebhookConfiguration(client clientset.Interface, obj *admissionv1.ValidatingWebhookConfiguration) error

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

func CreateResourceWithFile

func CreateResourceWithFile(client kubernetes.Interface, yamlStr string, option interface{}) error

CreateResourceWithFile create k8s resource with file

func CustomConfig

func CustomConfig() string

func DeleteCSIDriver added in v0.6.0

func DeleteCSIDriver(client clientset.Interface, csiDriver *storagev1.CSIDriver) error

func DeleteClusterRole

func DeleteClusterRole(client clientset.Interface, clusterRole *rbac.ClusterRole) error

func DeleteClusterRoleBinding

func DeleteClusterRoleBinding(client clientset.Interface, clusterRoleBinding *rbac.ClusterRoleBinding) error

func DeleteConfigMap

func DeleteConfigMap(client clientset.Interface, cm *corev1.ConfigMap) error

func DeleteDaemonSet

func DeleteDaemonSet(client clientset.Interface, ds *apps.DaemonSet) error

func DeleteDaemonSetForeground

func DeleteDaemonSetForeground(client clientset.Interface, namespace, name string) error

DeleteDaemonSetForeground deletes the specified DaemonSet in foreground mode; i.e. it blocks until/makes sure all the managed Pods are deleted

func DeleteDeployment

func DeleteDeployment(client clientset.Interface, namespace string, deployName string, isExtensions bool, labelSelector metav1.LabelSelector) error

func DeleteDeploymentForeground

func DeleteDeploymentForeground(client clientset.Interface, namespace, name string) error

DeleteDeploymentForeground deletes the specified Deployment in foreground mode; i.e. it blocks until/makes sure all the managed Pods are deleted

func DeleteJob

func DeleteJob(client clientset.Interface, job *batchv1.Job) error

func DeleteMutatingMutatingWebhookConfigurations

func DeleteMutatingMutatingWebhookConfigurations(client clientset.Interface, obj *admissionv1.MutatingWebhookConfiguration) error

func DeleteNodeLabel added in v0.3.0

func DeleteNodeLabel(kubeClient *kubernetes.Clientset, nodeName string, labels map[string]string) error

func DeletePodSecurityPolicy added in v0.6.0

func DeletePodSecurityPolicy(client clientset.Interface, podSecurityPolicy *v1beta1.PodSecurityPolicy) error

func DeleteReplicaSetApp

func DeleteReplicaSetApp(client clientset.Interface, options metav1.ListOptions) error

DeleteReplicaSetApp delete the replicaset and pod additionally for deployment app with extension group

func DeleteResourceWithFile

func DeleteResourceWithFile(client kubernetes.Interface, yamlStr string, option interface{}) error

DeleteResourceWithFile create k8s resource with file

func DeleteRole

func DeleteRole(client clientset.Interface, role *rbac.Role) error

func DeleteRoleBinding

func DeleteRoleBinding(client clientset.Interface, roleBinding *rbac.RoleBinding) error

func DeleteSecret

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

func DeleteService

func DeleteService(client clientset.Interface, svc *corev1.Service) error

func DeleteServiceAccount

func DeleteServiceAccount(client clientset.Interface, sa *corev1.ServiceAccount) error

func DeleteServiceAccounts

func DeleteServiceAccounts(client clientset.Interface, namespace string, svcAccountName string) error

DeleteServiceAccounts delete a serviceAccount

func DeleteStorageClasses added in v0.6.0

func DeleteStorageClasses(client clientset.Interface, csiDriver *storagev1.StorageClass) error

func GetAPIExtensionSclientset added in v0.6.0

func GetAPIExtensionSclientset(kubeconfigFile string) (extensionSclientset.Interface, error)

func GetClientSet

func GetClientSet(kubeconfigFile string) (*kubernetes.Clientset, error)

func GetClusterRoleBinding

func GetClusterRoleBinding(client clientset.Interface, name string) (*rbac.ClusterRoleBinding, error)

GetClusterRoleBinding get a cluster role binding.

func GetInclusterClientSet added in v0.7.0

func GetInclusterClientSet(kubeConfigPath string) (*kubernetes.Clientset, error)

func GetKubeConfig added in v0.4.0

func GetKubeConfig(kubeConfigPath string) (*restclient.Config, error)

func GetNodeListStatus added in v0.6.1

func GetNodeListStatus(nodes []corev1.Node) (readyNodes []string, notReadyNodes []string)

func GetService

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

GetService get a service.

func GetServiceAccount

func GetServiceAccount(client clientset.Interface, namespace string, name string) (*corev1.ServiceAccount, error)

GetServiceAccount get a service.

func IsJobFinished added in v0.4.0

func IsJobFinished(j *batchv1.Job) bool

func IsOverK8sVersion added in v0.3.0

func IsOverK8sVersion(baseK8sVersion, k8sVersion string) (bool, error)

func IsReadyNode added in v0.6.1

func IsReadyNode(node *corev1.Node) bool

func MarkNode

func MarkNode(client clientset.Interface, nodeName string, labels map[string]string, taints []corev1.Taint) error

MarkNode mark node by adding labels and taints

func ParseString

func ParseString(strtmpl string, obj interface{}) ([]byte, error)

ParseString validates and parses passed as argument template

func PatchNode

func PatchNode(client clientset.Interface, nodeName string, patchFn func(*corev1.Node)) error

PatchNode tries to patch a node using patchFn for the actual mutating logic. Retries are provided by the wait package.

func PatchNodeOnce

func PatchNodeOnce(client clientset.Interface, nodeName string, patchFn func(*corev1.Node)) func() (bool, error)

PatchNodeOnce executes patchFn on the node object found by the node name. This is a condition function meant to be used with wait.Poll. false, nil implies it is safe to try again, an error indicates no more tries should be made and true indicates success.

Types

This section is empty.

Jump to

Keyboard shortcuts

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