简体   繁体   English

azure kubernetes 服务 - 私有注册表上的自签名证书

[英]azure kubernetes service - self signed cert on private registry

I have a tunnel created between my azure subscription and my on-prem servers.我在我的 azure 订阅和我的本地服务器之间创建了一个隧道。 ON prem we have an artifactory server that is housing all of our docker images.在本地,我们有一个神器服务器,用于存放我们所有的 docker 镜像。 For all internal servers we have a company wide CA trust and all certs are generated from this.对于所有内部服务器,我们都有公司范围的 CA 信任,所有证书都由此生成。

However, when I try to deploy something to aks and reference this docker registry.但是,当我尝试将某些内容部署到 aks 并引用此 docker 注册表时。 I am getting a cert error because the nodes themselves do not trust the "in house" self signed cert.我收到证书错误,因为节点本身不信任“内部”自签名证书。

Is there anyway to get the root CA chain added to the nodes?有没有办法将根 CA 链添加到节点中? Or a way to tell the docker daemon on the aks nodes this is an insecure registry?或者告诉 aks 节点上的 docker 守护进程这是一个不安全的注册表?

Not one hundred percent sure, but you can try to use the docker config to create the secret for image pull, the command like this:不能百分百确定,但您可以尝试使用 docker config 来创建镜像拉取的秘密,命令如下:

cat ~/.docker/config.json | base64

Then create the secret like this:然后像这样创建秘密:

apiVersion: v1
kind: Secret
metadata:
 name: registrypullsecret
data:
 .dockerconfigjson: <base-64-encoded-json-here>
type: kubernetes.io/dockerconfigjson

Use this secret in your deployment or pod as the value of imagePullSecrets .在您的部署或 pod 中使用此密钥作为imagePullSecrets的值。 For more details, see Using a private Docker Registry with Kubernetes .有关更多详细信息,请参阅将私有 Docker 注册表与 Kubernetes 结合使用

For the beginning I would recommend you to use curl to check connection between your azure cluster and on prem server.一开始,我建议您使用curl检查 azure 集群和 prem 服务器之间的连接。

Please use curl and curl -k and check if they both works(-k allow connections to SSL sites without certs, I assume it won't work, what means You don't have on prem certs on azure cluster)请使用 curl 和 curl -k 并检查它们是否都有效(-k 允许在没有证书的情况下连接到 SSL 站点,我认为它不起作用,这意味着您在 azure 集群上没有本地证书)

If curl -k won't work then you need to copy and add certs from on prem to azure cluster.如果 curl -k 不起作用,那么您需要将证书从本地复制并添加到 azure 集群。

Links which should help you do that应该可以帮助您做到这一点的链接

And found some informations about doing that with docker daemon并找到了一些有关使用 docker daemon 执行此操作的信息

I hope it will help you.我希望它会帮助你。 Let me know if you have any more questions.如果您还有其他问题,请告诉我。

It looks like you are having the same problem described here: https://github.com/kubernetes/kubernetes/issues/43924 .看起来您遇到了此处描述的相同问题: https : //github.com/kubernetes/kubernetes/issues/43924

This solution should probably work for you: 此解决方案可能适合您:

As far as I remember this was a docker issue, not a kubernetes one.据我所知,这是一个 docker 问题,而不是 kubernetes 问题。 Docker does not use linux's ca certs. Docker 不使用 linux 的 ca 证书。 Nobody knows why.没有人知道为什么。

You have to install those certs manually (on every node that could spawn those pods) so that docker can use them:您必须手动安装这些证书(在可以生成这些 pod 的每个节点上),以便 docker 可以使用它们:

/etc/docker/certs.d/mydomain.com:1234/ca.crt /etc/docker/certs.d/mydomain.com:1234/ca.crt

This is a highly annoying issue as you have to butcher your nodes after bootstrapping to get those certs in there.这是一个非常烦人的问题,因为您必须在引导后删除节点才能在那里获取这些证书。 And kubernetes spawns nodes all the time.并且 kubernetes 一直在产生节点。 How this issue has not been solved yet is a mystery to me.这个问题如何尚未解决对我来说是个谜。 It's a complete showstopper IMO.这是一个完整的showstopper IMO。

Then it's just a question of how to run this for every node.那么这只是如何为每个节点运行它的问题。 You could do that with a DaemonSet which runs a script from a ConfigMap, as described here: https://cloud.google.com/solutions/automatically-bootstrapping-gke-nodes-with-daemonsets .您可以使用从 ConfigMap 运行脚本的 DaemonSet 来做到这一点,如下所述: https ://cloud.google.com/solutions/automatically-bootstrapping-gke-nodes-with-daemonsets。 That article refers to a GitHub project https://github.com/GoogleCloudPlatform/solutions-gke-init-daemonsets-tutorial .那篇文章引用了一个 GitHub 项目https://github.com/GoogleCloudPlatform/solutions-gke-init-daemonsets-tutorial The magic is in the DaemonSet.yaml:神奇之处在于 DaemonSet.yaml:

apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: node-initializer
  labels:
    app: default-init
spec:
  selector:
    matchLabels:
      app: default-init
  updateStrategy:
    type: RollingUpdate
  template:
    metadata:
      labels:
        name: node-initializer
        app: default-init
    spec:
      volumes:
      - name: root-mount
        hostPath:
          path: /
      - name: entrypoint
        configMap:
          name: entrypoint
          defaultMode: 0744
      initContainers:
      - image: ubuntu:18.04
        name: node-initializer
        command: ["/scripts/entrypoint.sh"]
        env:
        - name: ROOT_MOUNT_DIR
          value: /root
        securityContext:
          privileged: true
        volumeMounts:
        - name: root-mount
          mountPath: /root
        - name: entrypoint
          mountPath: /scripts
      containers:
      - image: "gcr.io/google-containers/pause:2.0"
        name: pause

You could modify the script that is in the ConfigMap to pull your cert and put it in the correct directory.您可以修改 ConfigMap 中的脚本以提取您的证书并将其放在正确的目录中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM