k8sclient

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2022 License: Apache-2.0 Imports: 45 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CLIKubernetes = "kubectl"
	CLIOpenShift  = "oc"

	FlavorKubernetes OrchestratorFlavor = "k8s"
	FlavorOpenShift  OrchestratorFlavor = "openshift"

	ExitCodeSuccess = 0
	ExitCodeFailure = 1

	YAMLSeparator = `\n---\s*\n`

	// CRD Finalizer name
	TridentFinalizer = "trident.netapp.io"
)
View Source
const (
	TridentAppLabelKey       = "app"
	DefaultContainerLabelKey = "kubectl.kubernetes.io/default-container"
)
View Source
const CSIDriverYAMLv1 = `` /* 126-byte string literal not displayed */
View Source
const PrivilegedPodSecurityPolicyYAML = `` /* 400-byte string literal not displayed */
View Source
const UnprivilegedPodSecurityPolicyYAML = `` /* 316-byte string literal not displayed */

Variables

This section is empty.

Functions

func GenericPatch

func GenericPatch(original interface{}, modifiedYAML []byte) ([]byte, error)

GenericPatch merges an object with a new YAML definition.

func GetBackendCRDYAML

func GetBackendCRDYAML() string

func GetBackendConfigCRDYAML

func GetBackendConfigCRDYAML() string

func GetCRDsYAML

func GetCRDsYAML() string

func GetCSIDaemonSetYAMLLinux

func GetCSIDaemonSetYAMLLinux(args *DaemonsetYAMLArguments) string

func GetCSIDaemonSetYAMLWindows

func GetCSIDaemonSetYAMLWindows(args *DaemonsetYAMLArguments) string

func GetCSIDeploymentYAML

func GetCSIDeploymentYAML(args *DeploymentYAMLArguments) string

func GetCSIDriverYAML

func GetCSIDriverYAML(name string, labels, controllingCRDetails map[string]string) string

func GetCSIServiceYAML

func GetCSIServiceYAML(serviceName string, labels, controllingCRDetails map[string]string) string

func GetClusterRoleBindingYAML

func GetClusterRoleBindingYAML(
	namespace, name string, flavor OrchestratorFlavor,
	labels, controllingCRDetails map[string]string, csi bool,
) string

func GetClusterRoleYAML

func GetClusterRoleYAML(
	flavor OrchestratorFlavor, clusterRoleName string, labels, controllingCRDetails map[string]string, csi bool,
) string

func GetMirrorRelationshipCRDYAML

func GetMirrorRelationshipCRDYAML() string

func GetNamespaceYAML

func GetNamespaceYAML(namespace string) string

func GetNodeCRDYAML

func GetNodeCRDYAML() string

func GetOpenShiftSCCQueryYAML

func GetOpenShiftSCCQueryYAML(scc string) string

func GetOpenShiftSCCYAML

func GetOpenShiftSCCYAML(sccName, user, namespace string, labels, controllingCRDetails map[string]string) string

func GetOrchestratorCRDYAML

func GetOrchestratorCRDYAML() string

func GetPrivilegedPodSecurityPolicyYAML

func GetPrivilegedPodSecurityPolicyYAML(pspName string, labels, controllingCRDetails map[string]string) string

func GetResourceQuotaYAML

func GetResourceQuotaYAML(resourceQuotaName, namespace string, labels, controllingCRDetails map[string]string) string

func GetSecretYAML

func GetSecretYAML(
	secretName, namespace string, labels, controllingCRDetails, data, stringData map[string]string,
) string

func GetServiceAccountYAML

func GetServiceAccountYAML(
	serviceAccountName string, secrets []string, labels, controllingCRDetails map[string]string,
) string

func GetSnapshotCRDYAML

func GetSnapshotCRDYAML() string

func GetSnapshotInfoCRDYAML

func GetSnapshotInfoCRDYAML() string

func GetStorageClassCRDYAML

func GetStorageClassCRDYAML() string

func GetTransactionCRDYAML

func GetTransactionCRDYAML() string

func GetTridentVersionPodYAML

func GetTridentVersionPodYAML(
	name, tridentImage, serviceAccountName string, imagePullSecrets []string, labels,
	controllingCRDetails map[string]string,
) string

func GetUnprivilegedPodSecurityPolicyYAML

func GetUnprivilegedPodSecurityPolicyYAML(pspName string, labels, controllingCRDetails map[string]string) string

func GetVersionCRDYAML

func GetVersionCRDYAML() string

func GetVolumeCRDYAML

func GetVolumeCRDYAML() string

func GetVolumePublicationCRDYAML

func GetVolumePublicationCRDYAML() string

func GetVolumeReferenceCRDYAML

func GetVolumeReferenceCRDYAML() string

Types

type Clients

type Clients struct {
	RestConfig     *rest.Config
	KubeClient     *kubernetes.Clientset
	SnapshotClient *k8ssnapshots.Clientset
	K8SClient      KubernetesClient
	TprovClient    *tprov.Clientset
	TorcClient     *torc.Clientset
	TridentClient  *tridentv1clientset.Clientset
	K8SVersion     *k8sversion.Info
	Namespace      string
	InK8SPod       bool
}

func CreateK8SClients

func CreateK8SClients(masterURL, kubeConfigPath, overrideNamespace string) (*Clients, error)

CreateK8SClients is the top-level factory method for creating Kubernetes clients. Whether this code is running inside or outside a pod is detected automatically. If inside, we can get the kubeconfig and namespace from the context we are running in. If outside, either a kubeconfig is specified or we use kubectl/oc to read the kubeconfig using `kubectl config view --raw` and we attempt to discern the namespace from the kubeconfig context. The namespace may be overridden, and if the namespace may not be determined by any other means, it is set to 'default'.

type DaemonsetYAMLArguments

type DaemonsetYAMLArguments struct {
	DaemonsetName        string              `json:"daemonsetName"`
	TridentImage         string              `json:"tridentImage"`
	ImageRegistry        string              `json:"imageRegistry"`
	KubeletDir           string              `json:"kubeletDir"`
	LogFormat            string              `json:"logFormat"`
	ProbePort            string              `json:"probePort"`
	ImagePullSecrets     []string            `json:"imagePullSecrets"`
	Labels               map[string]string   `json:"labels"`
	ControllingCRDetails map[string]string   `json:"controllingCRDetails"`
	EnableForceDetach    bool                `json:"enableForceDetach"`
	Debug                bool                `json:"debug"`
	Version              *utils.Version      `json:"version"`
	HTTPRequestTimeout   string              `json:"httpRequestTimeout"`
	NodeSelector         map[string]string   `json:"nodeSelector"`
	Tolerations          []map[string]string `json:"tolerations"`
	ServiceAccountName   string              `json:"serviceAccountName"`
}

type DeploymentYAMLArguments

type DeploymentYAMLArguments struct {
	DeploymentName          string              `json:"deploymentName"`
	TridentImage            string              `json:"tridentImage"`
	AutosupportImage        string              `json:"autosupportImage"`
	AutosupportProxy        string              `json:"autosupportProxy"`
	AutosupportCustomURL    string              `json:"autosupportCustomURL"`
	AutosupportSerialNumber string              `json:"autosupportSerialNumber"`
	AutosupportHostname     string              `json:"autosupportHostname"`
	ImageRegistry           string              `json:"imageRegistry"`
	LogFormat               string              `json:"logFormat"`
	SnapshotCRDVersion      string              `json:"snapshotCRDVersion"`
	ImagePullSecrets        []string            `json:"imagePullSecrets"`
	Labels                  map[string]string   `json:"labels"`
	ControllingCRDetails    map[string]string   `json:"controllingCRDetails"`
	Debug                   bool                `json:"debug"`
	UseIPv6                 bool                `json:"useIPv6"`
	SilenceAutosupport      bool                `json:"silenceAutosupport"`
	Version                 *utils.Version      `json:"version"`
	TopologyEnabled         bool                `json:"topologyEnabled"`
	HTTPRequestTimeout      string              `json:"httpRequestTimeout"`
	NodeSelector            map[string]string   `json:"nodeSelector"`
	Tolerations             []map[string]string `json:"tolerations"`
	ServiceAccountName      string              `json:"serviceAccountName"`
}

type KubeClient

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

func (*KubeClient) AddFinalizerToCRD

func (k *KubeClient) AddFinalizerToCRD(crdName string) error

AddFinalizerToCRD updates the CRD object to include our Trident finalizer (definitions are not namespaced)

func (*KubeClient) AddFinalizerToCRDs

func (k *KubeClient) AddFinalizerToCRDs(CRDnames []string) error

AddFinalizerToCRDs updates the CRD objects to include our Trident finalizer (definitions are not namespaced)

func (*KubeClient) CLI

func (k *KubeClient) CLI() string

func (*KubeClient) CheckCRDExists

func (k *KubeClient) CheckCRDExists(crdName string) (bool, error)

func (*KubeClient) CheckCSIDriverExistsByLabel

func (k *KubeClient) CheckCSIDriverExistsByLabel(label string) (bool, string, error)

CheckCSIDriverExistsByLabel returns true if one or more CSI Driver objects matching the specified label exist.

func (*KubeClient) CheckClusterRoleBindingExistsByLabel

func (k *KubeClient) CheckClusterRoleBindingExistsByLabel(label string) (bool, string, error)

CheckClusterRoleBindingExistsByLabel returns true if one or more cluster role binding objects matching the specified label exist.

func (*KubeClient) CheckClusterRoleExistsByLabel

func (k *KubeClient) CheckClusterRoleExistsByLabel(label string) (bool, string, error)

CheckClusterRoleExistsByLabel returns true if one or more cluster role objects matching the specified label exist.

func (*KubeClient) CheckConfigMapExistsByLabel

func (k *KubeClient) CheckConfigMapExistsByLabel(label string, allNamespaces bool) (bool, string, error)

CheckConfigMapExistsByLabel returns true if one or more configmap objects matching the specified label exist.

func (*KubeClient) CheckDaemonSetExists

func (k *KubeClient) CheckDaemonSetExists(name, namespace string) (bool, error)

CheckDaemonSetExists returns true if the specified daemonset exists.

func (*KubeClient) CheckDaemonSetExistsByLabel

func (k *KubeClient) CheckDaemonSetExistsByLabel(label string, allNamespaces bool) (bool, string, error)

CheckDaemonSetExistsByLabel returns true if one or more daemonset objects matching the specified label exist.

func (*KubeClient) CheckDeploymentExists

func (k *KubeClient) CheckDeploymentExists(name, namespace string) (bool, error)

CheckDeploymentExists returns true if the specified deployment exists.

func (*KubeClient) CheckDeploymentExistsByLabel

func (k *KubeClient) CheckDeploymentExistsByLabel(label string, allNamespaces bool) (bool, string, error)

CheckDeploymentExistsByLabel returns true if one or more deployment objects matching the specified label exist.

func (*KubeClient) CheckNamespaceExists

func (k *KubeClient) CheckNamespaceExists(namespace string) (bool, error)

func (*KubeClient) CheckPVCBound

func (k *KubeClient) CheckPVCBound(pvcName string) (bool, error)

func (*KubeClient) CheckPVCExists

func (k *KubeClient) CheckPVCExists(pvc string) (bool, error)

func (*KubeClient) CheckPVExists

func (k *KubeClient) CheckPVExists(pvName string) (bool, error)

func (*KubeClient) CheckPodExistsByLabel

func (k *KubeClient) CheckPodExistsByLabel(label string, allNamespaces bool) (bool, string, error)

CheckPodExistsByLabel returns true if one or more pod objects matching the specified label exist.

func (*KubeClient) CheckPodSecurityPolicyExistsByLabel

func (k *KubeClient) CheckPodSecurityPolicyExistsByLabel(label string) (bool, string, error)

CheckPodSecurityPolicyExistsByLabel returns true if one or more pod security policy objects matching the specified label exist.

func (*KubeClient) CheckSecretExists

func (k *KubeClient) CheckSecretExists(secretName string) (bool, error)

CheckSecretExists returns true if the Secret exists

func (*KubeClient) CheckServiceAccountExists

func (k *KubeClient) CheckServiceAccountExists(name, namespace string) (bool, error)

CheckServiceAccountExists returns true if a matching service account exists.

func (*KubeClient) CheckServiceAccountExistsByLabel

func (k *KubeClient) CheckServiceAccountExistsByLabel(label string, allNamespaces bool) (bool, string, error)

CheckServiceAccountExistsByLabel returns true if one or more service account objects matching the specified label exist.

func (*KubeClient) CheckServiceExistsByLabel

func (k *KubeClient) CheckServiceExistsByLabel(label string, allNamespaces bool) (bool, string, error)

CheckServiceExistsByLabel returns true if one or more service objects matching the specified label exist.

func (*KubeClient) CheckStatefulSetExistsByLabel

func (k *KubeClient) CheckStatefulSetExistsByLabel(label string, allNamespaces bool) (bool, string, error)

CheckStatefulSetExistsByLabel returns true if one or more statefulset objects matching the specified label exist.

func (*KubeClient) CreateCHAPSecret

func (k *KubeClient) CreateCHAPSecret(
	secretName, accountName, initiatorSecret, targetSecret string,
) (*v1.Secret, error)

CreateCHAPSecret creates a new Secret for iSCSI CHAP mutual authentication

func (*KubeClient) CreateConfigMapFromDirectory

func (k *KubeClient) CreateConfigMapFromDirectory(_, _, _ string) error

func (*KubeClient) CreateObjectByFile

func (k *KubeClient) CreateObjectByFile(filePath string) error

CreateObjectByFile creates one or more objects on the server from a YAML/JSON file at the specified path.

func (*KubeClient) CreateObjectByYAML

func (k *KubeClient) CreateObjectByYAML(yamlData string) error

CreateObjectByYAML creates one or more objects on the server from a YAML/JSON document.

func (*KubeClient) CreateSecret

func (k *KubeClient) CreateSecret(secret *v1.Secret) (*v1.Secret, error)

CreateSecret creates a new Secret

func (*KubeClient) DeleteCRD

func (k *KubeClient) DeleteCRD(crdName string) error

func (*KubeClient) DeleteCSIDriver

func (k *KubeClient) DeleteCSIDriver(name string) error

DeleteCSIDriver deletes a CSI Driver object matching the specified name

func (*KubeClient) DeleteCSIDriverByLabel

func (k *KubeClient) DeleteCSIDriverByLabel(label string) error

DeleteCSIDriverByLabel deletes a CSI Driver object matching the specified label in the namespace of the client.

func (*KubeClient) DeleteClusterRole

func (k *KubeClient) DeleteClusterRole(name string) error

DeleteClusterRole deletes a cluster role object matching the specified name

func (*KubeClient) DeleteClusterRoleBinding

func (k *KubeClient) DeleteClusterRoleBinding(name string) error

DeleteClusterRoleBinding deletes a cluster role binding object matching the specified name

func (*KubeClient) DeleteClusterRoleBindingByLabel

func (k *KubeClient) DeleteClusterRoleBindingByLabel(label string) error

DeleteClusterRoleBindingByLabel deletes a cluster role binding object matching the specified label in the namespace of the client.

func (*KubeClient) DeleteClusterRoleByLabel

func (k *KubeClient) DeleteClusterRoleByLabel(label string) error

DeleteClusterRoleByLabel deletes a cluster role object matching the specified label in the namespace of the client.

func (*KubeClient) DeleteConfigMapByLabel

func (k *KubeClient) DeleteConfigMapByLabel(label string) error

DeleteConfigMapByLabel deletes a configmap object matching the specified label

func (*KubeClient) DeleteDaemonSet

func (k *KubeClient) DeleteDaemonSet(name, namespace string, foreground bool) error

DeleteDeployment deletes a deployment object matching the specified name and namespace.

func (*KubeClient) DeleteDaemonSetByLabel

func (k *KubeClient) DeleteDaemonSetByLabel(label string) error

DeleteDaemonSetByLabel deletes a daemonset object matching the specified label in the namespace of the client.

func (*KubeClient) DeleteDaemonSetByLabelAndName

func (k *KubeClient) DeleteDaemonSetByLabelAndName(label, name string) error

DeleteDaemonSetByLabelAndName deletes a daemonset object matching the specified label and name in the namespace of the client.

func (*KubeClient) DeleteDeployment

func (k *KubeClient) DeleteDeployment(name, namespace string, foreground bool) error

DeleteDeployment deletes a deployment object matching the specified name and namespace.

func (*KubeClient) DeleteDeploymentByLabel

func (k *KubeClient) DeleteDeploymentByLabel(label string) error

DeleteDeploymentByLabel deletes a deployment object matching the specified label in the namespace of the client.

func (*KubeClient) DeleteObjectByFile

func (k *KubeClient) DeleteObjectByFile(filePath string, ignoreNotFound bool) error

DeleteObjectByFile deletes one or more objects on the server from a YAML/JSON file at the specified path.

func (*KubeClient) DeleteObjectByYAML

func (k *KubeClient) DeleteObjectByYAML(yamlData string, ignoreNotFound bool) error

DeleteObjectByYAML deletes one or more objects on the server from a YAML/JSON document.

func (*KubeClient) DeletePVByLabel

func (k *KubeClient) DeletePVByLabel(label string) error

func (*KubeClient) DeletePVCByLabel

func (k *KubeClient) DeletePVCByLabel(label string) error

func (*KubeClient) DeletePod

func (k *KubeClient) DeletePod(name, namespace string) error

DeletePod deletes a pod object matching the specified name and namespace

func (*KubeClient) DeletePodByLabel

func (k *KubeClient) DeletePodByLabel(label string) error

DeletePodByLabel deletes a pod object matching the specified label

func (*KubeClient) DeletePodSecurityPolicy

func (k *KubeClient) DeletePodSecurityPolicy(pspName string) error

DeletePodSecurityPolicy deletes a pod security policy object matching the specified PSP name.

func (*KubeClient) DeletePodSecurityPolicyByLabel

func (k *KubeClient) DeletePodSecurityPolicyByLabel(label string) error

DeletePodSecurityPolicyByLabel deletes a pod security policy object matching the specified label in the namespace of the client.

func (*KubeClient) DeleteResourceQuota

func (k *KubeClient) DeleteResourceQuota(name string) error

DeleteResourceQuota deletes a ResourceQuota by name.

func (*KubeClient) DeleteResourceQuotaByLabel

func (k *KubeClient) DeleteResourceQuotaByLabel(label string) error

DeleteResourceQuotaByLabel deletes a ResourceQuota by label.

func (*KubeClient) DeleteSecret

func (k *KubeClient) DeleteSecret(name, namespace string) error

DeleteSecret deletes the specified Secret by name and namespace

func (*KubeClient) DeleteSecretByLabel

func (k *KubeClient) DeleteSecretByLabel(label string) error

DeleteSecretByLabel deletes a secret object matching the specified label

func (*KubeClient) DeleteSecretDefault

func (k *KubeClient) DeleteSecretDefault(secretName string) error

DeleteSecret deletes the specified Secret

func (*KubeClient) DeleteService

func (k *KubeClient) DeleteService(name, namespace string) error

DeleteService deletes a Service object matching the specified name and namespace

func (*KubeClient) DeleteServiceAccount

func (k *KubeClient) DeleteServiceAccount(name, namespace string, foreground bool) error

DeleteServiceAccount deletes a service account object matching the specified name and namespace.

func (*KubeClient) DeleteServiceAccountByLabel

func (k *KubeClient) DeleteServiceAccountByLabel(label string) error

DeleteServiceAccountByLabel deletes a service account object matching the specified label in the namespace of the client.

func (*KubeClient) DeleteServiceByLabel

func (k *KubeClient) DeleteServiceByLabel(label string) error

DeleteServiceByLabel deletes a service object matching the specified label in the namespace of the client.

func (*KubeClient) DeleteStatefulSet

func (k *KubeClient) DeleteStatefulSet(name, namespace string) error

DeleteStatefulSet deletes a statefulset object matching the specified name and namespace.

func (*KubeClient) DeleteStatefulSetByLabel

func (k *KubeClient) DeleteStatefulSetByLabel(label string) error

DeleteStatefulSetByLabel deletes a statefulset object matching the specified label in the namespace of the client.

func (*KubeClient) Exec

func (k *KubeClient) Exec(podName, containerName string, commandArgs []string) ([]byte, error)

func (*KubeClient) Flavor

func (k *KubeClient) Flavor() OrchestratorFlavor

func (*KubeClient) FollowPodLogs

func (k *KubeClient) FollowPodLogs(pod, container, namespace string, logLineCallback LogLineCallback)

func (*KubeClient) GetCRD

func (*KubeClient) GetCRDClient

func (k *KubeClient) GetCRDClient() (*crdclient.Clientset, error)

func (*KubeClient) GetCSIDriverByLabel

func (k *KubeClient) GetCSIDriverByLabel(label string) (*storagev1.CSIDriver, error)

GetCSIDriverByLabel returns a CSI driver object matching the specified label if it is unique

func (*KubeClient) GetCSIDriversByLabel

func (k *KubeClient) GetCSIDriversByLabel(label string) ([]storagev1.CSIDriver, error)

GetCSIDriversByLabel returns all CSI driver objects matching the specified label

func (*KubeClient) GetClusterRoleBindingByLabel

func (k *KubeClient) GetClusterRoleBindingByLabel(label string) (*v13.ClusterRoleBinding, error)

GetClusterRoleBindingByLabel returns a cluster role binding object matching the specified label if it is unique

func (*KubeClient) GetClusterRoleBindingByLabelAndName

func (k *KubeClient) GetClusterRoleBindingByLabelAndName(label, clusterRoleBindingName string) (
	*v13.ClusterRoleBinding, error,
)

GetClusterRoleBindingByLabelAndName returns a cluster role binding object matching the specified label and name

func (*KubeClient) GetClusterRoleBindingsByLabel

func (k *KubeClient) GetClusterRoleBindingsByLabel(label string) ([]v13.ClusterRoleBinding, error)

GetClusterRoleBindingsByLabel returns all cluster role binding objects matching the specified label

func (*KubeClient) GetClusterRoleByLabel

func (k *KubeClient) GetClusterRoleByLabel(label string) (*v13.ClusterRole, error)

GetClusterRoleByLabel returns a cluster role object matching the specified label if it is unique

func (*KubeClient) GetClusterRoleByLabelAndName

func (k *KubeClient) GetClusterRoleByLabelAndName(label, clusterRoleName string) (*v13.ClusterRole, error)

GetClusterRoleByLabelAndName returns a cluster role object matching the specified label and name

func (*KubeClient) GetClusterRolesByLabel

func (k *KubeClient) GetClusterRolesByLabel(label string) ([]v13.ClusterRole, error)

GetClusterRoleByLabel returns all cluster role objects matching the specified label

func (*KubeClient) GetConfigMapByLabel

func (k *KubeClient) GetConfigMapByLabel(label string, allNamespaces bool) (*v1.ConfigMap, error)

GetConfigMapByLabel returns a configmap object matching the specified label if it is unique

func (*KubeClient) GetConfigMapsByLabel

func (k *KubeClient) GetConfigMapsByLabel(label string, allNamespaces bool) ([]v1.ConfigMap, error)

GetConfigMapsByLabel returns all configmap objects matching the specified label

func (*KubeClient) GetDaemonSetByLabel

func (k *KubeClient) GetDaemonSetByLabel(label string, allNamespaces bool) (*appsv1.DaemonSet, error)

GetDaemonSetByLabel returns a daemonset object matching the specified label if it is unique

func (*KubeClient) GetDaemonSetByLabelAndName

func (k *KubeClient) GetDaemonSetByLabelAndName(label, name string, allNamespaces bool) (*appsv1.DaemonSet,
	error,
)

GetDaemonSetByLabelAndName returns a daemonset object matching the specified label and name

func (*KubeClient) GetDaemonSetsByLabel

func (k *KubeClient) GetDaemonSetsByLabel(label string, allNamespaces bool) ([]appsv1.DaemonSet, error)

GetDaemonSetsByLabel returns all daemonset objects matching the specified label

func (*KubeClient) GetDeploymentByLabel

func (k *KubeClient) GetDeploymentByLabel(label string, allNamespaces bool) (*appsv1.Deployment, error)

GetDeploymentByLabel returns a deployment object matching the specified label if it is unique

func (*KubeClient) GetDeploymentsByLabel

func (k *KubeClient) GetDeploymentsByLabel(label string, allNamespaces bool) ([]appsv1.Deployment, error)

GetDeploymentByLabel returns all deployment objects matching the specified label

func (*KubeClient) GetNamespace

func (k *KubeClient) GetNamespace(namespace string) (*v1.Namespace, error)

func (*KubeClient) GetOpenShiftSCCByName

func (k *KubeClient) GetOpenShiftSCCByName(user, scc string) (bool, bool, []byte, error)

GetOpenShiftSCCByName gets the specified user (typically a service account) from the specified security context constraint. This only works for OpenShift, and it must be idempotent.

func (*KubeClient) GetPV

func (k *KubeClient) GetPV(pvName string) (*v1.PersistentVolume, error)

func (*KubeClient) GetPVByLabel

func (k *KubeClient) GetPVByLabel(label string) (*v1.PersistentVolume, error)

func (*KubeClient) GetPVC

func (k *KubeClient) GetPVC(pvcName string) (*v1.PersistentVolumeClaim, error)

func (*KubeClient) GetPVCByLabel

func (k *KubeClient) GetPVCByLabel(label string, allNamespaces bool) (*v1.PersistentVolumeClaim, error)

func (*KubeClient) GetPodByLabel

func (k *KubeClient) GetPodByLabel(label string, allNamespaces bool) (*v1.Pod, error)

GetPodByLabel returns a pod object matching the specified label

func (*KubeClient) GetPodSecurityPoliciesByLabel

func (k *KubeClient) GetPodSecurityPoliciesByLabel(label string) ([]v1beta1.PodSecurityPolicy,
	error,
)

GetPodSecurityPoliciesByLabel returns all pod security policy objects matching the specified label

func (*KubeClient) GetPodSecurityPolicyByLabel

func (k *KubeClient) GetPodSecurityPolicyByLabel(label string) (*v1beta1.PodSecurityPolicy, error)

GetPodSecurityPolicyByLabel returns a pod security policy object matching the specified label if it is unique

func (*KubeClient) GetPodsByLabel

func (k *KubeClient) GetPodsByLabel(label string, allNamespaces bool) ([]v1.Pod, error)

GetPodsByLabel returns all pod objects matching the specified label

func (*KubeClient) GetResourceQuota

func (k *KubeClient) GetResourceQuota(name string) (*v1.ResourceQuota, error)

GetResourceQuota returns a ResourceQuota by name.

func (*KubeClient) GetResourceQuotaByLabel

func (k *KubeClient) GetResourceQuotaByLabel(label string) (*v1.ResourceQuota, error)

GetResourceQuotaByLabel returns a ResourceQuota by label.

func (*KubeClient) GetResourceQuotasByLabel

func (k *KubeClient) GetResourceQuotasByLabel(label string) ([]v1.ResourceQuota, error)

GetResourceQuotasByLabel returns all ResourceQuotas matching a given label.

func (*KubeClient) GetSecret

func (k *KubeClient) GetSecret(secretName string) (*v1.Secret, error)

GetSecret looks up a Secret by name

func (*KubeClient) GetSecretByLabel

func (k *KubeClient) GetSecretByLabel(label string, allNamespaces bool) (*v1.Secret, error)

GetSecretByLabel looks up a Secret by label

func (*KubeClient) GetSecretsByLabel

func (k *KubeClient) GetSecretsByLabel(label string, allNamespaces bool) ([]v1.Secret, error)

GetSecretsByLabel returns all secret object matching specified label

func (*KubeClient) GetServiceAccountByLabel

func (k *KubeClient) GetServiceAccountByLabel(label string, allNamespaces bool) (*v1.ServiceAccount, error)

GetServiceAccountByLabel returns a service account object matching the specified label if it is unique

func (*KubeClient) GetServiceAccountByLabelAndName

func (k *KubeClient) GetServiceAccountByLabelAndName(label, serviceAccountName string, allNamespaces bool) (
	*v1.ServiceAccount, error,
)

GetServiceAccountByLabelAndName returns a service account object matching the specified label and name

func (*KubeClient) GetServiceAccountsByLabel

func (k *KubeClient) GetServiceAccountsByLabel(label string, allNamespaces bool) ([]v1.ServiceAccount, error)

GetServiceAccountsByLabel returns all service account objects matching the specified label

func (*KubeClient) GetServiceByLabel

func (k *KubeClient) GetServiceByLabel(label string, allNamespaces bool) (*v1.Service, error)

GetServiceByLabel returns a service object matching the specified label if it is unique

func (*KubeClient) GetServicesByLabel

func (k *KubeClient) GetServicesByLabel(label string, allNamespaces bool) ([]v1.Service, error)

GetServicesByLabel returns all service objects matching the specified label

func (*KubeClient) GetSnapshotterCRDVersion

func (k *KubeClient) GetSnapshotterCRDVersion() (snapshotterCRDVersion string)

func (*KubeClient) GetStatefulSetByLabel

func (k *KubeClient) GetStatefulSetByLabel(label string, allNamespaces bool) (*appsv1.StatefulSet, error)

GetStatefulSetByLabel returns a statefulset object matching the specified label if it is unique

func (*KubeClient) GetStatefulSetsByLabel

func (k *KubeClient) GetStatefulSetsByLabel(label string, allNamespaces bool) ([]appsv1.StatefulSet, error)

GetStatefulSetsByLabel returns all stateful objects matching the specified label

func (*KubeClient) IsTopologyInUse

func (k *KubeClient) IsTopologyInUse() (bool, error)

func (*KubeClient) Namespace

func (k *KubeClient) Namespace() string

func (*KubeClient) PatchCRD

func (k *KubeClient) PatchCRD(crdName string, patchBytes []byte, patchType types.PatchType) error

PatchCRD patches a CRD with a supplied YAML/JSON document in []byte format.

func (*KubeClient) PatchCSIDriverByLabel

func (k *KubeClient) PatchCSIDriverByLabel(label string, patchBytes []byte, patchType types.PatchType) error

PatchCSIDriverByLabel patches a deployment object matching the specified label in the namespace of the client.

func (*KubeClient) PatchClusterRoleBindingByLabel

func (k *KubeClient) PatchClusterRoleBindingByLabel(label string, patchBytes []byte, patchType types.PatchType) error

PatchClusterRoleBindingByLabel patches a Cluster Role binding object matching the specified label in the namespace of the client.

func (*KubeClient) PatchClusterRoleBindingByLabelAndName

func (k *KubeClient) PatchClusterRoleBindingByLabelAndName(label, clusterRoleBindingName string, patchBytes []byte,
	patchType types.PatchType,
) error

PatchClusterRoleBindingByLabelAndName patches a Cluster Role binding object matching the specified label and name in the namespace of the client.

func (*KubeClient) PatchClusterRoleByLabel

func (k *KubeClient) PatchClusterRoleByLabel(label string, patchBytes []byte, patchType types.PatchType) error

PatchClusterRoleByLabel patches a Cluster Role object matching the specified label in the namespace of the client.

func (*KubeClient) PatchClusterRoleByLabelAndName

func (k *KubeClient) PatchClusterRoleByLabelAndName(label, clusterRoleName string, patchBytes []byte,
	patchType types.PatchType,
) error

PatchClusterRoleByLabelAndName patches a Cluster Role object matching the specified label and name in the namespace of the client.

func (*KubeClient) PatchDaemonSetByLabel

func (k *KubeClient) PatchDaemonSetByLabel(label string, patchBytes []byte, patchType types.PatchType) error

PatchDaemonSetByLabel patches a DaemonSet object matching the specified label in the namespace of the client.

func (*KubeClient) PatchDaemonSetByLabelAndName

func (k *KubeClient) PatchDaemonSetByLabelAndName(
	label, daemonSetName string, patchBytes []byte, patchType types.PatchType,
) error

PatchDaemonSetByLabelAndName patches a DaemonSet object matching the specified label and name in the namespace of the client.

func (*KubeClient) PatchDeploymentByLabel

func (k *KubeClient) PatchDeploymentByLabel(label string, patchBytes []byte, patchType types.PatchType) error

PatchDeploymentByLabel patches a deployment object matching the specified label in the namespace of the client.

func (*KubeClient) PatchNamespace

func (k *KubeClient) PatchNamespace(namespace string, patchBytes []byte, patchType types.PatchType) error

PatchNamespace patches the namespace with matching name

func (*KubeClient) PatchNamespaceLabels

func (k *KubeClient) PatchNamespaceLabels(namespace string, labels map[string]string) error

PatchNamespaceLabels patches the namespace with provided labels

func (*KubeClient) PatchOpenShiftSCC

func (k *KubeClient) PatchOpenShiftSCC(newJSONData []byte) error

PatchOpenShiftSCC patches the specified user (typically a service account) from the specified security context constraint. This only works for OpenShift, and it must be idempotent.

func (*KubeClient) PatchPodSecurityPolicyByLabel

func (k *KubeClient) PatchPodSecurityPolicyByLabel(label string, patchBytes []byte, patchType types.PatchType) error

PatchPodSecurityPolicyByLabel patches a pod security policy object matching the specified label in the namespace of the client.

func (*KubeClient) PatchResourceQuotaByLabel

func (k *KubeClient) PatchResourceQuotaByLabel(label string, patchBytes []byte, patchType types.PatchType) error

PatchResourceQuotaByLabel patches a ResourceQuota object matching a given label in the client namespace.

func (*KubeClient) PatchSecretByLabel

func (k *KubeClient) PatchSecretByLabel(label string, patchBytes []byte, patchType types.PatchType) error

PatchPodSecurityPolicyByLabel patches a pod security policy object matching the specified label in the namespace of the client.

func (*KubeClient) PatchServiceAccountByLabel

func (k *KubeClient) PatchServiceAccountByLabel(label string, patchBytes []byte, patchType types.PatchType) error

PatchServiceAccountByLabel patches a Service Account object matching the specified label in the namespace of the client.

func (*KubeClient) PatchServiceAccountByLabelAndName

func (k *KubeClient) PatchServiceAccountByLabelAndName(label, serviceAccountName string, patchBytes []byte,
	patchType types.PatchType,
) error

PatchServiceAccountByLabelAndName patches a Service Account object matching the specified label and name in the namespace of the client.

func (*KubeClient) PatchServiceByLabel

func (k *KubeClient) PatchServiceByLabel(label string, patchBytes []byte, patchType types.PatchType) error

PatchServiceByLabel patches a deployment object matching the specified label in the namespace of the client.

func (*KubeClient) RemoveFinalizerFromCRD

func (k *KubeClient) RemoveFinalizerFromCRD(crdName string) error

RemoveFinalizerFromCRD updates the CRD object to remove all finalizers (definitions are not namespaced)

func (*KubeClient) RemoveTridentUserFromOpenShiftSCC

func (k *KubeClient) RemoveTridentUserFromOpenShiftSCC(user, scc string) error

RemoveTridentUserFromOpenShiftSCC removes the specified user (typically a service account) from the 'anyuid' security context constraint. This only works for OpenShift, and it must be idempotent.

func (*KubeClient) ServerVersion

func (k *KubeClient) ServerVersion() *utils.Version

func (*KubeClient) SetNamespace

func (k *KubeClient) SetNamespace(namespace string)

func (*KubeClient) SetTimeout

func (k *KubeClient) SetTimeout(timeout time.Duration)

func (*KubeClient) UpdateSecret

func (k *KubeClient) UpdateSecret(secret *v1.Secret) (*v1.Secret, error)

UpdateSecret updates an existing Secret

func (*KubeClient) Version

func (k *KubeClient) Version() *version.Info

type KubernetesClient

type KubernetesClient interface {
	Version() *version.Info
	ServerVersion() *utils.Version
	Namespace() string
	SetNamespace(namespace string)
	SetTimeout(time.Duration)
	Flavor() OrchestratorFlavor
	CLI() string
	Exec(podName, containerName string, commandArgs []string) ([]byte, error)
	GetDeploymentByLabel(label string, allNamespaces bool) (*appsv1.Deployment, error)
	GetDeploymentsByLabel(label string, allNamespaces bool) ([]appsv1.Deployment, error)
	CheckDeploymentExists(name, namespace string) (bool, error)
	CheckDeploymentExistsByLabel(label string, allNamespaces bool) (bool, string, error)
	DeleteDeploymentByLabel(label string) error
	DeleteDeployment(name, namespace string, foreground bool) error
	PatchDeploymentByLabel(label string, patchBytes []byte, patchType types.PatchType) error
	GetServiceByLabel(label string, allNamespaces bool) (*v1.Service, error)
	GetServicesByLabel(label string, allNamespaces bool) ([]v1.Service, error)
	CheckServiceExistsByLabel(label string, allNamespaces bool) (bool, string, error)
	DeleteServiceByLabel(label string) error
	DeleteService(name, namespace string) error
	PatchServiceByLabel(label string, patchBytes []byte, patchType types.PatchType) error
	GetStatefulSetByLabel(label string, allNamespaces bool) (*appsv1.StatefulSet, error)
	GetStatefulSetsByLabel(label string, allNamespaces bool) ([]appsv1.StatefulSet, error)
	CheckStatefulSetExistsByLabel(label string, allNamespaces bool) (bool, string, error)
	DeleteStatefulSetByLabel(label string) error
	DeleteStatefulSet(name, namespace string) error
	GetDaemonSetByLabel(label string, allNamespaces bool) (*appsv1.DaemonSet, error)
	GetDaemonSetByLabelAndName(label, name string, allNamespaces bool) (*appsv1.DaemonSet, error)
	GetDaemonSetsByLabel(label string, allNamespaces bool) ([]appsv1.DaemonSet, error)
	CheckDaemonSetExists(name, namespace string) (bool, error)
	CheckDaemonSetExistsByLabel(label string, allNamespaces bool) (bool, string, error)
	DeleteDaemonSetByLabel(label string) error
	DeleteDaemonSetByLabelAndName(label, name string) error
	DeleteDaemonSet(name, namespace string, foreground bool) error
	PatchDaemonSetByLabel(label string, patchBytes []byte, patchType types.PatchType) error
	PatchDaemonSetByLabelAndName(label, daemonSetName string, patchBytes []byte, patchType types.PatchType) error
	GetConfigMapByLabel(label string, allNamespaces bool) (*v1.ConfigMap, error)
	GetConfigMapsByLabel(label string, allNamespaces bool) ([]v1.ConfigMap, error)
	CheckConfigMapExistsByLabel(label string, allNamespaces bool) (bool, string, error)
	DeleteConfigMapByLabel(label string) error
	CreateConfigMapFromDirectory(path, name, label string) error
	GetPodByLabel(label string, allNamespaces bool) (*v1.Pod, error)
	GetPodsByLabel(label string, allNamespaces bool) ([]v1.Pod, error)
	CheckPodExistsByLabel(label string, allNamespaces bool) (bool, string, error)
	DeletePodByLabel(label string) error
	DeletePod(name, namespace string) error
	GetPVC(pvcName string) (*v1.PersistentVolumeClaim, error)
	GetPVCByLabel(label string, allNamespaces bool) (*v1.PersistentVolumeClaim, error)
	CheckPVCExists(pvcName string) (bool, error)
	CheckPVCBound(pvcName string) (bool, error)
	DeletePVCByLabel(label string) error
	GetPV(pvName string) (*v1.PersistentVolume, error)
	GetPVByLabel(label string) (*v1.PersistentVolume, error)
	CheckPVExists(pvName string) (bool, error)
	DeletePVByLabel(label string) error
	GetCRD(crdName string) (*apiextensionv1.CustomResourceDefinition, error)
	CheckCRDExists(crdName string) (bool, error)
	PatchCRD(crdName string, patchBytes []byte, patchType types.PatchType) error
	DeleteCRD(crdName string) error
	GetPodSecurityPolicyByLabel(label string) (*v1beta1.PodSecurityPolicy, error)
	GetPodSecurityPoliciesByLabel(label string) ([]v1beta1.PodSecurityPolicy, error)
	CheckPodSecurityPolicyExistsByLabel(label string) (bool, string, error)
	DeletePodSecurityPolicyByLabel(label string) error
	DeletePodSecurityPolicy(pspName string) error
	PatchPodSecurityPolicyByLabel(label string, patchBytes []byte, patchType types.PatchType) error
	GetServiceAccountByLabel(label string, allNamespaces bool) (*v1.ServiceAccount, error)
	GetServiceAccountByLabelAndName(label, serviceAccountName string, allNamespaces bool) (*v1.ServiceAccount, error)
	GetServiceAccountsByLabel(label string, allNamespaces bool) ([]v1.ServiceAccount, error)
	CheckServiceAccountExistsByLabel(label string, allNamespaces bool) (bool, string, error)
	DeleteServiceAccountByLabel(label string) error
	DeleteServiceAccount(name, namespace string, foreground bool) error
	PatchServiceAccountByLabel(label string, patchBytes []byte, patchType types.PatchType) error
	PatchServiceAccountByLabelAndName(label, serviceAccountName string, patchBytes []byte, patchType types.PatchType) error
	GetClusterRoleByLabelAndName(label, clusterRoleName string) (*v13.ClusterRole, error)
	GetClusterRoleByLabel(label string) (*v13.ClusterRole, error)
	GetClusterRolesByLabel(label string) ([]v13.ClusterRole, error)
	CheckClusterRoleExistsByLabel(label string) (bool, string, error)
	DeleteClusterRoleByLabel(label string) error
	DeleteClusterRole(name string) error
	PatchClusterRoleByLabel(label string, patchBytes []byte, patchType types.PatchType) error
	PatchClusterRoleByLabelAndName(label, clusterRoleName string, patchBytes []byte, patchType types.PatchType) error
	GetClusterRoleBindingByLabelAndName(label, clusterRoleBindingName string) (*v13.ClusterRoleBinding, error)
	GetClusterRoleBindingByLabel(label string) (*v13.ClusterRoleBinding, error)
	GetClusterRoleBindingsByLabel(label string) ([]v13.ClusterRoleBinding, error)
	CheckClusterRoleBindingExistsByLabel(label string) (bool, string, error)
	DeleteClusterRoleBindingByLabel(label string) error
	DeleteClusterRoleBinding(name string) error
	PatchClusterRoleBindingByLabel(label string, patchBytes []byte, patchType types.PatchType) error
	PatchClusterRoleBindingByLabelAndName(label, clusterRoleBindingName string, patchBytes []byte, patchType types.PatchType) error
	GetCSIDriverByLabel(label string) (*storagev1.CSIDriver, error)
	GetCSIDriversByLabel(label string) ([]storagev1.CSIDriver, error)
	CheckCSIDriverExistsByLabel(label string) (bool, string, error)
	DeleteCSIDriverByLabel(label string) error
	DeleteCSIDriver(name string) error
	PatchCSIDriverByLabel(label string, patchBytes []byte, patchType types.PatchType) error
	CheckNamespaceExists(namespace string) (bool, error)
	PatchNamespaceLabels(namespace string, labels map[string]string) error
	PatchNamespace(namespace string, patchBytes []byte, patchType types.PatchType) error
	GetNamespace(namespace string) (*v1.Namespace, error)
	CreateSecret(secret *v1.Secret) (*v1.Secret, error)
	UpdateSecret(secret *v1.Secret) (*v1.Secret, error)
	CreateCHAPSecret(secretName, accountName, initiatorSecret, targetSecret string) (*v1.Secret, error)
	GetSecret(secretName string) (*v1.Secret, error)
	GetSecretByLabel(label string, allNamespaces bool) (*v1.Secret, error)
	GetSecretsByLabel(label string, allNamespaces bool) ([]v1.Secret, error)
	CheckSecretExists(secretName string) (bool, error)
	DeleteSecretDefault(secretName string) error
	DeleteSecretByLabel(label string) error
	DeleteSecret(name, namespace string) error
	PatchSecretByLabel(label string, patchBytes []byte, patchType types.PatchType) error
	GetResourceQuota(label string) (*v1.ResourceQuota, error)
	GetResourceQuotaByLabel(label string) (*v1.ResourceQuota, error)
	GetResourceQuotasByLabel(label string) ([]v1.ResourceQuota, error)
	DeleteResourceQuota(name string) error
	DeleteResourceQuotaByLabel(label string) error
	PatchResourceQuotaByLabel(label string, patchBytes []byte, patchType types.PatchType) error
	CreateObjectByFile(filePath string) error
	CreateObjectByYAML(yaml string) error
	DeleteObjectByFile(filePath string, ignoreNotFound bool) error
	DeleteObjectByYAML(yaml string, ignoreNotFound bool) error
	RemoveTridentUserFromOpenShiftSCC(user, scc string) error
	GetOpenShiftSCCByName(user, scc string) (bool, bool, []byte, error)
	PatchOpenShiftSCC(newJSONData []byte) error
	FollowPodLogs(pod, container, namespace string, logLineCallback LogLineCallback)
	AddFinalizerToCRD(crdName string) error
	AddFinalizerToCRDs(CRDnames []string) error
	RemoveFinalizerFromCRD(crdName string) error
	GetCRDClient() (*crdclient.Clientset, error)
	IsTopologyInUse() (bool, error)
	GetSnapshotterCRDVersion() string
}

func NewFakeKubeClient

func NewFakeKubeClient() (KubernetesClient, error)

func NewKubeClient

func NewKubeClient(config *rest.Config, namespace string, k8sTimeout time.Duration) (KubernetesClient, error)

type LogLineCallback

type LogLineCallback func(string)

type OrchestratorFlavor

type OrchestratorFlavor string

Jump to

Keyboard shortcuts

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