utils

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2024 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CAPIObjectVersion   = "v1beta1"
	CAPVCDObjectVersion = "v1beta2"
	FieldManager        = "rdeProjector"
)
View Source
const (
	VCDCluster          = "VCDCluster"
	MachineDeployment   = "MachineDeployment"
	Cluster             = "Cluster"
	KubeadmControlPlane = "KubeadmControlPlane"
	VCDMachineTemplate  = "VCDMachineTemplate"
	SECRET              = "Secret"
)

Variables

This section is empty.

Functions

func ApplyCAPIYaml

func ApplyCAPIYaml(ctx context.Context, r runtimeclient.Client, yamlContent []byte) error

ApplyCAPIYaml applies the Kubernetes YAML content to create objects using the provided runtime client. It reads the YAML content, decodes each object, and creates them in the cluster using the runtime client. If an error occurs during decoding or creation, it returns the error.

func ApplyK8sVersionUpgrade

func ApplyK8sVersionUpgrade(ctx context.Context, r runtimeclient.Client, capiYaml string, tkgMapKey string, tkgMap map[string]interface{}, vappTemplate *types.QueryResultVappTemplateType) (string, error)

ApplyK8sVersionUpgrade returns a new capiyaml with the target state that the cluster should have after upgrading to the specified TKG and Kubernetes version.

Parameters: - capiYaml: The cluster's current capiyaml. - tkgMapKey: The key to a specific upgrade path in tkg_map.json. - tkgMap: The tkg_map.json marshalled into a map[string]interface{}. - vappTemplate: The vApp Template that matches the specific upgrade path.

Returns: - string: The Kubernetes version that the cluster is being upgraded to. - error: nil if there is no error, otherwise the encountered error.

func CheckRdeEntityNonExisted

func CheckRdeEntityNonExisted(ctx context.Context, client *vcdsdk.Client, rdeID, clusterName string) error

func ConstructCAPVCDTestClient

func ConstructCAPVCDTestClient(ctx context.Context, vcdCluster *v1beta2.VCDCluster, workloadClientSet *kubernetes.Clientset, capiYaml, clusterNameSpace, clusterName, rdeId string, getVdcClient bool) (*testingsdk.TestClient, error)

func CreateAuthSecret

func CreateAuthSecret(ctx context.Context, cs *kubernetes.Clientset, namespace string, refreshToken string) error

func CreateCCMConfigMap

func CreateCCMConfigMap(ctx context.Context, cs *kubernetes.Clientset, namespace, host, org, vdcName, clusterID, clusterName, ovdcNetwork string) error

func CreateCSIConfigMap

func CreateCSIConfigMap(ctx context.Context, cs *kubernetes.Clientset, namespace, host, org, vdcName, clusterID, vAppName string) error

func CreateClientConfig

func CreateClientConfig(kubeConfigBytes []byte) (*rest.Config, *kubernetes.Clientset, error)

func CreateClusterIDSecret

func CreateClusterIDSecret(ctx context.Context, cs *kubernetes.Clientset, namespace string, clusterID string) error

func CreateOrGetNameSpace

func CreateOrGetNameSpace(ctx context.Context, cs *kubernetes.Clientset, namespace string) error

func CreateWorkloadClusterResources

func CreateWorkloadClusterResources(ctx context.Context, workloadClientSet *kubernetes.Clientset, capiYaml, rdeID string, vcdcluster *v1beta2.VCDCluster) error

func DeleteCAPIYaml

func DeleteCAPIYaml(ctx context.Context, r runtimeclient.Client, yamlContent []byte) error

func GetClusterNameAndNamespaceFromCAPIYaml

func GetClusterNameAndNamespaceFromCAPIYaml(yamlContent []byte) (string, string, error)

func GetMapBySpecName

func GetMapBySpecName(specMap map[string]interface{}, specName string, sectionName string) (map[string]interface{}, error)

func GetSecret

func GetSecret(_ context.Context, capiYaml string) (*corev1.Secret, error)

func GetUserOrgAndName

func GetUserOrgAndName(_ context.Context, org, username string) (string, string)

func GetVCDClusterFromCluster

func GetVCDClusterFromCluster(ctx context.Context, client runtimeclient.Client, namespace string, name string) (*v1beta2.VCDCluster, error)

func MonitorK8sNodePools

func MonitorK8sNodePools(testClient *testingsdk.TestClient, runtimeClient runtimeclient.Client, expectedWorkNodeCount int64) error

func MonitorK8sUpgrade

func MonitorK8sUpgrade(
	testClient *testingsdk.TestClient, runtimeClient runtimeclient.Client, targetK8sVersion string,
) error

MonitorK8sUpgrade polls the current cluster, checking if all nodes have been upgraded to a specified k8s version and then if all machines have reached running phase. @param testClient - test client needed to access the cluster using common testing core @param runtimeClient - k8s client needed to check if machines have reached running phase @param targetK8sVersion - the specified k8s version that we are checking for the nodes to be upgraded to @return error - null if there is no error, the error otherwise

func NewTestClient

func NewTestClient(host, org, userOrg, vdcName, username, token, clusterId string, getVdcClient bool) (*testingsdk.TestClient, error)

func ScaleNodePool

func ScaleNodePool(ctx context.Context, r runtimeclient.Client, desiredNodePoolSize int64, clusterName, clusterNameSpace string) error

func UpgradeCluster

func UpgradeCluster(ctx context.Context, r runtimeclient.Client, capiYaml, currK8sVersion, targetK8sVersion, targetTkgVersion string, tkgMap map[string]interface{}, allVappTemplates []*types.QueryResultVappTemplateType) (string, error)

UpgradeCluster performs all the necessary steps and calls the required functions to upgrade the current cluster. It takes the following parameters: - ctx: the context for the operation - r: the runtime client used to access the cluster using common testing core - capiYaml: the current capiyaml - currK8sVersion: the cluster's current Kubernetes version - targetK8sVersion: the target Kubernetes version for the upgrade - targetTkgVersion: the target Tanzu Kubernetes Grid (TKG) version for the upgrade - tkgMap: tkg_map.json marshalled into map[string]interface{} - allVappTemplates: a list of vApp Templates installed in each catalog in the current organization

The function returns the following values: - string: the updated capiyaml (for stringing operations, if necessary) - error: nil if there is no error, otherwise the encountered error

func ValidateKubeConfig

func ValidateKubeConfig(ctx context.Context, kubeConfigBytes []byte) (*kubernetes.Clientset, error)

func WaitForClusterDelete

func WaitForClusterDelete(ctx context.Context, client runtimeclient.Client, clusterName, clusterNameSpace string) error

func WaitForClusterProvisioned

func WaitForClusterProvisioned(ctx context.Context, client runtimeclient.Client, clusterName, clusterNameSpace string) error

func WaitForMachinesRunning

func WaitForMachinesRunning(ctx context.Context, client runtimeclient.Client, clusterName, clusterNameSpace string) error

Types

type ConfigMapInput

type ConfigMapInput struct {
	VcdHost   string
	ORG       string
	OVDC      string
	Network   string
	ClusterID string
	VAPP      string
}

Jump to

Keyboard shortcuts

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