Deploy coroot behind oauth2-proxy (#605)

Coroot gives eBPF-based service maps, tracing and RCA for the cluster; the community edition has no OIDC, so it sits behind oauth2-proxy.

- add coroot-operator chart 0.10.8 in coroot-system (platform)
- add a Coroot CR: 2 replicas on CNPG, ClickHouse 2 + keeper 3, metrics via vmcluster/main, pinned images
- agents send keyless; Coroot binds an empty key to its single default project
- front coroot.unkin.net with oauth2-proxy (Authentik, akP-coroot-admin); Coroot grants Admin to anonymous
- restrict Coroot ingress to oauth2-proxy and the agents; PDBs, anti-affinity, DNS, wildcard cert, schema

Requires IUCLabs/terraform-artifactapi#7 and IUCLabs/terraform-authentik#7.

Reviewed-on: #605
Co-authored-by: unkin-agent <unkin-agent@unkin.net>
Co-committed-by: unkin-agent <unkin-agent@unkin.net>
This commit was merged in pull request #605.
This commit is contained in:
2026-11-27 07:55:38 +11:00
committed by BenVincent
parent ad369d0f7e
commit c090015686
27 changed files with 8361 additions and 2 deletions
@@ -0,0 +1,14 @@
---
apiVersion: bind.unkin.net/v1alpha1
kind: DNSRecord
metadata:
name: coroot-dns-internal
namespace: bind-internal
spec:
zoneRef: unkin-net
name: coroot
type: A
ttl: 600
values:
# traefik-external (DMZ) gateway VIP.
- 198.18.199.0
@@ -7,6 +7,7 @@ resources:
- autocraft.yaml
- auth.yaml
- cheeztv.yaml
- coroot.yaml
- fafflix.yaml
# PRODUCTION CUTOVER RECORD — see git.yaml. Uncomment together with the
# record itself, and remove git-edge.yaml.
@@ -14,9 +14,9 @@ spec:
secretTemplate:
annotations:
reflector.v1.k8s.emberstack.com/reflection-allowed: "true"
reflector.v1.k8s.emberstack.com/reflection-allowed-namespaces: "cheeztv,arrstack,authentik,gitea,watchstate,mediamark,repospawner,haproxy,vlogs,grafana,mail,autocraft"
reflector.v1.k8s.emberstack.com/reflection-allowed-namespaces: "cheeztv,arrstack,authentik,gitea,watchstate,mediamark,repospawner,haproxy,vlogs,grafana,mail,autocraft,coroot"
reflector.v1.k8s.emberstack.com/reflection-auto-enabled: "true"
reflector.v1.k8s.emberstack.com/reflection-auto-namespaces: "cheeztv,arrstack,authentik,gitea,watchstate,mediamark,repospawner,haproxy,vlogs,grafana,mail,autocraft"
reflector.v1.k8s.emberstack.com/reflection-auto-namespaces: "cheeztv,arrstack,authentik,gitea,watchstate,mediamark,repospawner,haproxy,vlogs,grafana,mail,autocraft,coroot"
privateKey:
size: 4096
dnsNames:
@@ -0,0 +1,6 @@
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- namespace.yaml
+7
View File
@@ -0,0 +1,7 @@
---
apiVersion: v1
kind: Namespace
metadata:
labels:
app.kubernetes.io/name: coroot-system
name: coroot-system
+47
View File
@@ -0,0 +1,47 @@
---
# Per-cluster Ceph RGW bucket + owner user for CNPG backups, via cephrgw-operator.
apiVersion: ceph.unkin.net/v1alpha1
kind: ObjectStoreUser
metadata:
name: cnpg-coroot-backup
namespace: coroot
spec:
displayName: "CNPG backup owner (coroot)"
# RGW users are global; keep the uid namespace-qualified so it never collides.
uid: cnpg-coroot-backup
maxBuckets: 5
# Operator writes the S3 keys here; the Cluster's barmanObjectStore consumes them.
secretName: cnpg-coroot-backup-s3
# Keep the RGW user (and keys) on CR deletion so a restore can still reach the archive.
retainOnDelete: true
---
apiVersion: ceph.unkin.net/v1alpha1
kind: Bucket
metadata:
name: cnpg-coroot
namespace: coroot
spec:
placementTarget: ec
bucketName: cnpg-coroot
# The owner user has full read/write on its bucket; no extra BucketAccess grant.
ownerRef: cnpg-coroot-backup
versioning: false
tags:
app: coroot
purpose: cnpg-backup
# Never drop the backups if the CR is removed; retire buckets by hand.
retainOnDelete: true
---
# Nightly base backup under always-on WAL archiving (CNPG cron is 6-field, seconds first).
apiVersion: postgresql.cnpg.io/v1
kind: ScheduledBackup
metadata:
name: cnpg-coroot-nightly
namespace: coroot
spec:
schedule: "0 10 4 * * *"
immediate: false
backupOwnerReference: self
method: barmanObjectStore
cluster:
name: postgres
+82
View File
@@ -0,0 +1,82 @@
---
apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
name: postgres
namespace: coroot
spec:
affinity:
podAntiAffinityType: preferred
backup:
retentionPolicy: 30d
barmanObjectStore:
destinationPath: s3://cnpg-coroot
endpointURL: https://s3.ceph.unkin.net
# radosgw serves a Vault-PKI cert.
endpointCA:
name: vault-ca-cert
key: ca.crt
# Keys minted by the ObjectStoreUser in cnpg_backup.yaml; never hardcoded.
s3Credentials:
accessKeyId:
name: cnpg-coroot-backup-s3
key: AWS_ACCESS_KEY_ID
secretAccessKey:
name: cnpg-coroot-backup-s3
key: AWS_SECRET_ACCESS_KEY
# Path prefix within the bucket; keep stable across restores (see docs).
serverName: coroot
data:
compression: bzip2
jobs: 2
wal:
compression: zstd
maxParallel: 2
bootstrap:
initdb:
database: coroot
encoding: UTF8
localeCType: C
localeCollate: C
# CNPG mints the owner credentials in the postgres-app Secret.
owner: coroot
enablePDB: true
enableSuperuserAccess: false
failoverDelay: 0
imageName: ghcr.io/cloudnative-pg/postgresql:18.1-system-trixie
instances: 2
logLevel: info
monitoring:
customQueriesConfigMap:
- key: queries
name: cnpg-default-monitoring
disableDefaultQueries: false
enablePodMonitor: false
postgresql:
parameters:
max_connections: "200"
shared_buffers: 128MB
primaryUpdateMethod: restart
primaryUpdateStrategy: unsupervised
replicationSlots:
highAvailability:
enabled: true
slotPrefix: _cnpg_
synchronizeReplicas:
enabled: true
updateInterval: 30
resources:
limits:
cpu: 500m
memory: 512Mi
requests:
cpu: 50m
memory: 256Mi
smartShutdownTimeout: 180
startDelay: 3600
stopDelay: 1800
storage:
resizeInUseVolumes: true
size: 10Gi
storageClass: cephrbd-fast-delete
switchoverDelay: 3600
+33
View File
@@ -0,0 +1,33 @@
---
apiVersion: postgresql.cnpg.io/v1
kind: Pooler
metadata:
name: postgres-pooler-rw
namespace: coroot
spec:
cluster:
name: postgres
instances: 2
pgbouncer:
parameters:
default_pool_size: "50"
max_client_conn: "200"
paused: false
poolMode: session
template:
metadata:
labels:
app: pooler-rw
spec:
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: app
operator: In
values:
- pooler-rw
topologyKey: kubernetes.io/hostname
containers: []
type: rw
+114
View File
@@ -0,0 +1,114 @@
---
# Community has no OIDC: oauth2-proxy is the only ingress path, so anonymous requests are Admin.
apiVersion: coroot.com/v1
kind: Coroot
metadata:
name: coroot
namespace: coroot
spec:
communityEdition:
image:
name: ghcr.io/coroot/coroot:1.29.4
replicas: 2
authAnonymousRole: Admin
resources:
requests:
cpu: 500m
memory: 1Gi
limits:
cpu: "2"
memory: 4Gi
storage:
className: cephrbd-fast-delete
size: 10Gi
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- topologyKey: kubernetes.io/hostname
labelSelector:
matchLabels:
app.kubernetes.io/part-of: coroot
app.kubernetes.io/component: coroot
# Shared config store; required for replicas > 1.
postgres:
host: postgres-pooler-rw.coroot.svc.cluster.local
port: 5432
user: coroot
database: coroot
passwordSecret:
name: postgres-app
key: password
params:
sslmode: require
# Metrics live in the shared VictoriaMetrics cluster; no bundled Prometheus.
externalPrometheus:
url: http://vmselect-main.observability.svc.cluster.local:8481/select/0/prometheus
remoteWriteURL: http://vminsert-main.observability.svc.cluster.local:8480/insert/0/prometheus/api/v1/write
clickhouse:
image:
name: ghcr.io/coroot/clickhouse:26.10.3-ubi9-0
shards: 1
replicas: 2
resources:
requests:
cpu: "1"
memory: 4Gi
limits:
cpu: "4"
memory: 8Gi
storage:
className: cephrbd-fast-delete
size: 100Gi
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- topologyKey: kubernetes.io/hostname
labelSelector:
matchLabels:
app.kubernetes.io/part-of: coroot
app.kubernetes.io/component: clickhouse
keeper:
image:
name: ghcr.io/coroot/clickhouse:26.10.3-ubi9-0
replicas: 3
resources:
requests:
cpu: 100m
memory: 256Mi
limits:
cpu: "1"
memory: 1Gi
storage:
className: cephrbd-fast-delete
size: 10Gi
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- topologyKey: kubernetes.io/hostname
labelSelector:
matchLabels:
app.kubernetes.io/part-of: coroot
app.kubernetes.io/component: clickhouse-keeper
clusterAgent:
image:
name: ghcr.io/coroot/coroot-cluster-agent:1.12.0
resources:
requests:
cpu: 100m
memory: 256Mi
limits:
cpu: "1"
memory: 1Gi
# Privileged hostPID eBPF agent on every node, control-plane included.
nodeAgent:
image:
name: ghcr.io/coroot/coroot-node-agent:1.38.3
tolerations:
- operator: Exists
resources:
requests:
cpu: 100m
memory: 256Mi
limits:
cpu: "1"
memory: 1Gi
+32
View File
@@ -0,0 +1,32 @@
---
# External (DMZ) Traefik front for coroot.unkin.net, TLS via the reflected LE *.unkin.net wildcard.
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
labels:
traefik.io/instance: external
name: coroot-external
namespace: coroot
spec:
gatewayClassName: traefik-external
listeners:
- allowedRoutes:
namespaces:
from: Same
hostname: coroot.unkin.net
name: http
port: 80
protocol: HTTP
- allowedRoutes:
namespaces:
from: Same
hostname: coroot.unkin.net
name: https
port: 443
protocol: HTTPS
tls:
certificateRefs:
- group: ""
kind: Secret
name: wildcard-unkin-net-tls
mode: Terminate
+49
View File
@@ -0,0 +1,49 @@
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: coroot-http-redirect
namespace: coroot
spec:
hostnames:
- coroot.unkin.net
parentRefs:
- group: gateway.networking.k8s.io
kind: Gateway
name: coroot-external
sectionName: http
rules:
- filters:
- type: RequestRedirect
requestRedirect:
scheme: https
statusCode: 301
matches:
- path:
type: PathPrefix
value: /
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: coroot
namespace: coroot
spec:
hostnames:
- coroot.unkin.net
parentRefs:
- group: gateway.networking.k8s.io
kind: Gateway
name: coroot-external
sectionName: https
rules:
- backendRefs:
- group: ""
kind: Service
name: coroot-oauth2
port: 80
weight: 1
matches:
- path:
type: PathPrefix
value: /
+19
View File
@@ -0,0 +1,19 @@
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- namespace.yaml
- cnpg_cluster.yaml
- cnpg_backup.yaml
- cnpg_pooler.yaml
- coroot.yaml
- vaultauth.yaml
- vaultstaticsecret.yaml
- oauth2-proxy-configmap.yaml
- oauth2-proxy-deployment.yaml
- pdb.yaml
- networkpolicy.yaml
- service.yaml
- gateway.yaml
- httproute.yaml
+7
View File
@@ -0,0 +1,7 @@
---
apiVersion: v1
kind: Namespace
metadata:
labels:
app.kubernetes.io/name: coroot
name: coroot
+30
View File
@@ -0,0 +1,30 @@
---
# authAnonymousRole is Admin, so only oauth2-proxy and the coroot agents may reach the UI/API.
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: coroot-ingress
namespace: coroot
spec:
podSelector:
matchLabels:
app.kubernetes.io/part-of: coroot
app.kubernetes.io/component: coroot
policyTypes:
- Ingress
ingress:
- from:
- podSelector:
matchLabels:
app: coroot-oauth2
- podSelector:
matchLabels:
app.kubernetes.io/part-of: coroot
app.kubernetes.io/component: coroot-node-agent
- podSelector:
matchLabels:
app.kubernetes.io/part-of: coroot
app.kubernetes.io/component: coroot-cluster-agent
ports:
- protocol: TCP
port: 8080
@@ -0,0 +1,27 @@
---
apiVersion: v1
kind: ConfigMap
metadata:
name: coroot-oauth2-env
namespace: coroot
data:
OAUTH2_PROXY_HTTP_ADDRESS: "0.0.0.0:4180"
OAUTH2_PROXY_PROVIDER: "oidc"
OAUTH2_PROXY_OIDC_ISSUER_URL: "https://identity.unkin.net/application/o/coroot/"
OAUTH2_PROXY_REDIRECT_URL: "https://coroot.unkin.net/oauth2/callback"
OAUTH2_PROXY_UPSTREAMS: "http://coroot-coroot.coroot.svc.cluster.local:8080/"
OAUTH2_PROXY_SCOPE: "openid email profile ak_groups"
# Populate session.Groups from the Authentik ak_groups claim.
OAUTH2_PROXY_OIDC_GROUPS_CLAIM: "ak_groups"
OAUTH2_PROXY_ALLOWED_GROUPS: "akP-coroot-admin"
OAUTH2_PROXY_PASS_USER_HEADERS: "true"
OAUTH2_PROXY_EMAIL_DOMAINS: "*"
# Authentik hardcodes email_verified=false; authorization is enforced via ak_groups.
OAUTH2_PROXY_INSECURE_OIDC_ALLOW_UNVERIFIED_EMAIL: "true"
OAUTH2_PROXY_COOKIE_SECURE: "true"
OAUTH2_PROXY_COOKIE_DOMAINS: "coroot.unkin.net"
OAUTH2_PROXY_WHITELIST_DOMAINS: "coroot.unkin.net"
OAUTH2_PROXY_REVERSE_PROXY: "true"
OAUTH2_PROXY_PROVIDER_CA_FILES: "/etc/ssl/combined/ca-certificates.crt"
OAUTH2_PROXY_CODE_CHALLENGE_METHOD: "S256"
OAUTH2_PROXY_SKIP_PROVIDER_BUTTON: "true"
@@ -0,0 +1,138 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: coroot-oauth2
namespace: coroot
annotations:
configmap.reloader.stakater.com/auto: "true"
secret.reloader.stakater.com/reload: "coroot-oauth-credentials,vault-ca-cert"
spec:
replicas: 2
selector:
matchLabels:
app: coroot-oauth2
strategy:
rollingUpdate:
maxUnavailable: 1
type: RollingUpdate
template:
metadata:
labels:
app: coroot-oauth2
spec:
serviceAccountName: default
automountServiceAccountToken: false
topologySpreadConstraints:
- maxSkew: 1
topologyKey: kubernetes.io/hostname
whenUnsatisfiable: DoNotSchedule
labelSelector:
matchLabels:
app: coroot-oauth2
securityContext:
runAsNonRoot: true
runAsUser: 65532
runAsGroup: 65532
fsGroup: 65532
seccompProfile:
type: RuntimeDefault
initContainers:
# identity.unkin.net serves a Vault-PKI cert; append the internal CA to the system roots.
- name: combine-certs
image: docker.io/library/alpine:3.24
imagePullPolicy: IfNotPresent
command:
- sh
- -c
- cat /etc/ssl/certs/ca-certificates.crt /custom-ca/ca.crt > /combined-certs/ca-certificates.crt
volumeMounts:
- name: vault-ca-cert
mountPath: /custom-ca
readOnly: true
- name: combined-certs
mountPath: /combined-certs
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
capabilities:
drop:
- ALL
resources:
requests:
cpu: 50m
memory: 32Mi
limits:
cpu: 200m
memory: 64Mi
containers:
- name: oauth2-proxy
image: quay.io/oauth2-proxy/oauth2-proxy:v7.15.3
imagePullPolicy: IfNotPresent
ports:
- containerPort: 4180
name: http
protocol: TCP
envFrom:
- configMapRef:
name: coroot-oauth2-env
optional: false
env:
- name: OAUTH2_PROXY_CLIENT_ID
valueFrom:
secretKeyRef:
name: coroot-oauth-credentials
key: client_id
- name: OAUTH2_PROXY_CLIENT_SECRET
valueFrom:
secretKeyRef:
name: coroot-oauth-credentials
key: client_secret
- name: OAUTH2_PROXY_COOKIE_SECRET
valueFrom:
secretKeyRef:
name: coroot-oauth-credentials
key: cookie_secret
volumeMounts:
- name: combined-certs
mountPath: /etc/ssl/combined
readOnly: true
livenessProbe:
httpGet:
path: /ping
port: http
initialDelaySeconds: 10
periodSeconds: 30
timeoutSeconds: 5
failureThreshold: 3
readinessProbe:
httpGet:
path: /ready
port: http
initialDelaySeconds: 5
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 3
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
capabilities:
drop:
- ALL
resources:
requests:
cpu: 50m
memory: 64Mi
limits:
cpu: 500m
memory: 256Mi
volumes:
- name: vault-ca-cert
secret:
secretName: vault-ca-cert
items:
- key: ca.crt
path: ca.crt
- name: combined-certs
emptyDir: {}
restartPolicy: Always
+58
View File
@@ -0,0 +1,58 @@
---
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: coroot
namespace: coroot
spec:
maxUnavailable: 1
selector:
matchLabels:
app.kubernetes.io/part-of: coroot
app.kubernetes.io/component: coroot
---
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: coroot-clickhouse
namespace: coroot
spec:
maxUnavailable: 1
selector:
matchLabels:
app.kubernetes.io/part-of: coroot
app.kubernetes.io/component: clickhouse
---
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: coroot-clickhouse-keeper
namespace: coroot
spec:
maxUnavailable: 1
selector:
matchLabels:
app.kubernetes.io/part-of: coroot
app.kubernetes.io/component: clickhouse-keeper
---
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: coroot-oauth2
namespace: coroot
spec:
minAvailable: 1
selector:
matchLabels:
app: coroot-oauth2
---
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: postgres-pooler-rw
namespace: coroot
spec:
minAvailable: 1
selector:
matchLabels:
cnpg.io/poolerName: postgres-pooler-rw
+18
View File
@@ -0,0 +1,18 @@
---
# HTTPRoute target: all traffic enters via oauth2-proxy.
apiVersion: v1
kind: Service
metadata:
name: coroot-oauth2
namespace: coroot
spec:
internalTrafficPolicy: Cluster
ports:
- name: http
port: 80
protocol: TCP
targetPort: http
selector:
app: coroot-oauth2
sessionAffinity: None
type: ClusterIP
+18
View File
@@ -0,0 +1,18 @@
---
apiVersion: secrets.hashicorp.com/v1beta1
kind: VaultAuth
metadata:
name: default
namespace: coroot
spec:
allowedNamespaces:
- coroot
kubernetes:
audiences:
- vault
role: default
serviceAccount: default
tokenExpirationSeconds: 600
method: kubernetes
mount: k8s/au/syd1
vaultConnectionRef: vso-system/default
+17
View File
@@ -0,0 +1,17 @@
---
apiVersion: secrets.hashicorp.com/v1beta1
kind: VaultStaticSecret
metadata:
name: coroot-oauth-credentials
namespace: coroot
spec:
destination:
create: true
name: coroot-oauth-credentials
overwrite: true
hmacSecretData: true
mount: kv
path: kubernetes/namespace/coroot/default/oauth-credentials
refreshAfter: 5m
type: kv-v2
vaultAuthRef: default
@@ -0,0 +1,16 @@
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: coroot-system
resources:
- ../../../base/coroot-system
helmCharts:
- name: coroot-operator
repo: https://artifactapi.k8s.syd1.au.unkin.net/api/v1/virtual/helm
version: "0.10.8"
releaseName: coroot-operator
namespace: coroot-system
valuesFile: values.yaml
@@ -0,0 +1,14 @@
# Single replica: the operator has no leader election.
resources:
requests:
cpu: 100m
memory: 128Mi
limits:
cpu: 500m
memory: 512Mi
containerSecurityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
capabilities:
drop:
- ALL
@@ -0,0 +1,6 @@
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../../../base/coroot
@@ -12,6 +12,7 @@ spec:
directories:
- path: apps/overlays/*/observability
- path: apps/overlays/*/grafana
- path: apps/overlays/*/coroot
template:
metadata:
name: 'observability-{{path[3]}}'
+1
View File
@@ -24,6 +24,7 @@ spec:
- path: apps/overlays/*/cephrgw-system
- path: apps/overlays/*/cnpg-system
- path: apps/overlays/*/consul
- path: apps/overlays/*/coroot-system
- path: apps/overlays/*/dhcp-system
- path: apps/overlays/*/elastic-system
- path: apps/overlays/*/encapi
+2
View File
@@ -13,6 +13,8 @@ spec:
server: https://kubernetes.default.svc
- namespace: 'grafana'
server: https://kubernetes.default.svc
- namespace: 'coroot'
server: https://kubernetes.default.svc
clusterResourceWhitelist:
- group: ''
kind: Namespace
File diff suppressed because it is too large Load Diff