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

"Forward port" is stuck pending when permissions are restricted using a ClusterRole #2946

Open
artiommocrenco-amdaris opened this issue Feb 24, 2025 · 7 comments
Assignees
Labels
bug Something isn't working k8s K8s compatibility-related issues/features

Comments

@artiommocrenco-amdaris
Copy link

artiommocrenco-amdaris commented Feb 24, 2025

Describe the bug

"Forward port" is stuck pending when permissions are restricted using a similar ClusterRole:

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: developers-extended
rules:
  - apiGroups:
      - "*"
    resources:
      - "*"
    verbs:
      - list
      - get
      - watch
  - apiGroups:
      - ""
    resources:
      - pods/portforward
    verbs:
      - get
      - list
      - create

To Reproduce

Steps to reproduce the bug:

  1. Restrict a subject using ClusterRole from above (I was using service account and token)
  2. Find a service, try to "Forward port"
  3. The process is stuck, even after waiting several minutes

Expected results: port is forwarded or an error message is shown

Image

Image

Environment (please provide info about your environment):

  • Installation type: winget
  • Headlamp Version: 0.28.1
  • Other: Windows 11

Are you able to fix this issue?

No

Additional Context

Works using kubectl port-forward svc/myservice 8080:80 and in aptakube using the same kubeconfig in both cases, but doesn't work with Headlamp.

Works as expected with Headlamp using cluster admin kubeconfig (using TLS client auth).

@artiommocrenco-amdaris artiommocrenco-amdaris added the bug Something isn't working label Feb 24, 2025
@dosubot dosubot bot added the k8s K8s compatibility-related issues/features label Feb 24, 2025
@artiommocrenco-amdaris
Copy link
Author

#2936 could be related, as I was using a service account with a token

@anengineerdude
Copy link

Having issues as well the fixes in 0.28.1 related to port forward did not fix for me

@Davidr1963
Copy link

Having issues as well the fixes in 0.28.1 related to port forward did not work. It just get the Spinning wheel that it is trying.

@artiommocrenco-amdaris
Copy link
Author

still not working for me in 0.29.0

@knrt10
Copy link
Contributor

knrt10 commented Mar 4, 2025

Thank you for opening the issue, looking into this

@knrt10 knrt10 self-assigned this Mar 4, 2025
@knrt10
Copy link
Contributor

knrt10 commented Mar 10, 2025

Hi @artiommocrenco-amdaris I was unable to reproduce this issue with the current main. Can you please try it as well?

Here are the exact steps I used to test this scenario:

  1. Created clusterRole
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: developers-extended
rules:
  - apiGroups:
      - "*"
    resources:
      - "*"
    verbs:
      - list
      - get
      - watch
  - apiGroups:
      - ""
    resources:
      - pods/portforward
      - services
      - services/portforward
    verbs:
      - get
      - list
      - create
  1. Create SA kubectl create serviceaccount developer-test
  2. Created clusterrolebinding
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: developer-test-binding
subjects:
- kind: ServiceAccount
  name: developer-test
  namespace: default
roleRef:
  kind: ClusterRole
  name: developers-extended
  apiGroup: rbac.authorization.k8s.io
  1. Created token for auth kubectl create token developer-test
  2. Started backend cd backend && go run ./cmd -dev -enable-dynamic-clusters
  3. Started frontend cd frontend && npm i && npm start
  4. Started app cd app && npm run dev-only-app
  5. Went to a service and tried port-forward.

I had clusters in kubeconfig and it worked for me. I also had an AKS cluster and added it base64 encoding it via New Cluster button or you could add it again using Add cluster button using a kubeconfig as well.

Both scenario worked for me. Can you please add some logs from the console, that would be helpful as well? Thanks

@alex-hempel
Copy link

I have this issue, even when using a role that gives me cluster-admin permissions.

Headlamp 0.29 on MacOS 15.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working k8s K8s compatibility-related issues/features
Projects
Development

No branches or pull requests

5 participants