Azure Kubernetes Service - 专用注册表上的自签名证书



>我在 Azure 订阅和本地服务器之间创建了一个隧道。 在本地,我们有一个工件服务器,它容纳了我们所有的 docker 镜像。 对于所有内部服务器,我们都有公司范围的 CA 信任,所有证书都是由此生成的。

但是,当我尝试将某些内容部署到 aks 并引用此 docker 注册表时。 我收到证书错误,因为节点本身不信任"内部"自签名证书。

无论如何都可以将根 CA 链添加到节点中吗? 或者一种告诉 aks 节点上的 docker 守护程序这是一个不安全的注册表的方法?

不是百分百确定,但您可以尝试使用 docker 配置来创建镜像拉取的密钥,命令如下:

cat ~/.docker/config.json | base64

然后像这样创建密钥:

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

在部署或 Pod 中将此密钥用作imagePullSecrets的值。有关更多详细信息,请参阅将私有 Docker 注册表与 Kubernetes 配合使用。

首先,我建议你使用 curl 来检查 azure 群集与本地服务器上的连接。

请使用 curl 和 curl -k 并检查它们是否都有效(-k 允许在没有证书的情况下连接到 SSL 站点,我认为它不起作用,这意味着您在 Azure 群集上的本地证书上没有(

如果 curl -k 不起作用,则需要将证书从本地复制并添加到 Azure 群集。

应该可以帮助您做到这一点的链接

  • https://docs.docker.com/ee/enable-client-certificate-authentication/
  • https://askubuntu.com/questions/73287/how-do-i-install-a-root-certificate

并找到了一些有关使用 docker 守护程序执行此操作的信息

  • https://docs.docker.com/registry/insecure/

我希望它能帮助你。如果您还有其他问题,请告诉我。

看起来您遇到了此处描述的相同问题:https://github.com/kubernetes/kubernetes/issues/43924。

此解决方案可能适合您:

据我所知,这是一个 docker 问题,而不是 kubernetes 问题。 Docker不使用Linux的ca证书。没有人知道为什么。

您必须手动安装这些证书(在每个可以安装的节点上( 生成这些 pod(,以便 docker 可以使用它们:

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

这是一个非常烦人的问题,因为您必须屠宰您的节点 引导后将这些证书放在那里。和 kubernetes 生成 节点一直。这个问题还没有解决是一个 对我来说很神秘。这是一个完整的表演 IMO。

那么这只是一个如何为每个节点运行它的问题。您可以使用从 ConfigMap 运行脚本的 DaemonSet 来执行此操作,如下所述:https://cloud.google.com/solutions/automatically-bootstrapping-gke-nodes-with-daemonsets。该文章提到了GitHub项目 https://github.com/GoogleCloudPlatform/solutions-gke-init-daemonsets-tutorial。 魔力就在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

您可以修改 ConfigMap 中的脚本以提取您的证书并将其放在正确的目录中。

相关内容

最新更新