kubernetes

package
v0.15.2 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2025 License: AGPL-3.0 Imports: 53 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateArgoCDProject

func CreateArgoCDProject(ctx context.Context,
	argoCDProjectClient project.ProjectServiceClient,
	name string,
)

Tries to create an ArgoCD Project with the given name. Skips if the ArgoCD Project already exists. Panics on failure.

func CreateBackup added in v0.11.1

func CreateBackup(ctx context.Context, name string, clusterClient client.Client)

Creates a Velero Backup with the given name.

func CreateKubernetesClient

func CreateKubernetesClient(ctx context.Context, kubeconfigPath string) (client.Client, error)

Tries to create a Kubernetes Go client using the Kubeconfig file present at the given path. Returns the Kubernetes Go client.

func CreateNamespace

func CreateNamespace(ctx context.Context, namespaceName string, clusterClient client.Client)

Creates the given namespace (if it doesn't already exist).

func GenerateSealedSecret

func GenerateSealedSecret(ctx context.Context, secretFilePath string)

Takes the path to a Kubernetes Secret file. It replaces the contents of that file by generating the corresponding Sealed Secret.

func GetCapiClusterNamespace

func GetCapiClusterNamespace() string

Returns the namespace (capi-cluster / capi-cluster-<customer-id>) where the 'cloud-credentials' Kubernetes Secret will exist. This Kubernetes Secret will be used by Cluster API to communicate with the underlying cloud provider.

func GetClusterResource

func GetClusterResource(ctx context.Context,
	clusterClient client.Client,
) (*clusterAPIV1Beta1.Cluster, error)

Looks for and returns the Cluster resource in the given Kubernetes cluster.

func GetKubernetesResource

func GetKubernetesResource(ctx context.Context,
	clusterClient client.Client,
	resource client.Object,
) error

Tries to fetch the given Kubernetes resource using the given Kubernetes cluster client.

func GetLatestVeleroBackup added in v0.10.0

func GetLatestVeleroBackup(ctx context.Context, clusterClient client.Client) *veleroV1.Backup

Identifies and returns the latest / most recent Velero Backup.

func GetMainClusterEndpoint added in v0.10.0

func GetMainClusterEndpoint(ctx context.Context) *clusterAPIV1Beta1.APIEndpoint

Returns API endpoint of the main cluster, if provisioned. Otherwise returns nil.

func GetManagementClusterKubeconfigPath

func GetManagementClusterKubeconfigPath(ctx context.Context) string

Returns the management cluster kubeconfig file path, based on whether the script is running inside a container or not.

func HelmInstall

func HelmInstall(ctx context.Context, args *HelmInstallArgs)

Installs the Helm chart (if not already deployed), present at the given local path. We clone the KubeAid repository locally and then use absolute path to one of it's Helm chart (like argo-cd / sealed-secrets), to install that corresponding Helm chart.

func InstallAndSetupArgoCD

func InstallAndSetupArgoCD(ctx context.Context, clusterDir string, clusterClient client.Client)

Installs the ArgoCD Helm chart and creates the root ArgoCD App. Then creates and returns an ArgoCD Application client.

func InstallAndSetupCrossplane added in v0.12.2

func InstallAndSetupCrossplane(ctx context.Context)

Installs and sets up CrossPlane.

Syncs the crossplane, crossplane-providers-and-functions and crossplane-compositions ArgoCD
Apps one by one.

NOTE : We need to sync crossplane deployment itself, then the crossplane providers and functions,
       and finally the crossplane compositions.
       I tried packaging everything in a single Helm chart, and using ArgoCD sync waves. But,
       that didn't work. I'll retry later,

func InstallSealedSecrets

func InstallSealedSecrets(ctx context.Context)

Performs a minimal installation of Sealed Secrets in the underlying Kubernetes cluster.

func IsClusterctlMoveExecuted

func IsClusterctlMoveExecuted(ctx context.Context) bool

Returns whether the 'clusterctl move' command has already been executed or not.

func IsNodeGroupCountZero added in v0.12.0

func IsNodeGroupCountZero(ctx context.Context) bool

Returns whether there are zero node-groups or not. If yes, then we need to remove taints from the control-plane nodes right after the main cluster is provisioned.

func MustCreateClusterClient added in v0.11.1

func MustCreateClusterClient(ctx context.Context, kubeconfigPath string) client.Client

Creates a Kubernetes Go client using the Kubeconfig file present at the given path.

func NewArgoCDClient

func NewArgoCDClient(ctx context.Context, clusterClient client.Client) apiclient.Client

Port-forwards the ArgoCD server and creates an ArgoCD client. Returns the ArgoCD client.

func RecreateArgoCDApplicationClient

func RecreateArgoCDApplicationClient(ctx context.Context, clusterClient client.Client)

Recreates the ArgoCD Application client by port-forwarding the ArgoCD server. If the clusterClient is not provided (is nil), then it picks up the KUBECONFIG envionment variable and constructs the cluster client by itself.

func RemoveNoScheduleTaintsFromMasterNodes added in v0.12.0

func RemoveNoScheduleTaintsFromMasterNodes(ctx context.Context, clusterClient client.Client)

Removes the 'node-role.kubernetes.io/control-plane:NoSchedule' taint from master nodes.

func RestoreVeleroBackup added in v0.10.0

func RestoreVeleroBackup(ctx context.Context,
	clusterClient client.Client,
	latestVeleroBackup *veleroV1.Backup,
)

Creates a Velero Restore object for the given Velero Backup.

func SaveProvisionedClusterKubeconfig added in v0.8.0

func SaveProvisionedClusterKubeconfig(ctx context.Context, kubeClient client.Client)

Saves kubeconfig of the provisioned cluster locally.

func SyncAllArgoCDApps

func SyncAllArgoCDApps(ctx context.Context)

Lists and syncs all the ArgoCD Apps.

func SyncArgoCDApp

func SyncArgoCDApp(
	ctx context.Context,
	name string,
	resources []*argoCDV1Aplha1.SyncOperationResource,
)

Syncs the ArgoCD App (if not synced already). If the resources array is empty, then the whole ArgoCD App is synced. Otherwise, only the specified resources.

func TriggerCRONJob added in v0.11.1

func TriggerCRONJob(ctx context.Context, objectKey client.ObjectKey, clusterClient client.Client)

Triggers the given CRONJob, by creating a Job from its Job template.

func UsingClusterAPI added in v0.12.0

func UsingClusterAPI() (usingClusterAPI bool)

Returns whether we're using Clusterapi or not.

func WaitForMainClusterToBeProvisioned

func WaitForMainClusterToBeProvisioned(ctx context.Context, managementClusterClient client.Client)

Waits for the main cluster to be provisioned.

func WaitForMainClusterToBeReady

func WaitForMainClusterToBeReady(ctx context.Context, kubeClient client.Client)

Waits for the main cluster to be ready to run our application workloads.

Types

type HelmInstallArgs

type HelmInstallArgs struct {
	ChartPath,

	ReleaseName,
	Namespace string

	Values *values.Options
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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