Documentation ¶
Index ¶
- Constants
- Variables
- func AgentAnnotationsWithOwnerRef(instance *agentv1alpha1.Agent) map[string]string
- func AgentControllerClientCertResourceName(instance *agentv1alpha1.Agent) string
- func AgentEnv(instance *agentv1alpha1.Agent, agentGroup string) []corev1.EnvVar
- func AgentResourceName(instance *agentv1alpha1.Agent) string
- func AgentServiceAccountName(instance *agentv1alpha1.Agent) string
- func AgentVolumeMounts(agentSpec agentv1alpha1.AgentSpec) []corev1.VolumeMount
- func AgentVolumes(instance *agentv1alpha1.Agent) []corev1.Volume
- func CheckAndGenerateCertForOperator(config *rest.Config) error
- func CheckCertificate() bool
- func ClusterRoleBindingMutate(crb *rbacv1.ClusterRoleBinding, roleRef rbacv1.RoleRef, ...) controllerutil.MutateFn
- func ClusterRoleMutate(cr *rbacv1.ClusterRole, rules []rbacv1.PolicyRule) controllerutil.MutateFn
- func CommonLabels(commonLabels map[string]string, instanceName, component string) map[string]string
- func ConfigMapMutate(cm *corev1.ConfigMap, files map[string]string) controllerutil.MutateFn
- func ContainerEnvFrom(controllerSpec common.CommonSpec) []corev1.EnvFromSource
- func ContainerProbes(spec common.CommonSpec, scheme corev1.URIScheme) (*corev1.Probe, *corev1.Probe)
- func ContainerSecurityContext(containerSecurityContext common.ContainerSecurityContext) *corev1.SecurityContext
- func ControllerAnnotationsWithOwnerRef(instance *controllerv1alpha1.Controller) map[string]string
- func ControllerEnv(instance *controllerv1alpha1.Controller) []corev1.EnvVar
- func ControllerResourcesName(instance *controllerv1alpha1.Controller) string
- func ControllerResourcesNamespacedName(instance *controllerv1alpha1.Controller) string
- func ControllerServiceAccountName(instance *controllerv1alpha1.Controller) string
- func ControllerVolumeMounts(controllerSpec common.CommonSpec) []corev1.VolumeMount
- func ControllerVolumes(instance *controllerv1alpha1.Controller) []corev1.Volume
- func GenerateCertificate(dnsPrefix, namespace string) (*bytes.Buffer, *bytes.Buffer, *bytes.Buffer, error)
- func GetCertificateDNSNames(dnsPrefix, namespace string) []string
- func GetControllerClientCert(endpoints []string, client_ client.Client, ctx context.Context) []byte
- func GetOrGenerateCertificate(client client.Client, instance *controllerv1alpha1.Controller) (*bytes.Buffer, *bytes.Buffer, *bytes.Buffer, error)
- func GetPort(addr string) (int32, error)
- func ImagePullSecrets(image common.Image) []corev1.LocalObjectReference
- func ImageString(image common.Image, repository string) string
- func MergeContainers(common, extra []corev1.Container) []corev1.Container
- func MergeEnvFromSources(common, extra []corev1.EnvFromSource) []corev1.EnvFromSource
- func MergeEnvVars(common, extra []corev1.EnvVar) []corev1.EnvVar
- func MergeImagePullSecrets(common, extra []corev1.LocalObjectReference) []corev1.LocalObjectReference
- func MergeVolumeMounts(common, extra []corev1.VolumeMount) []corev1.VolumeMount
- func MergeVolumes(common, extra []corev1.Volume) []corev1.Volume
- func MutatingWebhookConfigurationMutate(mwc *admissionregistrationv1.MutatingWebhookConfiguration, ...) controllerutil.MutateFn
- func PodSecurityContext(podSecurityContext common.PodSecurityContext) *corev1.PodSecurityContext
- func SecretDataKey(spec *common.SecretKeyRef) string
- func SecretMutate(secret *corev1.Secret, data map[string][]byte, ...) controllerutil.MutateFn
- func SecretName(instance, component string, spec *common.APIKeySecret) string
- func SelectorLabels(instance, component string) map[string]string
- func ServiceAccountMutate(sa *corev1.ServiceAccount, automountServiceAccountToken *bool) controllerutil.MutateFn
- func ServiceMutate(svc *corev1.Service, spec corev1.ServiceSpec) controllerutil.MutateFn
- func SyncMaps(src, dst map[string]string) map[string]string
- func UpdateResource(client client.Client, ctx context.Context, instance client.Object) error
- func ValidatingWebhookConfigurationMutate(vwc *admissionregistrationv1.ValidatingWebhookConfiguration, ...) controllerutil.MutateFn
- func WriteFile(filepath string, sCert *bytes.Buffer) error
Constants ¶
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 ¶
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 ¶
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 ¶
CommonLabels prepares common labels used by all resources.
func ConfigMapMutate ¶
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
GetCertificateDNSNames generates DNS names for the certificate.
func GetControllerClientCert ¶
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 ImagePullSecrets ¶
func ImagePullSecrets(image common.Image) []corev1.LocalObjectReference
ImagePullSecrets prepares ImagePullSecrets string slice from the provided Image struct.
func ImageString ¶
ImageString prepares image string from the provided Image struct.
func MergeContainers ¶
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 ¶
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 ¶
MergeVolumes merges common and provided extra Volume of Kubernetes Pod.
func MutatingWebhookConfigurationMutate ¶
func MutatingWebhookConfigurationMutate(mwc *admissionregistrationv1.MutatingWebhookConfiguration, webhooks []admissionregistrationv1.MutatingWebhook) controllerutil.MutateFn
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 ¶
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 UpdateResource ¶
UpdateResource updates the Aperture resource in Kubernetes.
func ValidatingWebhookConfigurationMutate ¶
func ValidatingWebhookConfigurationMutate(vwc *admissionregistrationv1.ValidatingWebhookConfiguration, webhooks []admissionregistrationv1.ValidatingWebhook) controllerutil.MutateFn
ValidatingWebhookConfigurationMutate returns a mutate function that can be used to update the ValidatingWebhookConfiguration's spec.
Types ¶
This section is empty.