Documentation ¶
Index ¶
- Constants
- Variables
- func CreateBootstrapKubeConfig(ctxClusterName string, kubeAPIServer, proxyURL, ca string, ...) ([]byte, error)
- func GenerateHubBootstrapRBACObjects(managedClusterName string) ([]runtime.Object, error)
- func GetBootstrapCAData(ctx context.Context, clientHolder *helpers.ClientHolder, kubeAPIServer string, ...) ([]byte, error)
- func GetBootstrapSAName(clusterName string) string
- func GetBootstrapToken(ctx context.Context, kubeClient kubernetes.Interface, ...) ([]byte, []byte, []byte, error)
- func GetKubeAPIServerAddress(ctx context.Context, client client.Client, ...) (string, error)
- func GetKubeAPIServerConfig(ctx context.Context, clientHolder *helpers.ClientHolder, ns string, ...) (string, string, string, []byte, error)
- func GetKubeconfigClusterName(ctx context.Context, client client.Client) (string, error)
- func GetProxySettings(klusterletConfig *klusterletconfigv1alpha1.KlusterletConfig) (string, []byte)
- func RequestSAToken(ctx context.Context, kubeClient kubernetes.Interface, ...) ([]byte, []byte, []byte, error)
- func ValidateBootstrapKubeconfig(clusterName string, kubeAPIServer, proxyURL, ca string, caData []byte, ...) bool
- type BootstrapKubeConfigSecret
- type ImagePullSecretConfig
- type KlusterletManifestsConfig
- func (b *KlusterletManifestsConfig) Generate(ctx context.Context, clientHolder *helpers.ClientHolder) ([]byte, error)
- func (b *KlusterletManifestsConfig) GenerateKlusterletCRDsV1() ([]byte, error)
- func (b *KlusterletManifestsConfig) GenerateKlusterletCRDsV1Beta1() ([]byte, error)
- func (c *KlusterletManifestsConfig) WithImagePullSecretGenerate(g bool) *KlusterletManifestsConfig
- func (c *KlusterletManifestsConfig) WithKlusterletClusterAnnotations(a map[string]string) *KlusterletManifestsConfig
- func (c *KlusterletManifestsConfig) WithKlusterletConfig(klusterletConfig *klusterletconfigv1alpha1.KlusterletConfig) *KlusterletManifestsConfig
- func (c *KlusterletManifestsConfig) WithManagedCluster(mc *clusterv1.ManagedCluster) *KlusterletManifestsConfig
- func (c *KlusterletManifestsConfig) WithPriorityClassName(priorityClassName string) *KlusterletManifestsConfig
- type KlusterletRenderConfig
- type RenderConfig
Constants ¶
const EmptyImagePullSecret = "empty-image-pull-secret"
Variables ¶
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 GetBootstrapCAData ¶
func GetBootstrapCAData(ctx context.Context, clientHolder *helpers.ClientHolder, kubeAPIServer string, caNamespace string, klusterletConfig *klusterletconfigv1alpha1.KlusterletConfig) ([]byte, error)
func GetBootstrapSAName ¶
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 ¶
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 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 ImagePullSecretConfig ¶
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 (c *KlusterletManifestsConfig) WithKlusterletConfig(klusterletConfig *klusterletconfigv1alpha1.KlusterletConfig) *KlusterletManifestsConfig
func (*KlusterletManifestsConfig) WithManagedCluster ¶
func (c *KlusterletManifestsConfig) WithManagedCluster(mc *clusterv1.ManagedCluster) *KlusterletManifestsConfig
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 }