controllers

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package controllers implements functions for manipulating CAPI generated cluster secrets into Argo definitions.

Index

Constants

View Source
const CapiClusterSecretType corev1.SecretType = "cluster.x-k8s.io/secret"

CapiClusterSecretType represents the CAPI managed secret type.

Variables

View Source
var (
	// ArgoNamespace represents the Namespace that hold ArgoCluster secrets.
	ArgoNamespace string
	// TestKubeConfig represents
	TestKubeConfig *rest.Config
)
View Source
var (
	// EnableGarbageCollection enables experimental GC feature
	EnableGarbageCollection bool

	// EnableNamespacedNames represents a mode where the cluster name is always
	// prepended by the cluster namespace in all generated secrets
	EnableNamespacedNames bool
)

Functions

func BuildClusterName added in v0.1.6

func BuildClusterName(s string, namespace string) string

BuildClusterName returns cluster name after transformations applied (with/without namespace suffix, etc).

func BuildNamespacedName

func BuildNamespacedName(s string, namespace string) types.NamespacedName

BuildNamespacedName returns k8s native object identifier.

func GetArgoCommonLabels added in v0.1.12

func GetArgoCommonLabels() map[string]string

GetArgoCommonLabels holds a map of labels that reconciled objects must have.

func ValidateCapiNaming

func ValidateCapiNaming(n types.NamespacedName) bool

ValidateCapiNaming validates CAPI kubeconfig naming convention.

func ValidateCapiSecret

func ValidateCapiSecret(s *corev1.Secret) error

ValidateCapiSecret validates that we got proper defined types for a given secret.

func ValidateObjectOwner added in v0.1.7

func ValidateObjectOwner(s corev1.Secret) error

ValidateObjectOwner checks whether reconciled object is managed by CACO or not.

Types

type ArgoCluster

type ArgoCluster struct {
	NamespacedName  types.NamespacedName
	ClusterName     string
	ClusterServer   string
	ClusterLabels   map[string]string
	TakeAlongLabels map[string]string
	ClusterConfig   ArgoConfig
}

ArgoCluster holds all information needed for CAPI --> Argo Cluster conversion

func NewArgoCluster

func NewArgoCluster(c *CapiCluster, s *corev1.Secret, cluster *clusterv1.Cluster) (*ArgoCluster, error)

NewArgoCluster return a new ArgoCluster

func (*ArgoCluster) ConvertToSecret

func (a *ArgoCluster) ConvertToSecret() (*corev1.Secret, error)

ConvertToSecret converts an ArgoCluster into k8s native secret object.

type ArgoConfig

type ArgoConfig struct {
	TLSClientConfig *ArgoTLS `json:"tlsClientConfig,omitempty"`
	BearerToken     *string  `json:"bearerToken,omitempty"`
}

ArgoConfig represents Argo Cluster.JSON.config

type ArgoTLS

type ArgoTLS struct {
	CaData   *string `json:"caData,omitempty"`
	CertData *string `json:"certData,omitempty"`
	KeyData  *string `json:"keyData,omitempty"`
}

ArgoTLS represents Argo Cluster.JSON.config.tlsClientConfig

type Capi2Argo

type Capi2Argo struct {
	client.Client
	Log    logr.Logger
	Scheme *runtime.Scheme
}

Capi2Argo reconciles a Secret object

func (*Capi2Argo) Reconcile

func (r *Capi2Argo) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)

Reconcile holds all the logic for syncing CAPI to Argo Clusters.

func (*Capi2Argo) SetupWithManager

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

SetupWithManager ..

type CapiCluster

type CapiCluster struct {
	Name       string     `yaml:"name"`
	Namespace  string     `yaml:"namespace"`
	KubeConfig KubeConfig `yaml:"kubeConfig"`
}

CapiCluster is an one-on-one representation of KubeConfig fields.

func NewCapiCluster

func NewCapiCluster(name, namespace string) *CapiCluster

NewCapiCluster returns an empty CapiCluster type.

func (*CapiCluster) Unmarshal

func (c *CapiCluster) Unmarshal(s *corev1.Secret) error

Unmarshal k8s secret into CapiCluster type.

type Cluster

type Cluster struct {
	Name    string      `yaml:"name"`
	Cluster ClusterInfo `yaml:"cluster"`
}

Cluster represents kubeconfig.[]Clusters.Cluster fields.

type ClusterInfo

type ClusterInfo struct {
	CaData string `yaml:"certificate-authority-data"`
	Server string `yaml:"server"`
}

ClusterInfo represents kubeconfig.[]Clusters.Cluster.Clusterinfo fields.

type KubeConfig added in v0.1.12

type KubeConfig struct {
	APIVersion string    `yaml:"apiVersion"`
	Kind       string    `yaml:"kind"`
	Clusters   []Cluster `yaml:"clusters"`
	Users      []User    `yaml:"users"`
}

KubeConfig is an one-on-one representation of KubeConfig fields.

type User

type User struct {
	Name string   `yaml:"name"`
	User UserInfo `yaml:"user"`
}

User represents kubeconfig.[]Users fields.

type UserInfo

type UserInfo struct {
	CertData *string `yaml:"client-certificate-data,omitempty"`
	KeyData  *string `yaml:"client-key-data,omitempty"`
	Token    *string `yaml:"token,omitempty"`
}

UserInfo represents kubeconfig.[]Users.User fields.

Jump to

Keyboard shortcuts

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