Expose VictoriaLogs UI at vlogs.unkin.net behind oauth2-proxy (#498)
The vlselect query UI is only reachable in-cluster, so every log search needs a port-forward. Publish it at vlogs.unkin.net behind oauth2-proxy on the external (DMZ) Traefik. - Add `apps/base/logging/vlogs`: external Gateway, http->https redirect and main HTTPRoute - Terminate TLS with the reflected Let's Encrypt `*.unkin.net` wildcard; reflect it into `logging` - Publish the `vlogs` A record at the DMZ gateway VIP from the bind-operator `unkin.net` zone - Route all traffic through the `vlogs-oauth2` Service, upstreaming to `vlselect-logs:9471` - Gate on the Authentik `vlogs` application, group `akP-vlogs-admin` - Read OIDC credentials from `kv/kubernetes/namespace/logging/default/vlogs-oauth-credentials` Depends on unkin/terraform-authentik#40. Reviewed-on: #498 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 #498.
This commit is contained in:
@@ -162,3 +162,18 @@ spec:
|
|||||||
# traefik-EXTERNAL (DMZ) gateway VIP; the watchstate-external Gateway serves
|
# traefik-EXTERNAL (DMZ) gateway VIP; the watchstate-external Gateway serves
|
||||||
# the watchstate.unkin.net front door (oauth2-proxy) there.
|
# the watchstate.unkin.net front door (oauth2-proxy) there.
|
||||||
- 198.18.199.0
|
- 198.18.199.0
|
||||||
|
---
|
||||||
|
apiVersion: bind.unkin.net/v1alpha1
|
||||||
|
kind: DNSRecord
|
||||||
|
metadata:
|
||||||
|
name: vlogs-dns-internal
|
||||||
|
namespace: bind-internal
|
||||||
|
spec:
|
||||||
|
zoneRef: unkin-net
|
||||||
|
name: vlogs
|
||||||
|
type: A
|
||||||
|
ttl: 600
|
||||||
|
values:
|
||||||
|
# traefik-EXTERNAL (DMZ) gateway VIP; the vlogs-external Gateway serves the
|
||||||
|
# vlogs.unkin.net front door (oauth2-proxy) there.
|
||||||
|
- 198.18.199.0
|
||||||
|
|||||||
@@ -14,9 +14,9 @@ spec:
|
|||||||
secretTemplate:
|
secretTemplate:
|
||||||
annotations:
|
annotations:
|
||||||
reflector.v1.k8s.emberstack.com/reflection-allowed: "true"
|
reflector.v1.k8s.emberstack.com/reflection-allowed: "true"
|
||||||
reflector.v1.k8s.emberstack.com/reflection-allowed-namespaces: "cheeztv,arrstack,authentik,gitea,watchstate,mediamark,repospawner,haproxy"
|
reflector.v1.k8s.emberstack.com/reflection-allowed-namespaces: "cheeztv,arrstack,authentik,gitea,watchstate,mediamark,repospawner,haproxy,logging"
|
||||||
reflector.v1.k8s.emberstack.com/reflection-auto-enabled: "true"
|
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"
|
reflector.v1.k8s.emberstack.com/reflection-auto-namespaces: "cheeztv,arrstack,authentik,gitea,watchstate,mediamark,repospawner,haproxy,logging"
|
||||||
privateKey:
|
privateKey:
|
||||||
size: 4096
|
size: 4096
|
||||||
dnsNames:
|
dnsNames:
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ resources:
|
|||||||
- configmap_logarchiver.yaml
|
- configmap_logarchiver.yaml
|
||||||
- deployment_logarchiver.yaml
|
- deployment_logarchiver.yaml
|
||||||
- logviewer
|
- logviewer
|
||||||
|
- vlogs
|
||||||
|
|
||||||
# Vector pipelines are the single source of truth (also validated by
|
# Vector pipelines are the single source of truth (also validated by
|
||||||
# `vector test` in CI). Mounted into each tier via `existingConfigMaps`.
|
# `vector test` in CI). Mounted into each tier via `existingConfigMaps`.
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
---
|
||||||
|
# External (DMZ) front for the VictoriaLogs UI on vlogs.unkin.net via the
|
||||||
|
# external Traefik (LB VIP 198.18.199.0). TLS terminates with the real Let's
|
||||||
|
# Encrypt *.unkin.net wildcard (Certificate wildcard-unkin-net in cert-manager,
|
||||||
|
# reflected into this namespace as wildcard-unkin-net-tls by the emberstack
|
||||||
|
# reflector), so there is no cert-manager annotation here. The apex
|
||||||
|
# vlogs.unkin.net A record lives in the bind-operator unkin.net zone, NOT
|
||||||
|
# external-dns, so no external-dns annotation either. oauth2-proxy fronts it.
|
||||||
|
apiVersion: gateway.networking.k8s.io/v1
|
||||||
|
kind: Gateway
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
traefik.io/instance: external
|
||||||
|
name: vlogs-external
|
||||||
|
namespace: logging
|
||||||
|
spec:
|
||||||
|
gatewayClassName: traefik-external
|
||||||
|
listeners:
|
||||||
|
- allowedRoutes:
|
||||||
|
namespaces:
|
||||||
|
from: Same
|
||||||
|
hostname: vlogs.unkin.net
|
||||||
|
name: http
|
||||||
|
port: 80
|
||||||
|
protocol: HTTP
|
||||||
|
- allowedRoutes:
|
||||||
|
namespaces:
|
||||||
|
from: Same
|
||||||
|
hostname: vlogs.unkin.net
|
||||||
|
name: https
|
||||||
|
port: 443
|
||||||
|
protocol: HTTPS
|
||||||
|
tls:
|
||||||
|
certificateRefs:
|
||||||
|
- group: ""
|
||||||
|
kind: Secret
|
||||||
|
name: wildcard-unkin-net-tls
|
||||||
|
mode: Terminate
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
---
|
||||||
|
apiVersion: gateway.networking.k8s.io/v1
|
||||||
|
kind: HTTPRoute
|
||||||
|
metadata:
|
||||||
|
name: vlogs-http-redirect
|
||||||
|
namespace: logging
|
||||||
|
spec:
|
||||||
|
hostnames:
|
||||||
|
- vlogs.unkin.net
|
||||||
|
parentRefs:
|
||||||
|
- group: gateway.networking.k8s.io
|
||||||
|
kind: Gateway
|
||||||
|
name: vlogs-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: vlogs
|
||||||
|
namespace: logging
|
||||||
|
spec:
|
||||||
|
hostnames:
|
||||||
|
- vlogs.unkin.net
|
||||||
|
parentRefs:
|
||||||
|
- group: gateway.networking.k8s.io
|
||||||
|
kind: Gateway
|
||||||
|
name: vlogs-external
|
||||||
|
sectionName: https
|
||||||
|
rules:
|
||||||
|
- backendRefs:
|
||||||
|
- group: ""
|
||||||
|
kind: Service
|
||||||
|
name: vlogs-oauth2
|
||||||
|
port: 80
|
||||||
|
weight: 1
|
||||||
|
matches:
|
||||||
|
- path:
|
||||||
|
type: PathPrefix
|
||||||
|
value: /
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
---
|
||||||
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
|
kind: Kustomization
|
||||||
|
|
||||||
|
resources:
|
||||||
|
- vaultstaticsecret.yaml
|
||||||
|
- oauth2-proxy-configmap.yaml
|
||||||
|
- oauth2-proxy-deployment.yaml
|
||||||
|
- service.yaml
|
||||||
|
- gateway.yaml
|
||||||
|
- httproute.yaml
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
name: vlogs-oauth2-env
|
||||||
|
namespace: logging
|
||||||
|
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/vlogs/"
|
||||||
|
OAUTH2_PROXY_REDIRECT_URL: "https://vlogs.unkin.net/oauth2/callback"
|
||||||
|
OAUTH2_PROXY_UPSTREAMS: "http://vlselect-logs.logging.svc.cluster.local:9471/"
|
||||||
|
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-vlogs-admin"
|
||||||
|
OAUTH2_PROXY_PASS_USER_HEADERS: "true"
|
||||||
|
OAUTH2_PROXY_EMAIL_DOMAINS: "*"
|
||||||
|
# Authentik hardcodes email_verified=false in the id_token; authorization is
|
||||||
|
# enforced via ak_groups, so accepting the unverified email is safe.
|
||||||
|
OAUTH2_PROXY_INSECURE_OIDC_ALLOW_UNVERIFIED_EMAIL: "true"
|
||||||
|
OAUTH2_PROXY_COOKIE_SECURE: "true"
|
||||||
|
OAUTH2_PROXY_COOKIE_DOMAINS: "vlogs.unkin.net"
|
||||||
|
OAUTH2_PROXY_WHITELIST_DOMAINS: "vlogs.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,132 @@
|
|||||||
|
---
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: vlogs-oauth2
|
||||||
|
namespace: logging
|
||||||
|
annotations:
|
||||||
|
configmap.reloader.stakater.com/auto: "true"
|
||||||
|
secret.reloader.stakater.com/reload: "vlogs-oauth-credentials,vault-ca-cert"
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: vlogs-oauth2
|
||||||
|
strategy:
|
||||||
|
rollingUpdate:
|
||||||
|
maxUnavailable: 1
|
||||||
|
type: RollingUpdate
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: vlogs-oauth2
|
||||||
|
spec:
|
||||||
|
serviceAccountName: default
|
||||||
|
automountServiceAccountToken: false
|
||||||
|
securityContext:
|
||||||
|
runAsNonRoot: true
|
||||||
|
runAsUser: 65532
|
||||||
|
runAsGroup: 65532
|
||||||
|
fsGroup: 65532
|
||||||
|
seccompProfile:
|
||||||
|
type: RuntimeDefault
|
||||||
|
initContainers:
|
||||||
|
# identity.unkin.net serves a Vault-PKI cert; combine the system roots
|
||||||
|
# with the internal CA so oauth2-proxy's OIDC HTTP client trusts it.
|
||||||
|
- name: combine-certs
|
||||||
|
image: docker.io/library/alpine:3
|
||||||
|
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: vlogs-oauth2-env
|
||||||
|
optional: false
|
||||||
|
env:
|
||||||
|
- name: OAUTH2_PROXY_CLIENT_ID
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: vlogs-oauth-credentials
|
||||||
|
key: client_id
|
||||||
|
- name: OAUTH2_PROXY_CLIENT_SECRET
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: vlogs-oauth-credentials
|
||||||
|
key: client_secret
|
||||||
|
- name: OAUTH2_PROXY_COOKIE_SECRET
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: vlogs-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
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
---
|
||||||
|
# Front-door entry Service: the HTTPRoute for vlogs.unkin.net targets this, so
|
||||||
|
# all traffic enters via oauth2-proxy.
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: vlogs-oauth2
|
||||||
|
namespace: logging
|
||||||
|
spec:
|
||||||
|
internalTrafficPolicy: Cluster
|
||||||
|
ports:
|
||||||
|
- name: http
|
||||||
|
port: 80
|
||||||
|
protocol: TCP
|
||||||
|
targetPort: http
|
||||||
|
selector:
|
||||||
|
app: vlogs-oauth2
|
||||||
|
sessionAffinity: None
|
||||||
|
type: ClusterIP
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
---
|
||||||
|
apiVersion: secrets.hashicorp.com/v1beta1
|
||||||
|
kind: VaultStaticSecret
|
||||||
|
metadata:
|
||||||
|
name: vlogs-oauth-credentials
|
||||||
|
namespace: logging
|
||||||
|
spec:
|
||||||
|
destination:
|
||||||
|
create: true
|
||||||
|
name: vlogs-oauth-credentials
|
||||||
|
overwrite: true
|
||||||
|
hmacSecretData: true
|
||||||
|
mount: kv
|
||||||
|
path: kubernetes/namespace/logging/default/vlogs-oauth-credentials
|
||||||
|
refreshAfter: 5m
|
||||||
|
type: kv-v2
|
||||||
|
vaultAuthRef: default
|
||||||
Reference in New Issue
Block a user