Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for route-prefix #178

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

fstr
Copy link
Contributor

@fstr fstr commented Jan 4, 2025

Description
This PR adds support to configure the Pyrra --route-prefix argument on the Pyrra web-server. This is useful when the Pyrra UI is running behind a reverse proxy or more generally under a different path.

If the new property .Values.routePrefix is set:

  • Pass argument to web-server via Deployment manifest
  • Adjust ServiceMonitor path to include routePrefix
  • Adjust test-connection to include routePrefix

Extra:

  • Add security context to test-connection pod to be able to run in more restrictive environments. Do not run as root. Run as user nobody. Setting readOnlyRootFs requires wget to write to stdout.

This also fixes: #158

How I tested this change
Update values.yaml:

routePrefix: "/pyrra"
serviceMonitor:
  enabled: true

Render the chart:

helm template --name-template pyrra --values values.yaml .

Deployment:

---
# Source: pyrra/templates/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: pyrra
  labels:
    helm.sh/chart: pyrra-0.14.3
    app.kubernetes.io/name: pyrra
    app.kubernetes.io/instance: pyrra
    app.kubernetes.io/version: "v0.8.1"
    app.kubernetes.io/component: metrics
    app.kubernetes.io/managed-by: Helm
spec:
  selector:
    matchLabels:
      app.kubernetes.io/name: pyrra
      app.kubernetes.io/instance: pyrra
  template:
    metadata:
      labels:
        app.kubernetes.io/name: pyrra
        app.kubernetes.io/instance: pyrra
    spec:
      serviceAccountName: pyrra
      securityContext:
        {}
      containers:
        - name: pyrra-kubernetes
          securityContext:
            {}
          image: "ghcr.io/pyrra-dev/pyrra:v0.8.1"
          imagePullPolicy: IfNotPresent
          args:
            - kubernetes
            - --metrics-addr=:8080
          resources:
            {}
          ports:
            - name: op-metrics
              containerPort: 8080
        - name: pyrra
          securityContext:
            {}
          image: "ghcr.io/pyrra-dev/pyrra:v0.8.1"
          imagePullPolicy: IfNotPresent
          args:
            - api
            - --prometheus-url=http://prometheus-operated.monitoring.svc.cluster.local:9090
            - --api-url=http://localhost:9444
            - --route-prefix=/pyrra
          ports:
          - name: http
            containerPort: 9099

ServiceMonitor:

---
# Source: pyrra/templates/servicemonitor-server.yaml
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: pyrra-server
  labels:
    helm.sh/chart: pyrra-0.14.3
    app.kubernetes.io/name: pyrra
    app.kubernetes.io/instance: pyrra
    app.kubernetes.io/version: "v0.8.1"
    app.kubernetes.io/component: metrics
    app.kubernetes.io/managed-by: Helm
spec:
  jobLabel: pyrra-server
  selector:
    matchLabels:
      app.kubernetes.io/name: pyrra
      app.kubernetes.io/instance: pyrra
  namespaceSelector:
    matchNames:
    - monitoring
  endpoints:
  - port: http
    path: /pyrra/metrics

test-connection pod:

---
# Source: pyrra/templates/tests/test-connection.yaml
apiVersion: v1
kind: Pod
metadata:
  name: "pyrra-test-connection"
  labels:
    helm.sh/chart: pyrra-0.14.3
    app.kubernetes.io/name: pyrra
    app.kubernetes.io/instance: pyrra
    app.kubernetes.io/version: "v0.8.1"
    app.kubernetes.io/component: metrics
    app.kubernetes.io/managed-by: Helm
  annotations:
    "helm.sh/hook": test
spec:
  containers:
    - name: wget
      image: busybox
      command: ['wget']
      args: ['-O-', 'pyrra:9099']
      securityContext:
        readOnlyRootFilesystem: true
        allowPrivilegeEscalation: false
        privileged: false
        capabilities:
          drop:
            - ALL
  restartPolicy: Never
  securityContext:
    runAsUser: 65534
    runAsGroup: 65534
    runAsNonRoot: true

@fstr fstr force-pushed the fstr/route-prefix branch from e77be65 to 61ccc47 Compare January 4, 2025 13:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for configuring route-prefix
1 participant