clusterbootstrapclone

package
v0.0.0-...-9331f55 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2023 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Overview

Package clusterbootstrapclone provides helper functions to create ClusterBootstrap CR and clones its associated objects.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Helper

type Helper struct {
	Ctx                         context.Context
	K8sClient                   client.Client
	AggregateAPIResourcesClient client.Client
	DynamicClient               dynamic.Interface
	GVRHelper                   util.GVRHelper
	Logger                      logr.Logger
}

func NewHelper

func NewHelper(ctx context.Context, k8sClient client.Client, aggregateAPIResourcesClient client.Client,
	dynamicClient dynamic.Interface,
	gvrHelper util.GVRHelper,
	logger logr.Logger) *Helper

NewHelper instantiates a new helper instance

func (*Helper) AddClusterOwnerRef

func (h *Helper) AddClusterOwnerRef(cluster *clusterapiv1beta1.Cluster, children []*unstructured.Unstructured, controller, blockownerdeletion *bool) error

AddClusterOwnerRef adds cluster as an owner reference to the children with given controller and blockownerdeletion settings

func (*Helper) AddClusterOwnerRefToExistingProviders

func (h *Helper) AddClusterOwnerRefToExistingProviders(cluster *clusterapiv1beta1.Cluster, clusterBootstrap *runtanzuv1alpha3.ClusterBootstrap) error

func (*Helper) AddMissingSpecFieldsFromTemplate

func (h *Helper) AddMissingSpecFieldsFromTemplate(clusterBootstrapTemplate *runtanzuv1alpha3.ClusterBootstrapTemplate,
	clusterBootstrap *runtanzuv1alpha3.ClusterBootstrap, keysToSkip map[string]interface{}) error

AddMissingSpecFieldsFromTemplate scans clusterBootstrap's fields. For fields which are not specified, it adds defaults from clusterBootstrapTemplate

func (*Helper) AddPackageLabelForCNIProvider

func (h *Helper) AddPackageLabelForCNIProvider(clusterName string, clusterBootstrap *runtanzuv1alpha3.ClusterBootstrap) error

AddPackageLabelForCNIProvider patch the missing labels for AntreaConfig(cni config) when it's related to an existing clusterboostrap. To make antreaconfig works with old versions, it relies on the package label now.

func (*Helper) CloneReferencedObjectsFromCBPackages

func (h *Helper) CloneReferencedObjectsFromCBPackages(
	cluster *clusterapiv1beta1.Cluster,
	cbPackages []*runtanzuv1alpha3.ClusterBootstrapPackage,
	sourceNamespace string) ([]*corev1.Secret, []*unstructured.Unstructured, error)

CloneReferencedObjectsFromCBPackages clones all referenced objects of a list of ClusterBootstrapPackage.ValuesFrom from sourceNamespace into the cluster namespace.

func (*Helper) CompleteCBPackageRefNamesFromTKR

func (h *Helper) CompleteCBPackageRefNamesFromTKR(tkr *runtanzuv1alpha3.TanzuKubernetesRelease, clusterBootstrap *runtanzuv1alpha3.ClusterBootstrap) error

CompleteCBPackageRefNamesFromTKR goes through the ClusterBootstrapPackages and makes the RefName complete. For example, when the clusterBootstrapPackage.RefName passed in is "calico*", this function updates it to be a fully qualified name(<packageShortName>.<domain>.<version>). The fully qualified name is fetched from TKR.

func (*Helper) CreateClusterBootstrapFromTemplate

func (h *Helper) CreateClusterBootstrapFromTemplate(
	clusterBootstrapTemplate *runtanzuv1alpha3.ClusterBootstrapTemplate,
	cluster *clusterapiv1beta1.Cluster,
	tkrName string) (*runtanzuv1alpha3.ClusterBootstrap, error)

CreateClusterBootstrapFromTemplate does the following:

  1. Create a new ClusterBootstrap CR under the cluster namespace
  2. Clone the referenced object of ClusterBootstrapPackage.ValuesFrom into the cluster namespace. If the referenced object has embedded TypedLocalObjectReference(e.g., CPI has VSphereCPIConfig as valuesFrom, VSphereCPIConfig has a Secret reference under its Spec), this function clones the embedded object into the cluster namespace as well.
  3. Add OwnerReferences and Labels to the cloned objects.

func (*Helper) CreateOrPatchInlineSecret

func (h *Helper) CreateOrPatchInlineSecret(
	cluster *clusterapiv1beta1.Cluster,
	cbPkg *runtanzuv1alpha3.ClusterBootstrapPackage,
	inlineSecret *corev1.Secret) (*corev1.Secret, error)

CreateOrPatchInlineSecret is a function that creates or patches a Secret resource from ClusterBootstrapPackage.ValuesFrom.Inline into the cluster namespace

func (*Helper) CreateSecretFromInline

func (h *Helper) CreateSecretFromInline(
	cluster *clusterapiv1beta1.Cluster,
	cbPkg *runtanzuv1alpha3.ClusterBootstrapPackage,
	carvelPkgRefName string) (*corev1.Secret, error)

CreateSecretFromInline is an internal function creates a Secret resource from ClusterBootstrapPackage.ValuesFrom.Inline into the cluster namespace

func (*Helper) EnsureOwnerRef

func (h *Helper) EnsureOwnerRef(clusterBootstrap *runtanzuv1alpha3.ClusterBootstrap, secrets []*corev1.Secret, providers []*unstructured.Unstructured) error

EnsureOwnerRef will ensure the provided OwnerReference onto the secrets and provider objects

func (*Helper) HandleExistingClusterBootstrap

func (h *Helper) HandleExistingClusterBootstrap(clusterBootstrap *runtanzuv1alpha3.ClusterBootstrap, cluster *clusterapiv1beta1.Cluster, tkrName, systemNamespace string) (*runtanzuv1alpha3.ClusterBootstrap, error)

HandleExistingClusterBootstrap does the following:

  1. Check the annotation from the existing ClusterBootstrap CR. Add missing fields to the ClusterBootstrap CR if needed
  2. Clone the referenced object of ClusterBootstrapPackage.ValuesFrom into the cluster namespace. If the referenced object has embedded TypedLocalObjectReference(e.g., CPI has VSphereCPIConfig as valuesFrom, VSphereCPIConfig has a Secret reference under its Spec), this function clones the embedded object into the cluster namespace as well.
  3. Add OwnerReferences and Labels to the cloned objects.

Jump to

Keyboard shortcuts

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