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

Basic auth disabled for /status endpoint #652

Closed
bu3 opened this issue Mar 14, 2023 · 10 comments
Closed

Basic auth disabled for /status endpoint #652

bu3 opened this issue Mar 14, 2023 · 10 comments

Comments

@bu3
Copy link
Contributor

bu3 commented Mar 14, 2023

Hi,

I'm having an issue deploying bazel-remote in a K8s cluster using /status as liveness probe with basic authentication enabled.
I cannot enable allow_unauthenticated_reads because of some internal security requirement but that means that /status returns 401 and K8s kills my deployment.

Is there any way to disable authentication for /status only?

@mostynb
Copy link
Collaborator

mostynb commented Mar 14, 2023

Have you considered using the /grpc.health.v1.Health/Check (gRPC) service for this?

@bu3
Copy link
Contributor Author

bu3 commented Mar 14, 2023

No. Sorry I didn't. I don't get it though. You mean to use it for a liveness probe over gRPC?

Something like this?

  livenessProbe:
    grpc:
      port: 9092
      service: /grpc.health.v1.Health/Check
  readinessProbe:
    grpc:
      port: 9092
      service: /grpc.health.v1.Health/Check

@mostynb
Copy link
Collaborator

mostynb commented Mar 14, 2023

Yes. I don't have a great knowledge of kubernetes so I can't offer much help with that side of things, but maybe the discussion in #522 is helpful? This gRPC service is supposed to always be reachable (as long as you haven't disabled gRPC support in bazel-remote) regardless of authentication status.

@bu3
Copy link
Contributor Author

bu3 commented Mar 14, 2023

That's great. Thanks for getting back so fast

@mostynb
Copy link
Collaborator

mostynb commented Mar 14, 2023

No problem. There's also a brief mention of this in the kubernetes notes section of the README.md - suggestions for how to improve that are weclome, if you have any.

@bu3
Copy link
Contributor Author

bu3 commented Mar 20, 2023

Hi @mostynb,

just to help anyone else dealing with the same issue, this deployment works fine with k8s >= 1.24:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: nginx
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: bazel-remote-cache
        image: buchgr/bazel-remote-cache:latest
        ports:
          - containerPort: 7442
            name: http
            protocol: TCP
          - containerPort: 8080
            name: http-default
            protocol: TCP
        livenessProbe:
            grpc:
              service: /grpc.health.v1.Health/Check
              port: 9092
            failureThreshold: 3
            initialDelaySeconds: 3
            periodSeconds: 1
            successThreshold: 1
            timeoutSeconds: 1
        readinessProbe:
            grpc:
              service: /grpc.health.v1.Health/Check
              port: 9092
            failureThreshold: 3
            periodSeconds: 3
            successThreshold: 1
            timeoutSeconds: 10

mostynb added a commit to mostynb/bazel-remote that referenced this issue Mar 21, 2023
Thanks to @bu3 for providing this.

Relates to buchgr#652.
@mostynb
Copy link
Collaborator

mostynb commented Mar 21, 2023

Thanks for following up- I'll close this issue now, and we can move documentation discussion into #653.

@mostynb mostynb closed this as completed Mar 21, 2023
mostynb added a commit to mostynb/bazel-remote that referenced this issue Mar 21, 2023
Thanks to @bu3 for providing this.

Relates to buchgr#652.
@CareF
Copy link

CareF commented Sep 11, 2023

This config seems to be buggy?

Deployment.apps "test-bazel-cache" is invalid: [spec.template.spec.containers[0].livenessProbe: Required value: must specify a handler type, spec.template.spec.containers[0].readinessProbe: Required value: must specify a handler type]

@bu3
Copy link
Contributor Author

bu3 commented Sep 11, 2023

Hi @CareF, I've just tried to deploy it again and it seems to be working fine.

From my running pod description:

bazel-remote-cache:                                                                                                                                                 │
│     Container ID:   docker://f76ece540f53b6b2e8d8f58149109272374d162f9ebce27006e3ead9b55b61b9                                                                         │
│     Image:          buchgr/bazel-remote-cache:latest                                                                                                                  │
│     Image ID:       docker-pullable://buchgr/bazel-remote-cache@sha256:a334bb87e5059f1ea1a68a856b25a110dd09c538329303ccba90263ea664c750                               │
│     Ports:          7442/TCP, 8080/TCP                                                                                                                                │
│     Host Ports:     0/TCP, 0/TCP                                                                                                                                      │
│     State:          Running                                                                                                                                           │
│       Started:      Mon, 11 Sep 2023 09:44:54 +0100                                                                                                                   │
│     Ready:          True                                                                                                                                              │
│     Restart Count:  0                                                                                                                                                 │
│     Liveness:       grpc <pod>:9092 /grpc.health.v1.Health/Check delay=3s timeout=1s period=1s #success=1 #failure=3                                                  │
│     Readiness:      grpc <pod>:9092 /grpc.health.v1.Health/Check delay=0s timeout=10s period=3s #success=1 #failure=3

Tested with K8s 1.25

@CareF
Copy link

CareF commented Sep 12, 2023

Hi @CareF, I've just tried to deploy it again and it seems to be working fine.

From my running pod description:

bazel-remote-cache:                                                                                                                                                 │
│     Container ID:   docker://f76ece540f53b6b2e8d8f58149109272374d162f9ebce27006e3ead9b55b61b9                                                                         │
│     Image:          buchgr/bazel-remote-cache:latest                                                                                                                  │
│     Image ID:       docker-pullable://buchgr/bazel-remote-cache@sha256:a334bb87e5059f1ea1a68a856b25a110dd09c538329303ccba90263ea664c750                               │
│     Ports:          7442/TCP, 8080/TCP                                                                                                                                │
│     Host Ports:     0/TCP, 0/TCP                                                                                                                                      │
│     State:          Running                                                                                                                                           │
│       Started:      Mon, 11 Sep 2023 09:44:54 +0100                                                                                                                   │
│     Ready:          True                                                                                                                                              │
│     Restart Count:  0                                                                                                                                                 │
│     Liveness:       grpc <pod>:9092 /grpc.health.v1.Health/Check delay=3s timeout=1s period=1s #success=1 #failure=3                                                  │
│     Readiness:      grpc <pod>:9092 /grpc.health.v1.Health/Check delay=0s timeout=10s period=3s #success=1 #failure=3

Tested with K8s 1.25

Thank you for the reply. My fault. Our k8s cluster is too old for grpc handler.

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

No branches or pull requests

3 participants