clusters

package
v0.0.0-...-2bcb20d Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: Apache-2.0 Imports: 32 Imported by: 3

Documentation

Index

Constants

View Source
const (
	FleetSteveResourceType               = "fleet.cattle.io.cluster"
	PodSecurityAdmissionSteveResoureType = "management.cattle.io.podsecurityadmissionconfigurationtemplate"
	ProvisioningSteveResourceType        = "provisioning.cattle.io.cluster"

	ErrMsgListDownstreamClusters = "Couldn't list downstream clusters"
)

Variables

This section is empty.

Functions

func AgentAffinityConfigHelper

func AgentAffinityConfigHelper(advancedClusterAffinity *management.Affinity) *corev1.Affinity

AgentAffinityConfigHelper is a "helper" function that converts a management.Affinity struct and returns a corev1.Affinity struct.

func CheckServiceAccountTokenSecret

func CheckServiceAccountTokenSecret(client *rancher.Client, clusterName string) (success bool, err error)

CheckServiceAccountTokenSecret verifies if a serviceAccountTokenSecret exists or not in the cluster.

func CreateK3SRKE2Cluster

func CreateK3SRKE2Cluster(client *rancher.Client, rke2Cluster *apisV1.Cluster) (*v1.SteveAPIObject, error)

CreateK3SRKE2Cluster is a "helper" functions that takes a rancher client, and the rke2 cluster config as parameters. This function registers a delete cluster fuction with a wait.WatchWait to ensure the cluster is removed cleanly.

func CreateRKE1Cluster

func CreateRKE1Cluster(client *rancher.Client, rke1Cluster *management.Cluster) (*management.Cluster, error)

CreateRKE1Cluster is a "helper" functions that takes a rancher client, and the rke1 cluster config as parameters. This function registers a delete cluster fuction with a wait.WatchWait to ensure the cluster is removed cleanly.

func CreateRancherBaselinePSACT

func CreateRancherBaselinePSACT(client *rancher.Client, psact string) error

CreateRancherBaselinePSACT creates custom PSACT called rancher-baseline which sets each PSS to baseline.

func DeleteK3SRKE2Cluster

func DeleteK3SRKE2Cluster(client *rancher.Client, clusterID string) error

DeleteK3SRKE2Cluster is a "helper" functions that takes a rancher client, and the non-rke1 cluster ID as parameters to delete the cluster.

func DeleteRKE1Cluster

func DeleteRKE1Cluster(client *rancher.Client, clusterID string) error

DeleteKE1Cluster is a "helper" functions that takes a rancher client, and the rke1 cluster ID as parameters to delete the cluster.

func GetClusterIDByName

func GetClusterIDByName(client *rancher.Client, clusterName string) (string, error)

GetClusterIDByName is a helper function that returns the cluster ID by name

func GetClusterNameByID

func GetClusterNameByID(client *rancher.Client, clusterID string) (string, error)

GetClusterNameByID is a helper function that returns the cluster ID by name

func GetProvisioningClusterByName

func GetProvisioningClusterByName(client *rancher.Client, clusterName string, namespace string) (*apisV1.Cluster, *v1.SteveAPIObject, error)

GetProvisioningClusterByName is a helper function to get cluster object with the cluster name

func GetV1ProvisioningClusterByName

func GetV1ProvisioningClusterByName(client *rancher.Client, clusterName string) (string, error)

GetV1ProvisioningClusterByName is a helper function that returns the cluster ID by name

func HardenK3SClusterConfig

func HardenK3SClusterConfig(clusterName, namespace string, clustersConfig *ClusterConfig, machinePools []apisV1.RKEMachinePool, cloudCredentialSecretName string) *apisV1.Cluster

HardenK3SClusterConfig is a constructor for a apisV1.Cluster object, to be used by the rancher.Client.Provisioning client.

func HardenRKE2ClusterConfig

func HardenRKE2ClusterConfig(clusterName, namespace string, clustersConfig *ClusterConfig, machinePools []apisV1.RKEMachinePool, cloudCredentialSecretName string) *apisV1.Cluster

HardenRKE2ClusterConfig is a constructor for a apisV1.Cluster object, to be used by the rancher.Client.Provisioning client.

func ImportCluster

func ImportCluster(client *rancher.Client, cluster *apisV1.Cluster, rest *rest.Config) error

ImportCluster creates a job using the given rest config that applies the import yaml from the given management cluster.

func InTreeSystemConfig

func InTreeSystemConfig(providerName string) (rkeConfig []rkev1.RKESystemConfig)

InTreeSystemConfig constructs the proper rkeSystemConfig slice for enabling cloud provider in-tree services. Vsphere deprecated 1.21+ AWS deprecated 1.27+ Azure deprecated 1.28+

func IsClusterImported

func IsClusterImported(client *rancher.Client, clusterID string) (isImported bool, err error)

IsClusterImported is a function to get a boolean value about if the cluster is imported or not. For custom and imported clusters the node driver value is different than "imported".

func IsHostedProvider

func IsHostedProvider(provider KubernetesProvider) (isHosted bool)

IsHostedProvider is a function to get a boolean value about if the cluster is hosted or not.

func IsHostedProvisioningClusterReady

func IsHostedProvisioningClusterReady(event watch.Event) (ready bool, err error)

IsHostedProvisioningClusterReady is basic check function that would be used for the wait.WatchWait func in pkg/wait. This functions just waits until a hosted cluster becomes ready.

func IsImportedClusterReady

func IsImportedClusterReady(event watch.Event) (ready bool, err error)

IsImportedClusterReady is basic check function that would be used for the wait.WatchWait func in pkg/wait. This functions just waits until an imported cluster becomes ready.

func IsProvisioningClusterReady

func IsProvisioningClusterReady(event watch.Event) (ready bool, err error)

IsProvisioningClusterReady is basic check function that would be used for the wait.WatchWait func in pkg/wait. This functions just waits until a cluster becomes ready.

func ListDownstreamClusters

func ListDownstreamClusters(client *rancher.Client) (clusterNames []string, err error)

ListDownstreamClusters is a helper function to get the name of the downstream clusters

func NewK3SRKE2ClusterConfig

func NewK3SRKE2ClusterConfig(clusterName, namespace string, clustersConfig *ClusterConfig, machinePools []apisV1.RKEMachinePool, cloudCredentialSecretName string) *apisV1.Cluster

NewK3SRKE2ClusterConfig is a constructor for a apisV1.Cluster object, to be used by the rancher.Client.Provisioning client.

func NewRKE1ClusterConfig

func NewRKE1ClusterConfig(clusterName string, client *rancher.Client, clustersConfig *ClusterConfig) *management.Cluster

NewRKE1lusterConfig is a constructor for a v3.Cluster object, to be used by the rancher.Client.Provisioning client.

func OutOfTreeSystemConfig

func OutOfTreeSystemConfig(providerName string) (rkeConfig []rkev1.RKESystemConfig)

OutOfTreeSystemConfig constructs the proper rkeSystemConfig slice for enabling the aws cloud provider out-of-tree services

func RKESystemConfigTemplate

func RKESystemConfigTemplate(config map[string]interface{}, selector *metav1.LabelSelector) rkev1.RKESystemConfig

RKESYstemConfigTemplate constructs an RKESystemConfig object given config data and a selector

func ResourceConfigHelper

func ResourceConfigHelper(advancedClusterResourceRequirements *management.ResourceRequirements) *corev1.ResourceRequirements

ResourceConfigHelper is a "helper" function that is used to convert the management.ResourceRequirements struct to a corev1.ResourceRequirements struct.

func UpdateK3SRKE2Cluster

func UpdateK3SRKE2Cluster(client *rancher.Client, cluster *v1.SteveAPIObject, updatedCluster *apisV1.Cluster) (*v1.SteveAPIObject, error)

UpdateK3SRKE2Cluster is a "helper" functions that takes a rancher client, old rke2/k3s cluster config, and the new rke2/k3s cluster config as parameters.

func WaitClusterToBeInUpgrade

func WaitClusterToBeInUpgrade(client *rancher.Client, clusterID string) (err error)

WaitClusterToBeInUpgrade is a helper function that takes a rancher client, and the cluster id as parameters. Waits cluster to be in upgrade state. Cluster error states that declare control plane is inaccessible and cluster object modified are ignored. Same cluster summary information logging is ignored.

func WaitClusterToBeUpgraded

func WaitClusterToBeUpgraded(client *rancher.Client, clusterID string) (err error)

WaitForClusterToBeUpgraded is a "helper" functions that takes a rancher client, and the cluster id as parameters. This function contains two stages. First stage is to wait to be cluster in upgrade state. And the other is to wait until cluster is ready. Cluster error states that declare control plane is inaccessible and cluster object modified are ignored. Same cluster summary information logging is ignored.

func WaitClusterUntilUpgrade

func WaitClusterUntilUpgrade(client *rancher.Client, clusterID string) (err error)

WaitClusterUntilUpgrade is a helper function that takes a rancher client, and the cluster id as parameters. Waits until cluster is ready. Cluster error states that declare control plane is inaccessible and cluster object modified are ignored. Same cluster summary information logging is ignored.

func WaitForActiveRKE1Cluster

func WaitForActiveRKE1Cluster(client *rancher.Client, clusterID string) error

WaitForActiveCluster is a "helper" function that waits for the cluster to reach the active state. The function accepts a Rancher client and a cluster ID as parameters.

func WatchAndWaitForCluster

func WatchAndWaitForCluster(client *rancher.Client, steveID string) error

WatchAndWaitForCluster is function that waits for a cluster to go unactive before checking its active state.

Types

type ClusterConfig

type ClusterConfig struct {
	KubernetesVersion    string                                   `json:"kubernetesVersion" yaml:"kubernetesVersion"`
	CNI                  string                                   `json:"cni" yaml:"cni"`
	PSACT                string                                   `json:"psact" yaml:"psact"`
	PNI                  bool                                     `json:"pni" yaml:"pni"`
	NodePools            []provisioningInput.NodePools            `json:"nodepools" yaml:"nodepools"`
	MachinePools         []provisioningInput.MachinePools         `json:"machinepools" yaml:"machinepools"`
	CloudProvider        string                                   `json:"cloudProvider" yaml:"cloudProvider"`
	Providers            *[]string                                `json:"providers" yaml:"providers"`
	NodeProviders        *[]string                                `json:"nodeProviders" yaml:"nodeProviders"`
	Hardened             bool                                     `json:"hardened" yaml:"hardened"`
	AddOnConfig          *provisioningInput.AddOnConfig           `json:"addonConfig" yaml:"addonConfig"`
	AgentEnvVars         *[]rkev1.EnvVar                          `json:"agentEnvVars" yaml:"agentEnvVars"`
	AgentEnvVarsRKE1     *[]management.EnvVar                     `json:"agentEnvVarsRKE1" yaml:"agentEnvVarsRKE1"`
	ClusterAgent         *management.AgentDeploymentCustomization `json:"clusterAgent" yaml:"clusterAgent"`
	FleetAgent           *management.AgentDeploymentCustomization `json:"fleetAgent" yaml:"fleetAgent"`
	ETCD                 *rkev1.ETCD                              `json:"etcd" yaml:"etcd"`
	ETCDRKE1             *management.ETCDService                  `json:"etcdRKE1" yaml:"etcdRKE1"`
	LabelsAndAnnotations *provisioningInput.LabelsAndAnnotations  `json:"labelsAndAnnotations" yaml:"labelsAndAnnotations"`
	Networking           *provisioningInput.Networking            `json:"networking" yaml:"networking"`
	Registries           *provisioningInput.Registries            `json:"registries" yaml:"registries"`
	UpgradeStrategy      *rkev1.ClusterUpgradeStrategy            `json:"upgradeStrategy" yaml:"upgradeStrategy"`
	Advanced             *provisioningInput.Advanced              `json:"advanced" yaml:"advanced"`
	ClusterSSHTests      []provisioningInput.SSHTestCase          `json:"clusterSSHTests" yaml:"clusterSSHTests"`
	CRIDockerd           bool                                     `json:"criDockerd" yaml:"criDockerd"`
}

func ConvertConfigToClusterConfig

func ConvertConfigToClusterConfig(provisioningConfig *provisioningInput.Config) *ClusterConfig

ConvertConfigToClusterConfig converts the config from (user) provisioning input to a cluster config

type ClusterMeta

type ClusterMeta struct {
	// ID used for value of cluster's ID
	ID string

	// Name used for cluster's name.
	Name string

	// Provider is used for cluster's provider.
	Provider KubernetesProvider

	// IsHosted is used for cluster's hosted information.
	IsHosted bool

	// IsImported is used for cluster's imported information.
	IsImported bool

	// IsLocal is used for cluster's local information.
	IsLocal bool
}

ClusterMeta is a struct that contains a cluster's meta

func NewClusterMeta

func NewClusterMeta(client *rancher.Client, clusterName string) (clusterMeta *ClusterMeta, err error)

NewClusterMeta is a function to initialize new ClusterMeta for a specific cluster.

type ClusterType

type ClusterType string
const (
	K3SClusterType  ClusterType = "k3s"
	RKE1ClusterType ClusterType = "rke1"
	RKE2ClusterType ClusterType = "rke2"
)

func (ClusterType) String

func (p ClusterType) String() string

type Default

type Default struct {
	StringValue      string `json:"stringValue"`
	IntValue         int    `json:"intValue"`
	BoolValue        bool   `json:"boolValue"`
	StringSliceValue []int  `json:"stringSliceValue"`
}

type DynamicSchemaSpec

type DynamicSchemaSpec struct {
	ResourceFields ResourceFields `json:"resourceFields"`
}

DynamicSchemaSpec contains ResourceFields that contains all the data for the DynamicSchemaSpec which a type in provisioning.cattle.io.clusters this is how we get an ssh user for a node pool

type KubernetesProvider

type KubernetesProvider string

KubernetesProvider is a string type to determine cluster's provider.

const (

	// KubernetesProvider string enums are to determine cluster's provider.
	KubernetesProviderRKE  KubernetesProvider = rke
	KubernetesProviderRKE2 KubernetesProvider = rke2
	KubernetesProviderK3S  KubernetesProvider = k3s
	KubernetesProviderAKS  KubernetesProvider = aks
	KubernetesProviderEKS  KubernetesProvider = eks
	KubernetesProviderGKE  KubernetesProvider = gke
)

func GetClusterProvider

func GetClusterProvider(client *rancher.Client, clusterID string) (provider KubernetesProvider, err error)

GetClusterProvider is a function to get cluster's KubernetesProvider.

type ResourceFields

type ResourceFields struct {
	SSHUser SSHUser
}

type SSHUser

type SSHUser struct {
	Type        string `json:"type"`
	Default     Default
	Create      bool   `json:"create"`
	Update      bool   `json:"update"`
	Description string `json:"description"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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