【问题标题】:EKS cluster doesn't provide client-ca-fileEKS 集群不提供 client-ca-file
【发布时间】:2019-07-22 12:47:53
【问题描述】:

在 EKS (Kubernetes 1.11.5) 中创建了一个具有多个节点组的集群,但是我注意到在 extension-apiserver-authentication 配置映射中缺少 client-ca-file 键。

我认为这是由于 Kubernetes API 服务的启动方式造成的。有没有其他人遇到过这个问题?

我在部署使用 GET https://10.100.0.1:443/api/v1/namespaces/kube-system/configmaps/extension-apiserver-authentication 查询 api 服务器的证书管理器时遇到了这个问题。

在 GKE 中这不是问题,因为 extension-apiserver-authentication configmap 已经包含 client-ca-file

extension-apiserver-authentication AWS 中的配置映射,

apiVersion: v1
data:
  requestheader-allowed-names: '["front-proxy-client"]'
  requestheader-client-ca-file: |
    <certificate file>
  requestheader-extra-headers-prefix: '["X-Remote-Extra-"]'
  requestheader-group-headers: '["X-Remote-Group"]'
  requestheader-username-headers: '["X-Remote-User"]'
kind: ConfigMap
metadata:
  creationTimestamp: 2019-01-14T04:56:51Z
  name: extension-apiserver-authentication
  namespace: kube-system
  resourceVersion: "39"
  selfLink: /api/v1/namespaces/kube-system/configmaps/extension-apiserver-authentication
  uid: ce2b6f64-17b8-11e9-a6dd-021a269d3ce8

但是在 GKE 中,

apiVersion: v1
data:
  client-ca-file: |
    <client certificate file>
  requestheader-allowed-names: '["aggregator"]'
  requestheader-client-ca-file: |
    <certificate file>
  requestheader-extra-headers-prefix: '["X-Remote-Extra-"]'
  requestheader-group-headers: '["X-Remote-Group"]'
  requestheader-username-headers: '["X-Remote-User"]'
kind: ConfigMap
metadata:
  creationTimestamp: 2018-05-24T12:06:33Z
  name: extension-apiserver-authentication
  namespace: kube-system
  resourceVersion: "32"
  selfLink: /api/v1/namespaces/kube-system/configmaps/extension-apiserver-authentication
  uid: e6c0c431-5f4a-11e8-8d8c-42010a9a0191

【问题讨论】:

    标签: authentication kubernetes amazon-eks


    【解决方案1】:

    我在尝试在 AWS EKS 集群上使用 cert-manager 时也遇到了这个问题。可以使用从 AWS CLI 获得的证书自己注入证书。请按照以下步骤解决此问题:

    获取证书

    证书以 Base64 编码存储,可以使用检索

    aws eks describe-cluster \
            --region=${AWS_DEFAULT_REGION} \
            --name=${CLUSTER_NAME} \
            --output=text \
            --query 'cluster.{certificateAuthorityData: certificateAuthority.data}' | base64 -D
    

    注入证书

    编辑kube-system命名空间下的configMap/extension-apiserver-authentication:kubectl -n kube-system edit cm extension-apiserver-authentication

    在数据部分下,在名为 client-ca-file 的新配置条目下添加 CA。例如:

      client-ca-file: |
        -----BEGIN CERTIFICATE-----
    ...
        -----END CERTIFICATE-----
    

    【讨论】:

    【解决方案2】:

    您的假设可能是正确的,我的意思是您的问题可能确实与在 EKS 中启动 api-server 的方式有关,并且当缺少 --client-ca-file 选项时,根据 apiserver 源代码:

    Cluster 没有在 %s 的 configmap/%s 中提供 client-ca-file,所以 对扩展 api-server 的客户端证书身份验证将不起作用。

    我想知道你是否可以自己创建一个 client-ca,然后更新 extension-apiserver-authentication ConfigMap。毕竟在 EKS 中,我们可以访问 CA(获取它的方式 here),它可以为我们签署客户端证书,如 GitHub 页面中所述,sample api-server。

    作为旁注:

    我注意到,在 EKS 上,像 kubelet 这样的组件正在使用 aws-iam-authenticator(集群节点上 /var/lib/kubelet/kubeconfig 的内容):

    apiVersion: v1
    kind: Config
    users:
    - name: kubelet
      user:
        exec:
          apiVersion: client.authentication.k8s.io/v1alpha1
          args:
          - token
          - -i
          - eks-api-eval
          command: /usr/bin/aws-iam-authenticator
          env: null
    

    与 GKE 相反,其中 client-ca 用作验证客户端的一种方式:

    apiVersion: v1
    kind: Config
    users:
    - name: kubelet
      user:
        client-certificate: /etc/srv/kubernetes/pki/kubelet.crt
        client-key: /etc/srv/kubernetes/pki/kubelet.key
    

    【讨论】:

    • 是的,完全同意。我就此联系了 AWS 支持。尽管与请求标头标志不同,但看起来不需要此标志。所以可能是托管的 K8 提供者不需要实现它。尽管如此,他们至少应该制作一些关于此的文档来这么说。当我收到支持的回复时会回复。
    猜你喜欢
    • 2022-01-23
    • 1970-01-01
    • 1970-01-01
    • 2021-11-14
    • 2019-06-22
    • 2020-04-26
    • 1970-01-01
    • 1970-01-01
    • 2021-07-27
    相关资源
    最近更新 更多