diff --git a/applications/authentik/ldap/deployment.yaml b/applications/authentik/ldap/deployment.yaml new file mode 100644 index 0000000..0d58c71 --- /dev/null +++ b/applications/authentik/ldap/deployment.yaml @@ -0,0 +1,46 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: authentik-ldap + namespace: authentik +spec: + replicas: 1 + selector: + matchLabels: + app: authentik-ldap + template: + metadata: + labels: + app: authentik-ldap + spec: + containers: + - name: ldap + image: ghcr.io/goauthentik/ldap:2026.8.0 + ports: + - containerPort: 3389 + name: ldap + - containerPort: 6636 + name: ldaps + - containerPort: 9300 + name: metrics + envFrom: + - secretRef: + name: authentik-ldap-secrets + livenessProbe: + httpGet: + path: /outpost.goauthentik.io/ping + port: 9300 + initialDelaySeconds: 10 + periodSeconds: 30 + readinessProbe: + httpGet: + path: /outpost.goauthentik.io/ping + port: 9300 + initialDelaySeconds: 5 + periodSeconds: 10 + resources: + requests: + cpu: 50m + memory: 128Mi + limits: + memory: 256Mi diff --git a/applications/authentik/ldap/infisicalsecret.yaml b/applications/authentik/ldap/infisicalsecret.yaml new file mode 100644 index 0000000..26fbe28 --- /dev/null +++ b/applications/authentik/ldap/infisicalsecret.yaml @@ -0,0 +1,24 @@ +apiVersion: secrets.infisical.com/v1alpha1 +kind: InfisicalSecret +metadata: + name: authentik-ldap-secrets + namespace: infisical +spec: + hostAPI: https://infisical.jsme.be + resyncInterval: 30 + authentication: + kubernetesAuth: + identityId: "5458def7-7c63-40d2-95da-41c614d0933a" + serviceAccountRef: + name: infisical-auth + namespace: infisical + autoCreateServiceAccountToken: true + secretsScope: + projectSlug: "kubernetes" + envSlug: "prod" + secretsPath: "/authentik/authentik-ldap" + recursive: false + managedSecretReference: + secretName: authentik-ldap-secrets + secretNamespace: authentik + secretType: Opaque diff --git a/applications/authentik/ldap/service.yaml b/applications/authentik/ldap/service.yaml new file mode 100644 index 0000000..8d0ee28 --- /dev/null +++ b/applications/authentik/ldap/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: authentik-ldap + namespace: authentik +spec: + selector: + app: authentik-ldap + ports: + - name: ldap + port: 3389 + targetPort: 3389 + - name: metrics + port: 9300 + targetPort: 9300 diff --git a/applications/authentik/ldap/tcproute.yaml b/applications/authentik/ldap/tcproute.yaml new file mode 100644 index 0000000..33d66b3 --- /dev/null +++ b/applications/authentik/ldap/tcproute.yaml @@ -0,0 +1,22 @@ +apiVersion: gateway.networking.k8s.io/v1alpha2 +kind: TCPRoute +metadata: + name: authentik-ldap + namespace: authentik +spec: + parentRefs: + - group: gateway.networking.k8s.io + kind: Gateway + name: gateway-internal + namespace: envoy-gateway + sectionName: authentik-ldap + - group: gateway.networking.k8s.io + kind: Gateway + name: gateway-internal + namespace: envoy-gateway + sectionName: authentik-ldaps + rules: + # The gateway terminates TLS on 636, so both listeners hit the plaintext port + - backendRefs: + - name: authentik-ldap + port: 3389 diff --git a/infra/envoy-gateway/authentik/authentik-ldap-certificate.yaml b/infra/envoy-gateway/authentik/authentik-ldap-certificate.yaml new file mode 100644 index 0000000..bc137b4 --- /dev/null +++ b/infra/envoy-gateway/authentik/authentik-ldap-certificate.yaml @@ -0,0 +1,14 @@ +apiVersion: cert-manager.io/v1 +kind: Certificate +metadata: + name: authentik-ldap-tls + namespace: envoy-gateway +spec: + secretName: authentik-ldap-tls + privateKey: + rotationPolicy: Always + issuerRef: + name: azure-dns + kind: ClusterIssuer + dnsNames: + - ldap.jsme.be diff --git a/infra/envoy-gateway/authentik/authentik-ldap-gateway-patch.yaml b/infra/envoy-gateway/authentik/authentik-ldap-gateway-patch.yaml new file mode 100644 index 0000000..6fbdc0c --- /dev/null +++ b/infra/envoy-gateway/authentik/authentik-ldap-gateway-patch.yaml @@ -0,0 +1,37 @@ +# TCP listeners for the authentik LDAP outpost. kinds must be set explicitly: +# TCP allows nothing by default and TLS defaults to TLSRoute. +- op: add + path: /spec/listeners/- + value: + name: authentik-ldap + protocol: TCP + port: 389 + allowedRoutes: + kinds: + - kind: TCPRoute + namespaces: + from: Selector + selector: + matchLabels: + kubernetes.io/metadata.name: authentik +- op: add + path: /spec/listeners/- + value: + name: authentik-ldaps + protocol: TLS + port: 636 + # No hostname: LDAP clients cannot be relied on to send SNI + tls: + mode: Terminate + certificateRefs: + - kind: Secret + name: authentik-ldap-tls + namespace: envoy-gateway + allowedRoutes: + kinds: + - kind: TCPRoute + namespaces: + from: Selector + selector: + matchLabels: + kubernetes.io/metadata.name: authentik diff --git a/infra/envoy-gateway/kustomization.yaml b/infra/envoy-gateway/kustomization.yaml index 24ff5ae..a15145c 100644 --- a/infra/envoy-gateway/kustomization.yaml +++ b/infra/envoy-gateway/kustomization.yaml @@ -23,6 +23,7 @@ resources: # Certificates - authentik/authentik-certificate.yaml + - authentik/authentik-ldap-certificate.yaml - argocd/argocd-certificate.yaml - bentopdf/bentopdf-certificate.yaml - gitea/gitea-certificate.yaml @@ -70,6 +71,12 @@ patches: kind: Gateway name: gateway-internal path: authentik/authentik-gateway-patch.yaml + - target: + group: gateway.networking.k8s.io + version: v1 + kind: Gateway + name: gateway-internal + path: authentik/authentik-ldap-gateway-patch.yaml - target: group: gateway.networking.k8s.io version: v1