controllers

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2021 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// GitSyncVersion is the version of the git-sync container image
	GitSyncVersion = "v3.2.0"
)
View Source
const MilliResyncPeriod = 3000

MilliResyncPeriod is the duration between two synchronization attempt of a given resource

Variables

This section is empty.

Functions

This section is empty.

Types

type ClusterDefConfig

type ClusterDefConfig struct {
	// Registry is the registry containing the sync pod image
	Registry string
	// CredsRegistrySecretName is the name of the secret that contains the credentials of the Registry
	CredsRegistrySecretName string
	// SnapshotLocation is the URL of the snapshot repository
	SnapshotLocation string
	// SnapshotCredentialSecret points to a K8S secret containing credentials
	SnapshotCredentialSecret string
	// HttpProxy for git repos
	HTTPProxy string
	// HttpsProxy for git repos
	HTTPSProxy string
	// NoProxy for git repos
	NoProxy string
	// PodNamespace is the namespace of the pod
	PodNamespace string
	// GitSyncPeriod is the time between two queries to the user git repo
	GitSyncPeriod string
	// UpdaterVersion is the version of the Updater container image (in the updater pod)
	UpdaterVersion string
	// ArgocdSnapshotPlugin is the name of plugin associated to the snapshot
	// argocd application or is empty is no plugin is used
	ArgocdSnapshotPlugin string
	// ArgocdSnapshotPluginEnv is the args of plugin associated to the snapshot
	// argocd application or is nil if no plugin is used.
	ArgocdSnapshotPluginEnv argocd.Env
	// ArgocdInitPlugin is the name of plugin associated to the init
	// argocd application or is empty is no plugin is used
	ArgocdInitPlugin string
	// ArgocdInitPluginEnv is the args of plugin associated to the init
	// argocd application or is nil if no plugin is used.
	ArgocdInitPluginEnv argocd.Env
}

ClusterDefConfig contains global parameters of the ClusterDef operator. Typical operators are the location and credentials of the snapshot repository, location of base cluster models and infrastructure parameters.

type ClusterDefReconciler

type ClusterDefReconciler struct {
	client.Client
	Log    logr.Logger
	Scheme *runtime.Scheme
	State  map[string]*ClusterDefStateCache
	Config *ClusterDefConfig
}

ClusterDefReconciler reconciles a ClusterDef object

func (*ClusterDefReconciler) CreateSyncPod

func (r *ClusterDefReconciler) CreateSyncPod(
	clusterDef *gitopsv1.ClusterDef,
	cache *ClusterDefStateCache,
	log logr.Logger,
) error

CreateSyncPod creates the pod and its associated config map for a given repository

func (*ClusterDefReconciler) GetConfig

func (r *ClusterDefReconciler) GetConfig(ctx context.Context, log logr.Logger) error

GetConfig retrieves the global configuration of the controller This is only performed on the first run of the reconcile loop. Then the configuration is memoized in the ClusterDefReconciler data structure.

func (*ClusterDefReconciler) Reconcile

func (r *ClusterDefReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error)

Reconcile implements the core logic

func (*ClusterDefReconciler) SetupWithManager

func (r *ClusterDefReconciler) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager registers the controller for ClusterDef

func (*ClusterDefReconciler) UpdateConditions

func (r *ClusterDefReconciler) UpdateConditions(
	cache *ClusterDefStateCache,
	nsName types.NamespacedName,
	conditionType gitopsv1.ClusterDefConditionType,
	status metav1.ConditionStatus, reason string, message string,
) error

UpdateConditions method update the status of a clusterDef resource

type ClusterDefStateCache

type ClusterDefStateCache struct {
	// ClusterName is the name of target cluster-api definition
	ClusterName string
	// ClusterNamespace is the namespace of target cluster-api definition
	ClusterNamespace string
	// Kubeconfig is the config of target
	Kubeconfig *clientapi.Config
	// ServerURL is the cached URL of the workload cluster API endpoint
	ServerURL string
	// TransientState describes how far are we in the discovery of elements to create second application
	State TransientState
	// TargetClient is a kubernetes client for the target (workload) cluster
	TargetClient *clientgo.Clientset
	// LastEvolution records when the state changed last.
	// It is used for timeout (reset the cache)
	LastEvolution time.Time
}

ClusterDefStateCache maintains the transient state of the reconciler. During the Registered phase the reconciler needs several information that may take time to obtain once they are obtained they are kept in the cache but could be recovered if the reconciler is restarted.

type TransientState

type TransientState int

TransientState is the state of reconciler during the creation of Init application

const (
	// TSRegistered is used when only the cache exists
	TSRegistered TransientState = iota
	// TSCreateSnapshot is used when we create the snapshot
	TSCreateSnapshot
	// TSFirstSync is used as soon as a first application is found
	TSFirstSync
	// TSClusterFound is used when the Cluster Api definition is deployed
	TSClusterFound
	// TSKubeConfigFound is used when the Kubeconfig secret is found
	TSKubeConfigFound
	// TSCommunicating is used when the reconciler communicates with target cluster
	TSCommunicating
	// TSAppLaunched is used when the application for init has been launched
	TSAppLaunched
	// TSAppDeployed is used when the application for init is deployed.
	TSAppDeployed
)

Jump to

Keyboard shortcuts

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