Don't have permission to view all the namespaces in the cluster

I tried to add gitlab-agent to the environment and select the namespace and flux customization there, but I get errors

I’m using the Gitlab hosted version of Self-Manager on Kubernetes.

Install command gitlab-agent

helm upgrade --install h gitlab/gitlab-agent \
    --namespace gitlab-agent-h \
    --create-namespace \
    --set image.tag=v17.2.2 \
    --set config.token=token \
    --set config.kasAddress=wss://kas.domain.com

Configuration gitlab-agent to path .gitlab/agents/my-agent/config.yaml in repository

user_access:
  access_as:
    agent: {}
  groups:
    - id: LearnHub
    - id: LearnHub/Frontend
    - id: LearnHub/Identity
ci_access:
  groups:
    - id: LearnHub
    - id: LearnHub/Frontend
    - id: LearnHub/Identity

Install command flux

flux bootstrap gitlab \
--hostname=gitlab.domain.com \
--owner=Flux-LearnHub \
--repository=Flux \
--branch=main \
--path=clusters/production \
--deploy-token-auth

Adding a repository

flux create source git learnhub-mainpage \
  --url=https://gitlab.domain.com/learnhub/frontend/mainpage.git \
  --branch=main \
  --interval=1m \
  --namespace=flux-system \
  --username=username \
  --password=token
flux create kustomization learnhub-mainpage-kustomization \
  --source=GitRepository/learnhub-mainpage.flux-system \
  --path="./manifests" \
  --prune=true \
  --interval=5m \
  --namespace=flux-system

And I don’t see Flux customization or namespace in the selection

I tried to manually grant the gitlab-agent cluster admin role for testing

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: gitlab-agent-cluster-admin
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: cluster-admin
subjects:
- kind: ServiceAccount
  name: learnhub-gitlab-agent # name ServiceAccount
  namespace: gitlab-agent

And I made sure that gitlab-agent has rights to all namespaces, but still nothing appears in the list, tell me how to fix this.

I’ve run into the same issue myself. The Agent connection works fine for both CI as well as actual user access (glab cluster agent update-kubeconfig etc…) but the Environment claims it has no access. Where do we go from here?

This happens because kas.domain.com and gitlab.domain.com are different subdomains and they cannot access the same cookies. You can see my solution
kubernetes - Don't have permission to view all the namespaces in the cluster - Stack Overflow