kubernetes - Kubernetes仪表板在使用代理时给出 “Unauthorized”

标签 kubernetes azure-aks

我正在尝试使用Azure上部署的Kubernetes 1.9.9在新设置的AKS群集上使用Kubernetes仪表板。

我运行kubectl proxy并打开http://localhost:8001/api/v1/namespaces/kube-system/services/kubernetes-dashboard/proxy/#!/overview?namespace=default来查看仪表板。

我收到一条消息Unauthorized。并且几乎所有功能都被禁用。

当我用谷歌搜索这个问题时,大多数解决方案似乎都围绕着除了localhost之外没有其他东西到达仪表板。但是我反对localhostkubectl proxy是否应该给我一个自动授权的入口点?

最佳答案

这实际上取决于您用来连接到kube-apiserver的ServiceAccountUser。如果您确实希望访问而无需详细查看策略(可以访问所有内容),则可以kubectl apply -f这样的代码:

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  annotations:
    rbac.authorization.kubernetes.io/autoupdate: "true"
  labels:
    kubernetes.io/bootstrapping: rbac-defaults
  name: my-cluster-admin
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: cluster-admin
subjects:
- apiGroup: rbac.authorization.k8s.io
  kind: User
  name: <your-user-from-your-~/.kube/config>

或者:
kubectl create clusterrolebinding my-cluster-admin --clusterrole=cluster-admin --user=<your-user-from-your-~/.kube/config>

您也可以使用GroupServiceAccount代替User

关于kubernetes - Kubernetes仪表板在使用代理时给出 “Unauthorized”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52716569/

相关文章:

azure - 无法使用 StorageClass 配置卷 - 无法获取存储帐户的存储 key

kubernetes - 为什么 Kubernetes Secret 既有键又有名称?

azure-aks - AKS 创建的服务主体密码到期

Azure Kubernetes 服务 - 何时需要在其他 Azure 资源上设置 AKS 服务原则才能建立连接?

kubernetes - Google容器引擎(Kubernetes)和OAuth2回调

azure - 是否可以使用Terraform回收azurerm_kubernetes_cluster service_principal :client_secret only

azure - 通过名称解析 Pod 的 IP

kubernetes - 避免在 Kubernetes 中为一个 cron 执行点运行多个 cron 作业

amazon-web-services - 从不同的 EC2 主机迁移 Pod

postgresql - Keycloak 无法连接到 Postgres : "SSL connection is required"