k8s

package
v0.0.0-...-3e7914a Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2025 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Namespace is the default namespace
	Namespace = "openebs"
	// WaitDuration is the default wait duration
	WaitDuration time.Duration = 5 * time.Second
	// Running is the active/running status of pod
	Running = "Running"
)

Variables

This section is empty.

Functions

func GetClusterRole

func GetClusterRole() (rbacv1.ClusterRole, error)

GetClusterRole generates the ClusterRole object from the yaml file

func GetClusterRoleBinding

func GetClusterRoleBinding() (rbacv1.ClusterRoleBinding, error)

GetClusterRoleBinding generates the ClusterRoleBinding object from the yaml file

func GetConfigMap

func GetConfigMap() (v1.ConfigMap, error)

GetConfigMap generates the ConfigMap object for NDM from the yaml file

func GetCustomResourceDefinition

func GetCustomResourceDefinition(crdyaml NDMYaml) (apiextensionsV1.CustomResourceDefinition, error)

GetCustomResourceDefinition generates the CustomResourceDefinition object from the specified YAML file

func GetDaemonSet

func GetDaemonSet() (appsv1.DaemonSet, error)

GetDaemonSet generates the NDM DaemonSet object from the yaml file

func GetDeployment

func GetDeployment() (appsv1.Deployment, error)

GetDeployment generates the NDO Deployment object from the yaml file

func GetNamespace

func GetNamespace() (v1.Namespace, error)

GetNamespace generates the openebs namespace object from yaml file

func GetServiceAccount

func GetServiceAccount() (v1.ServiceAccount, error)

GetServiceAccount generates the ServiceAccount object from the yaml file

func NewBDC

func NewBDC(bdcName string) *apis.BlockDeviceClaim

NewBDC creates a sample device claim which can be used for claiming a block device.

func WaitForReconciliation

func WaitForReconciliation()

WaitForReconciliation sleeps the process for a fixed duration so that the reconcile loop can run and fetch the required changes

func WaitForStateChange

func WaitForStateChange()

WaitForStateChange sleeps the process for a fixed Duration so that the state changes get written in etcd and we get the updated result

Types

type K8sClient

type K8sClient struct {
	ClientSet     *kubernetes.Clientset
	APIextClient  *apiextensionsclient.Clientset
	RunTimeClient client.Client
	// contains filtered or unexported fields
}

K8sClient is the client used for etcd operations

func GetClientSet

func GetClientSet() (K8sClient, error)

GetClientSet generates the client-set from the config file on the host Three clients are generated by the function:

  1. Client-set from client-go which is used for operations on pods/nodes and other first-class k8s objects. While using runtime client for this operations, the podList etc retrieved were not up-to-date
  2. Client from apiextensions which is used for CRUD operations on CRDs
  3. Runtime client from the controller-runtime which will be used for CRUD operations related to custom resources

func (K8sClient) CreateBlockDeviceClaim

func (c K8sClient) CreateBlockDeviceClaim(claim *apis.BlockDeviceClaim) error

CreateBlockDeviceClaim creates a BDC

func (K8sClient) CreateClusterRole

func (c K8sClient) CreateClusterRole(clusterRole rbacv1.ClusterRole) error

CreateClusterRole creates a cluster role

func (K8sClient) CreateClusterRoleBinding

func (c K8sClient) CreateClusterRoleBinding(clusterRoleBinding rbacv1.ClusterRoleBinding) error

CreateClusterRoleBinding creates a rolebinding

func (K8sClient) CreateConfigMap

func (c K8sClient) CreateConfigMap(configMap corev1.ConfigMap) error

CreateConfigMap creates a config map

func (K8sClient) CreateCustomResourceDefinition

func (c K8sClient) CreateCustomResourceDefinition(customResourceDefinition apiextensionsV1.CustomResourceDefinition) error

CreateCustomResourceDefinition creates a CRD

func (K8sClient) CreateDaemonSet

func (c K8sClient) CreateDaemonSet(daemonset appsv1.DaemonSet) error

CreateDaemonSet creates a Daemonset

func (K8sClient) CreateDeployment

func (c K8sClient) CreateDeployment(deployment appsv1.Deployment) error

CreateDeployment creates a deployment

func (K8sClient) CreateNDMBlockDeviceCRD

func (c K8sClient) CreateNDMBlockDeviceCRD() error

CreateNDMBlockDeviceCRD creates the CustomResourceDefinition for a Device type

func (K8sClient) CreateNDMBlockDeviceClaimCRD

func (c K8sClient) CreateNDMBlockDeviceClaimCRD() error

CreateNDMBlockDeviceClaimCRD creates the CustomResourceDefinition for a BlockDeviceClaim type

func (K8sClient) CreateNDMCRDs

func (c K8sClient) CreateNDMCRDs() error

CreateNDMCRDs creates the Disk, BlockDevice and BlockDeviceClaim CRDs

func (K8sClient) CreateNDMClusterRole

func (c K8sClient) CreateNDMClusterRole() error

CreateNDMClusterRole creates the ClusterRole required for NDM

func (K8sClient) CreateNDMClusterRoleBinding

func (c K8sClient) CreateNDMClusterRoleBinding() error

CreateNDMClusterRoleBinding creates the role binding required by NDM

func (K8sClient) CreateNDMConfigMap

func (c K8sClient) CreateNDMConfigMap() error

CreateNDMConfigMap creates the ConfigMap required for NDM

func (K8sClient) CreateNDMDaemonSet

func (c K8sClient) CreateNDMDaemonSet() error

CreateNDMDaemonSet creates the NDM Daemonset

func (K8sClient) CreateNDMOperatorDeployment

func (c K8sClient) CreateNDMOperatorDeployment() error

CreateNDMOperatorDeployment creates the NDM Operator

func (K8sClient) CreateNDMServiceAccount

func (c K8sClient) CreateNDMServiceAccount() error

CreateNDMServiceAccount creates the ServiceAccount required for NDM

func (K8sClient) CreateNamespace

func (c K8sClient) CreateNamespace(namespace corev1.Namespace) error

CreateNamespace creates a namespace

func (K8sClient) CreateOpenEBSNamespace

func (c K8sClient) CreateOpenEBSNamespace() error

CreateOpenEBSNamespace creates the openebs namespace required for NDM installation

func (K8sClient) CreateServiceAccount

func (c K8sClient) CreateServiceAccount(serviceAccount corev1.ServiceAccount) error

CreateServiceAccount creates a service account

func (K8sClient) DeleteBlockDeviceClaim

func (c K8sClient) DeleteBlockDeviceClaim(claim *apis.BlockDeviceClaim) error

DeleteBlockDeviceClaim deletes a BDC

func (K8sClient) DeleteClusterRole

func (c K8sClient) DeleteClusterRole(clusterRole rbacv1.ClusterRole) error

DeleteClusterRole deletes the cluster role

func (K8sClient) DeleteClusterRoleBinding

func (c K8sClient) DeleteClusterRoleBinding(clusterrolebinding rbacv1.ClusterRoleBinding) error

DeleteClusterRoleBinding deletes the role binding

func (K8sClient) DeleteConfigMap

func (c K8sClient) DeleteConfigMap(configMap corev1.ConfigMap) error

DeleteConfigMap deletes the config map

func (K8sClient) DeleteCustomResourceDefinition

func (c K8sClient) DeleteCustomResourceDefinition(customResourceDefinition apiextensionsV1.CustomResourceDefinition) error

DeleteCustomResourceDefinition deletes the CRD

func (K8sClient) DeleteDaemonSet

func (c K8sClient) DeleteDaemonSet(daemonset appsv1.DaemonSet) error

DeleteDaemonSet deletes the Daemonset

func (K8sClient) DeleteDeployment

func (c K8sClient) DeleteDeployment(deployment appsv1.Deployment) error

DeleteDeployment deletes a deployment

func (K8sClient) DeleteNDMBlockDeviceCRD

func (c K8sClient) DeleteNDMBlockDeviceCRD() error

DeleteNDMBlockDeviceCRD deletes the CustomResourceDefinition for a Device type

func (K8sClient) DeleteNDMBlockDeviceClaimCRD

func (c K8sClient) DeleteNDMBlockDeviceClaimCRD() error

DeleteNDMBlockDeviceClaimCRD deletes the CustomResourceDefinition for a BlockDeviceClaim type

func (K8sClient) DeleteNDMCRDs

func (c K8sClient) DeleteNDMCRDs() error

DeleteNDMCRDs deletes the disk, blockdevice and blockdevice claim CRDs

func (K8sClient) DeleteNDMClusterRole

func (c K8sClient) DeleteNDMClusterRole() error

DeleteNDMClusterRole deletes the ClusterRole required for NDM

func (K8sClient) DeleteNDMClusterRoleBinding

func (c K8sClient) DeleteNDMClusterRoleBinding() error

DeleteNDMClusterRoleBinding deletes the role binding required by NDM

func (K8sClient) DeleteNDMConfigMap

func (c K8sClient) DeleteNDMConfigMap() error

DeleteNDMConfigMap deletes the ConfigMap required for NDM

func (K8sClient) DeleteNDMDaemonSet

func (c K8sClient) DeleteNDMDaemonSet() error

DeleteNDMDaemonSet deletes the NDM Daemonset

func (K8sClient) DeleteNDMOperatorDeployment

func (c K8sClient) DeleteNDMOperatorDeployment() error

DeleteNDMOperatorDeployment deletes the NDM operator

func (K8sClient) DeleteNDMServiceAccount

func (c K8sClient) DeleteNDMServiceAccount() error

DeleteNDMServiceAccount deletes the ServiceAccount required for NDM

func (K8sClient) DeleteNamespace

func (c K8sClient) DeleteNamespace(namespace corev1.Namespace) error

DeleteNamespace deletes a namespace

func (K8sClient) DeleteOpenEBSNamespace

func (c K8sClient) DeleteOpenEBSNamespace() error

DeleteOpenEBSNamespace deletes the openebs namespace in which NDM was installed

func (K8sClient) DeleteServiceAccount

func (c K8sClient) DeleteServiceAccount(serviceAccount corev1.ServiceAccount) error

DeleteServiceAccount deletes the service account

func (K8sClient) GetBlockDevice

func (c K8sClient) GetBlockDevice(Name, Namesapce string) (*apis.BlockDevice, error)

GetBlockDevice with Name in Namespace

func (K8sClient) GetBlockDeviceClaim

func (c K8sClient) GetBlockDeviceClaim(NameSpace, Name string) (*apis.BlockDeviceClaim, error)

GetBlockDeviceClaim from Namespace and name

func (K8sClient) ListBlockDeviceClaims

func (c K8sClient) ListBlockDeviceClaims() (*apis.BlockDeviceClaimList, error)

ListBlockDeviceClaims returns list of BlockDeviceClaims in the cluster

func (K8sClient) ListBlockDevices

func (c K8sClient) ListBlockDevices() (*apis.BlockDeviceList, error)

ListBlockDevices returns list of BlockDeviceCR in the cluster

func (K8sClient) ListNodeStatus

func (c K8sClient) ListNodeStatus() (map[string]string, error)

ListNodeStatus returns list of all nodes(node name) in the cluster along with their status

func (K8sClient) ListPodStatus

func (c K8sClient) ListPodStatus() (map[string]string, error)

ListPodStatus returns the list of all pods in the given Namespace along with their status

func (*K8sClient) RegenerateClient

func (k *K8sClient) RegenerateClient() error

func (K8sClient) RestartPod

func (c K8sClient) RestartPod(name string) error

RestartPod the given pod

func (K8sClient) UpdateBlockDeviceClaim

func (c K8sClient) UpdateBlockDeviceClaim(claim *apis.BlockDeviceClaim) error

UpdateBlockDeviceClaim updates the BDC

type NDMYaml

type NDMYaml string

NDMYaml is a string type that stores the path to the YAML files which are required to deploy NDM

const (
	ConfigMapYAML           NDMYaml = "../yamls/node-disk-manager-config.yaml"
	ServiceAccountYAML      NDMYaml = "../../deploy/yamls/serviceaccount.yaml"
	ClusterRoleYAML         NDMYaml = "../../deploy/yamls/clusterrole.yaml"
	ClusterRoleBindingYAML  NDMYaml = "../../deploy/yamls/clusterrolebinding.yaml"
	BlockDeviceCRDYAML      NDMYaml = "../../deploy/crds/openebs.io_blockdevices.yaml"
	BlockDeviceClaimCRDYAML NDMYaml = "../../deploy/crds/openebs.io_blockdeviceclaims.yaml"
	DaemonSetYAML           NDMYaml = "../yamls/node-disk-manager.yaml"
	DeploymentYAML          NDMYaml = "../../deploy/yamls/node-disk-operator.yaml"
	OpenEBSNamespaceYAML    NDMYaml = "../../deploy/yamls/namespace.yaml"
)

Path to various YAMLs used for integration testing

Jump to

Keyboard shortcuts

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