bootstrap

package
v0.0.0-...-bd86e2b Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const EmptyImagePullSecret = "empty-image-pull-secret"

Variables

View Source
var ManifestFiles embed.FS

Functions

func CreateBootstrapKubeConfig

func CreateBootstrapKubeConfig(ctxClusterName string,
	kubeAPIServer, proxyURL, ca string, caData, token []byte) ([]byte, error)

create kubeconfig for bootstrap

func GenerateHubBootstrapRBACObjects

func GenerateHubBootstrapRBACObjects(managedClusterName string) ([]runtime.Object, error)

func GetBootstrapCAData

func GetBootstrapCAData(ctx context.Context, clientHolder *helpers.ClientHolder, kubeAPIServer string,
	caNamespace string, klusterletConfig *klusterletconfigv1alpha1.KlusterletConfig) ([]byte, error)

func GetBootstrapSAName

func GetBootstrapSAName(clusterName string) string

func GetBootstrapToken

func GetBootstrapToken(ctx context.Context, kubeClient kubernetes.Interface,
	saName, secretNamespace string, tokenExpirationSeconds int64) ([]byte, []byte, []byte, error)

GetBootstrapToken lists the secrets from the managed cluster namespace to look for the managed cluster bootstrap token firstly (compatibility with the ocp that version is less than 4.11), if there is no token found, uses tokenrequest to request token.

func GetKubeAPIServerAddress

func GetKubeAPIServerAddress(ctx context.Context, client client.Client,
	klusterletConfig *klusterletconfigv1alpha1.KlusterletConfig) (string, error)

func GetKubeAPIServerConfig

func GetKubeAPIServerConfig(ctx context.Context, clientHolder *helpers.ClientHolder, ns string,
	klusterletConfig *klusterletconfigv1alpha1.KlusterletConfig, selfManaged bool) (string, string,
	string, []byte, error)

GetKubeAPIServerConfig returns the expected apiserver url, proxy url, ca file and ca data for cluster registration.

func GetKubeconfigClusterName

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

GetKubeconfigClusterName returns the cluster name used in the bootstrap kubeconfig current context. This is to fix the issue that when the hub cluster is rebuilt, and we backup restore the resources on the same hub cluster, even the bootstrp kubeconfig is generated by the new hub cluster, it will not trigger the agent to rebootstrap. Using a different cluster name will make the agent to rebootstrap. Currently, the above issue is only fixed on OCP as we get the cluster name from the infrastructure. TODO: On non-OCP, we use "default-cluster" as the cluster name now and need to fix it in the future.

func GetProxySettings

func GetProxySettings(klusterletConfig *klusterletconfigv1alpha1.KlusterletConfig) (string, []byte)

func RequestSAToken

func RequestSAToken(ctx context.Context, kubeClient kubernetes.Interface, saName, secretNamespace string,
	tokenExpirationSeconds int64) ([]byte, []byte, []byte, error)

func ValidateBootstrapKubeconfig

func ValidateBootstrapKubeconfig(clusterName string,
	kubeAPIServer, proxyURL, ca string, caData []byte, ctxClusterName string,
	requiredKubeAPIServer, requiredProxyURL, requiredCA string, requiredCAData []byte,
	requiredCtxClusterName string) bool

ValidateBootstrapKubeconfig validates the bootstrap kubeconfig data by checking for changes in:

  • the kube apiserver address
  • the CA file path
  • the CA data
  • the proxy url
  • the context cluster name

Types

type BootstrapKubeConfigSecret

type BootstrapKubeConfigSecret struct {
	Name       string
	KubeConfig string
}

type ImagePullSecretConfig

type ImagePullSecretConfig struct {
	UseImagePullSecret       bool
	ImagePullSecretName      string
	ImagePullSecretData      string
	ImagePullSecretConfigKey string
	ImagePullSecretType      corev1.SecretType
}

type KlusterletManifestsConfig

type KlusterletManifestsConfig struct {
	InstallMode operatorv1.InstallMode

	ClusterName                  string
	KlusterletNamespace          string
	KlusterletClusterAnnotations map[string]string
	BootstrapKubeconfig          []byte

	// PriorityClassName is the name of the PriorityClass used by the klusterlet and operator
	PriorityClassName string

	// Used to determine whether mc is a localcluster.
	ManagedCluster *clusterv1.ManagedCluster
	// contains filtered or unexported fields
}

func NewKlusterletManifestsConfig

func NewKlusterletManifestsConfig(installMode operatorv1.InstallMode,
	clusterName string, bootstrapKubeconfig []byte) *KlusterletManifestsConfig

func (*KlusterletManifestsConfig) Generate

func (b *KlusterletManifestsConfig) Generate(ctx context.Context, clientHolder *helpers.ClientHolder) ([]byte, error)

Generate returns the rendered klusterlet manifests in bytes.

func (*KlusterletManifestsConfig) GenerateKlusterletCRDsV1

func (b *KlusterletManifestsConfig) GenerateKlusterletCRDsV1() ([]byte, error)

func (*KlusterletManifestsConfig) GenerateKlusterletCRDsV1Beta1

func (b *KlusterletManifestsConfig) GenerateKlusterletCRDsV1Beta1() ([]byte, error)

func (*KlusterletManifestsConfig) WithImagePullSecretGenerate

func (c *KlusterletManifestsConfig) WithImagePullSecretGenerate(g bool) *KlusterletManifestsConfig

func (*KlusterletManifestsConfig) WithKlusterletClusterAnnotations

func (c *KlusterletManifestsConfig) WithKlusterletClusterAnnotations(a map[string]string) *KlusterletManifestsConfig

WithKlusterletClusterAnnotations sets the klusterlet cluster annotations(klusterlet.spec.registrationConfiguration.clusterAnnotations). These annotations must begin with a prefix "agent.open-cluster-management.io*".

func (*KlusterletManifestsConfig) WithKlusterletConfig

func (*KlusterletManifestsConfig) WithManagedCluster

WithManagedClusterLabels sets the managed cluster.

func (*KlusterletManifestsConfig) WithPriorityClassName

func (c *KlusterletManifestsConfig) WithPriorityClassName(priorityClassName string) *KlusterletManifestsConfig

type KlusterletRenderConfig

type KlusterletRenderConfig struct {
	KlusterletName            string
	KlusterletNamespace       string
	ManagedClusterNamespace   string
	RegistrationOperatorImage string
	RegistrationImageName     string
	WorkImageName             string
	ImageName                 string
	PriorityClassName         string
	InstallMode               string

	NodeSelector  map[string]string
	Tolerations   []corev1.Toleration
	NodePlacement *operatorv1.NodePlacement

	RegistrationConfiguration *operatorv1.RegistrationConfiguration
	WorkConfiguration         *operatorv1.WorkAgentConfiguration

	MultipleHubsEnabled              bool
	DefaultBootstrapKubeConfigSecret BootstrapKubeConfigSecret
	BootstrapKubeConfigSecrets       []BootstrapKubeConfigSecret
}

KlusterletRenderConfig defines variables used in the klusterletFiles.

type RenderConfig

type RenderConfig struct {
	KlusterletRenderConfig
	ImagePullSecretConfig
}

Jump to

Keyboard shortcuts

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