controllers

package
v0.12.1 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2022 License: AGPL-3.0 Imports: 32 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"
	// 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"
	// ApertureFluxNinjaPlugin defines FluxNinja plugin name.
	ApertureFluxNinjaPlugin = "aperture-plugin-fluxninja"
	// DefaulterAnnotationKey defines annotation key for set defaults.
	DefaulterAnnotationKey = "fluxninja.com/set-defaults"
	// 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"
)

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"
	// 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 added in v0.3.0

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

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

func AgentEnv added in v0.3.0

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

AgentEnv prepares env resources for Agents' container.

func AgentVolumeMounts added in v0.3.0

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

AgentVolumeMounts prepares volumeMounts for Agents' container.

func AgentVolumes added in v0.3.0

func AgentVolumes(agentSpec agentv1alpha1.AgentSpec) []corev1.Volume

AgentVolumes prepares volumes for Agent.

func CheckAndGenerateCertForOperator

func CheckAndGenerateCertForOperator() error

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

func CheckCertificate added in v0.3.0

func CheckCertificate() bool

CheckCertificate checks if existing certificates are available.

func ClusterRoleBindingMutate added in v0.3.0

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 added in v0.3.0

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 added in v0.3.0

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

CommonLabels prepares common labels used by all resources.

func ConfigMapMutate added in v0.3.0

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 added in v0.3.0

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

ContainerEnvFrom prepares EnvFrom resource for Agent and Controllers' container.

func ContainerProbes added in v0.3.0

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

ContainerProbes prepares livenessProbe and readinessProbe based on the provided parameters.

func ContainerSecurityContext added in v0.3.0

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

ContainerSecurityContext prepares SecurityContext for containers based on the provided parameter.

func ControllerAnnotationsWithOwnerRef added in v0.3.0

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

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

func ControllerEnv added in v0.3.0

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

ControllerEnv prepares env resources for Controller' container.

func ControllerVolumeMounts added in v0.3.0

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

ControllerVolumeMounts prepares volumeMounts for Controllers' container.

func ControllerVolumes added in v0.3.0

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

ControllerVolumes prepares volumes for Controller.

func GenerateCertificate added in v0.3.0

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

GenerateCertificate generates certificate and stores it in the desired location.

func GetPort added in v0.3.0

func GetPort(addr string) (int32, error)

GetPort parses port value from the Address string.

func ImagePullSecrets added in v0.3.0

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

ImagePullSecrets prepares ImagePullSecrets string slice from the provided Image struct.

func ImageString added in v0.3.0

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

ImageString prepares image string from the provided Image struct.

func MergeContainers added in v0.3.0

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

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

func MergeEnvFromSources added in v0.3.0

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

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

func MergeEnvVars added in v0.3.0

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

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

func MergeImagePullSecrets added in v0.3.0

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

MergeImagePullSecrets merges common and provided Image Pull Secrets of Kubernetes.

func MergeVolumeMounts added in v0.3.0

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

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

func MergeVolumes added in v0.3.0

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

MergeVolumes merges common and provided extra Volume of Kubernetes Pod.

func MutatingWebhookConfigurationMutate added in v0.3.0

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

func PodSecurityContext added in v0.3.0

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

PodSecurityContext prepares SecurityContext for Pods based on the provided parameter.

func SecretDataKey added in v0.3.0

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 added in v0.3.0

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

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

func SecretName added in v0.3.0

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 added in v0.3.0

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

SelectorLabels prepares the labels used for Selector.

func ServiceAccountMutate added in v0.3.0

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 added in v0.3.0

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 UpdateResource added in v0.3.0

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

UpdateResource updates the Aperture resource in Kubernetes.

func ValidatingWebhookConfigurationMutate added in v0.3.0

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

func WriteFile added in v0.3.0

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