controllers

package
v2.27.0 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2023 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MutatingWebhookURI defines the URI for the Mutating Webhook for Pods.
	MutatingWebhookURI = "/mutate-pod"
	// AgentMutatingWebhookURI defines the URI for the Mutating Webhook for Agents.
	AgentMutatingWebhookURI = "agent-defaulter"
	// ControllerMutatingWebhookURI defines the URI for the Mutating Webhook for Controllers.
	ControllerMutatingWebhookURI = "controller-defaulter"
	// SecretKey defines the Kubernetes secret data key.
	SecretKey = "apiKey"
	// AppName defines name of the application.
	AppName = "aperture"
	// OperatorName defines operator name.
	OperatorName = AppName + "-operator"
	// ControllerName defines controller name.
	ControllerName = "controller"
	// ControllerServiceName defines controller service name.
	ControllerServiceName = AppName + "-controller"
	// AgentServiceName defines agent service name.
	AgentServiceName = AppName + "-agent"
	// PodMutatingWebhookName defines agent service name.
	PodMutatingWebhookName = AppName + "-injector"
	// AgentMutatingWebhookName defines agent service name.
	AgentMutatingWebhookName = AppName + "-" + AgentMutatingWebhookURI
	// ControllerMutatingWebhookName defines Controller Mutating Webhook Name.
	ControllerMutatingWebhookName = AppName + "-" + ControllerMutatingWebhookURI
	// ValidatingWebhookName defines Validating Webhook name.
	ValidatingWebhookName = ControllerServiceName + "-webhook"
	// FinalizerName defines finalizer name.
	FinalizerName = "fluxninja.com/finalizer"
	// SidecarKey defines sidecar key.
	SidecarKey = "sidecar.fluxninja.com"
	// SidecarAnnotationKey defines sidecar annotation key.
	SidecarAnnotationKey = SidecarKey + "/injection"
	// SidecarLabelKey defines sidecar label key.
	SidecarLabelKey = AppName + "-injection"
	// AgentGroupKey defines agent group key.
	AgentGroupKey = SidecarKey + "/agent-group"
	// V1Version defines v1 version.
	V1Version = "v1"
	// V1Alpha1Version defines v1alpha1 version.
	V1Alpha1Version = "v1alpha1"
	// Enabled string.
	Enabled = "enabled"
	// ValidatingWebhookSvcName defines Validating Webhook service name.
	ValidatingWebhookSvcName = ValidatingWebhookName
	// WebhookClientCertName defines client cert name.
	WebhookClientCertName = "client.pem"
	// ControllerCertKeyName defines controller key file name.
	ControllerCertKeyName = "key.pem"
	// ControllerCertName defines controller cert name.
	ControllerCertName = "crt.pem"
	// ControllerCertPath defines controller cert path.
	ControllerCertPath = "/etc/aperture/aperture-controller/certs"
	// Server string.
	Server = "server"
	// TCP string.
	TCP = "TCP"
	// DistCache string.
	DistCache = "dist-cache"
	// MemberList string.
	MemberList = "memberlist"
	// DefaulterAnnotationKey defines annotation key for set defaults.
	DefaulterAnnotationKey = "fluxninja.com/set-defaults"
	// AgentModeChangeAnnotationKey defines annotation key for change in Agent installation mode.
	AgentModeChangeAnnotationKey = "fluxninja.com/installation-mode-change"
	// FailedStatus string.
	FailedStatus = "failed"
	// PolicyValidatingWebhookName defines Validating Webhook name for Policy.
	PolicyValidatingWebhookName = "policy-validator.fluxninja.com"
	// PolicyValidatingWebhookURI defines Validating Webhook URI for Policy.
	PolicyValidatingWebhookURI = "/validate/policy"
	// OtelDebugPort string.
	OtelDebugPort = "otel-debug"
	// OtelHealthcheckPort string.
	OtelHealthcheckPort = "otel-health"
	// OtelPprofPort string.
	OtelPprofPort = "otel-pprof"
	// OtelZpagesPort string.
	OtelZpagesPort = "otel-zpages"
	// MinimumKubernetesVersion defines minimum kubernetes version required by Aperture.
	MinimumKubernetesVersion = "v1.23.0"
	// ControllerClientCertKey defines controller client cert key.
	ControllerClientCertKey = "controller-ca.pem"
	// AgentControllerClientCertPath defines Controller client cert path in Agent container.
	AgentControllerClientCertPath = "/etc/aperture/aperture-agent/certs"
	// AgentControllerClientCertCMName defines Controller client cert ConfigMap name.
	AgentControllerClientCertCMName = AgentServiceName + "-client-cert"
	// OperatorCertName defines operator cert name.
	OperatorCertName = "crt.pem"
	// OperatorCertKeyName defines operator key name.
	OperatorCertKeyName = "key.pem"
	// OperatorCAName defines operator CA name.
	OperatorCAName = "ca.pem"
)

Variables

View Source
var (
	// PolicyFilePath defines default path for the policies on Controller.
	PolicyFilePath = filepath.Join("/", "etc", "aperture", "aperture-controller", "policies")
	// Test string.
	Test = "test"
	// TestTwo string.
	TestTwo = "test2"
	// TestDigest string.
	TestDigest = "sha256:1234567890"
	// TestArray array.
	TestArray = []string{Test}
	// TestArrayTwo array.
	TestArrayTwo = []string{TestTwo, Test}
	// TestMap map.
	TestMap = map[string]string{
		Test: Test,
	}
	// TestMapTwo map.
	TestMapTwo = map[string]string{
		Test:    Test,
		TestTwo: TestTwo,
	}
	// K8sClient defines Kubernetes client for tests.
	K8sClient client.Client
	// K8sDynamicClient defines Kubernetes Dynamic client for tests.
	K8sDynamicClient dynamic.Interface
	// K8sManager defines Kubernetes Manager for tests.
	K8sManager ctrl.Manager
	// Ctx context.
	Ctx context.Context
	// DefaultAgentInstance defines default Agent instance for tests.
	DefaultAgentInstance *agentv1alpha1.Agent
	// DefaultControllerInstance defines default Controller instance for tests.
	DefaultControllerInstance *controllerv1alpha1.Controller
	// CertDir defines cert directory for tests.
	CertDir = filepath.Join(".", "certs")
	// PoliciesDir defines policies directory for tests.
	PoliciesDir = filepath.Join(".", "policies")
	// CurrentKubernetesVersion is pointer of type `apimachineryversion.Version`, which defines local kubernetes version.
	CurrentKubernetesVersion *apimachineryversion.Version
	// MinimumKubernetesVersionBool defines if minimum kubernetes version required by Aperture is met.
	MinimumKubernetesVersionBool bool
)

Functions

func AgentAnnotationsWithOwnerRef

func AgentAnnotationsWithOwnerRef(instance *agentv1alpha1.Agent) map[string]string

AgentAnnotationsWithOwnerRef prepares the map for Annotation with reference to the creator instance.

func AgentControllerClientCertResourceName added in v2.22.0

func AgentControllerClientCertResourceName(instance *agentv1alpha1.Agent) string

AgentControllerClientCertResourceName generate a name for the agent controller client certificate.

func AgentEnv

func AgentEnv(instance *agentv1alpha1.Agent, agentGroup string) []corev1.EnvVar

AgentEnv prepares env resources for Agents' container.

func AgentResourceName added in v2.22.0

func AgentResourceName(instance *agentv1alpha1.Agent) string

AgentResourceName generate a name for the agent related resources.

func AgentServiceAccountName added in v2.22.0

func AgentServiceAccountName(instance *agentv1alpha1.Agent) string

AgentServiceAccountName generate a name for the agent service account.

func AgentVolumeMounts

func AgentVolumeMounts(agentSpec agentv1alpha1.AgentSpec) []corev1.VolumeMount

AgentVolumeMounts prepares volumeMounts for Agents' container.

func AgentVolumes

func AgentVolumes(instance *agentv1alpha1.Agent) []corev1.Volume

AgentVolumes prepares volumes for Agent.

func CheckAndGenerateCertForOperator

func CheckAndGenerateCertForOperator(config *rest.Config) error

CheckAndGenerateCertForOperator checks if existing certificates are present and creates new if not present.

func CheckCertificate

func CheckCertificate() bool

CheckCertificate checks if existing certificates are available.

func ClusterRoleBindingMutate

func ClusterRoleBindingMutate(crb *rbacv1.ClusterRoleBinding, roleRef rbacv1.RoleRef, subjects []rbacv1.Subject) controllerutil.MutateFn

ClusterRoleBindingMutate returns a mutate function that can be used to update the Service's service spec.

func ClusterRoleMutate

func ClusterRoleMutate(cr *rbacv1.ClusterRole, rules []rbacv1.PolicyRule) controllerutil.MutateFn

ClusterRoleMutate returns a mutate function that can be used to update the ClusterRole's spec.

func CommonLabels

func CommonLabels(commonLabels map[string]string, instanceName, component string) map[string]string

CommonLabels prepares common labels used by all resources.

func ConfigMapMutate

func ConfigMapMutate(cm *corev1.ConfigMap, files map[string]string) controllerutil.MutateFn

ConfigMapMutate returns a mutate function that can be used to update the ConfigMap's configuration data.

func ContainerEnvFrom

func ContainerEnvFrom(controllerSpec common.CommonSpec) []corev1.EnvFromSource

ContainerEnvFrom prepares EnvFrom resource for Agent and Controllers' container.

func ContainerProbes

func ContainerProbes(spec common.CommonSpec, scheme corev1.URIScheme) (*corev1.Probe, *corev1.Probe)

ContainerProbes prepares livenessProbe and readinessProbe based on the provided parameters.

func ContainerSecurityContext

func ContainerSecurityContext(containerSecurityContext common.ContainerSecurityContext) *corev1.SecurityContext

ContainerSecurityContext prepares SecurityContext for containers based on the provided parameter.

func ControllerAnnotationsWithOwnerRef

func ControllerAnnotationsWithOwnerRef(instance *controllerv1alpha1.Controller) map[string]string

ControllerAnnotationsWithOwnerRef prepares the map for Annotation with reference to the creator instance.

func ControllerEnv

func ControllerEnv(instance *controllerv1alpha1.Controller) []corev1.EnvVar

ControllerEnv prepares env resources for Controller' container.

func ControllerResourcesName added in v2.8.0

func ControllerResourcesName(instance *controllerv1alpha1.Controller) string

ControllerResourcesName generates a name for the controller related resources.

func ControllerResourcesNamespacedName added in v2.8.0

func ControllerResourcesNamespacedName(instance *controllerv1alpha1.Controller) string

ControllerResourcesNamespacedName generates a name for the controller related resources.

func ControllerServiceAccountName added in v2.22.0

func ControllerServiceAccountName(instance *controllerv1alpha1.Controller) string

ControllerServiceAccountName generate a name for the controller service account.

func ControllerVolumeMounts

func ControllerVolumeMounts(controllerSpec common.CommonSpec) []corev1.VolumeMount

ControllerVolumeMounts prepares volumeMounts for Controllers' container.

func ControllerVolumes

func ControllerVolumes(instance *controllerv1alpha1.Controller) []corev1.Volume

ControllerVolumes prepares volumes for Controller.

func GenerateCertificate

func GenerateCertificate(dnsPrefix, namespace string) (*bytes.Buffer, *bytes.Buffer, *bytes.Buffer, error)

GenerateCertificate generates certificate and stores it in the desired location.

func GetCertificateDNSNames added in v2.8.0

func GetCertificateDNSNames(dnsPrefix, namespace string) []string

GetCertificateDNSNames generates DNS names for the certificate.

func GetControllerClientCert

func GetControllerClientCert(endpoints []string, client_ client.Client, ctx context.Context) []byte

GetControllerClientCert returns the controller client certificate from the controller configmap.

func GetOrGenerateCertificate

func GetOrGenerateCertificate(client client.Client, instance *controllerv1alpha1.Controller) (*bytes.Buffer, *bytes.Buffer, *bytes.Buffer, error)

GetOrGenerateCertificate returns the TLS/SSL certificates of the Controller.

func GetPort

func GetPort(addr string) (int32, error)

GetPort parses port value from the Address string.

func ImagePullSecrets

func ImagePullSecrets(image common.Image) []corev1.LocalObjectReference

ImagePullSecrets prepares ImagePullSecrets string slice from the provided Image struct.

func ImageString

func ImageString(image common.Image, repository string) string

ImageString prepares image string from the provided Image struct.

func MergeContainers

func MergeContainers(common, extra []corev1.Container) []corev1.Container

MergeContainers merges common and provided Container/Init Container of Kubernetes container.

func MergeEnvFromSources

func MergeEnvFromSources(common, extra []corev1.EnvFromSource) []corev1.EnvFromSource

MergeEnvFromSources merges common and provided extra Environment From of Kubernetes container.

func MergeEnvVars

func MergeEnvVars(common, extra []corev1.EnvVar) []corev1.EnvVar

MergeEnvVars merges common and provided extra Environment variables of Kubernetes container.

func MergeImagePullSecrets

func MergeImagePullSecrets(common, extra []corev1.LocalObjectReference) []corev1.LocalObjectReference

MergeImagePullSecrets merges common and provided Image Pull Secrets of Kubernetes.

func MergeVolumeMounts

func MergeVolumeMounts(common, extra []corev1.VolumeMount) []corev1.VolumeMount

MergeVolumeMounts merges common and provided extra Volume mounts of Kubernetes container.

func MergeVolumes

func MergeVolumes(common, extra []corev1.Volume) []corev1.Volume

MergeVolumes merges common and provided extra Volume of Kubernetes Pod.

func MutatingWebhookConfigurationMutate

MutatingWebhookConfigurationMutate returns a mutate function that can be used to update the MutatingWebhookConfiguration's spec.

func PodSecurityContext

func PodSecurityContext(podSecurityContext common.PodSecurityContext) *corev1.PodSecurityContext

PodSecurityContext prepares SecurityContext for Pods based on the provided parameter.

func SecretDataKey

func SecretDataKey(spec *common.SecretKeyRef) string

SecretDataKey fetches Key for ApiKey secret from config or generates the Key if not present in config.

func SecretMutate

func SecretMutate(secret *corev1.Secret, data map[string][]byte, ownerReferences []v1.OwnerReference) controllerutil.MutateFn

SecretMutate returns a mutate function that can be used to update the Secret's data.

func SecretName

func SecretName(instance, component string, spec *common.APIKeySecret) string

SecretName fetches name for ApiKey secret from config or generates the name if not present in config.

func SelectorLabels

func SelectorLabels(instance, component string) map[string]string

SelectorLabels prepares the labels used for Selector.

func ServiceAccountMutate

func ServiceAccountMutate(sa *corev1.ServiceAccount, automountServiceAccountToken *bool) controllerutil.MutateFn

ServiceAccountMutate returns a mutate function that can be used to update the ClusterRole's spec.

func ServiceMutate

func ServiceMutate(svc *corev1.Service, spec corev1.ServiceSpec) controllerutil.MutateFn

ServiceMutate returns a mutate function that can be used to update the Service's spec.

func SyncMaps added in v2.24.1

func SyncMaps(src, dst map[string]string) map[string]string

SyncMaps syncs the dst map with the src map.

func UpdateResource

func UpdateResource(client client.Client, ctx context.Context, instance client.Object) error

UpdateResource updates the Aperture resource in Kubernetes.

func ValidatingWebhookConfigurationMutate

ValidatingWebhookConfigurationMutate returns a mutate function that can be used to update the ValidatingWebhookConfiguration's spec.

func WriteFile

func WriteFile(filepath string, sCert *bytes.Buffer) error

WriteFile writes data in the file at the given path.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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