简体   繁体   English

如何在我的 kubernetes 服务中使用证书管理器 letencrypt-prod?

[英]How can I use Cert manager letsencrypt-prod in my kubernetes service?

I have 4 yaml file我有 4 个 yaml 文件

  1. Deployment.yaml部署.yaml
  2. Service.yaml服务.yaml
  3. Ingress.yaml入口.yaml
  4. issuer.yaml发行者.yaml

I want to use letsencrypt-prod for my service for certification .我想将letsencrypt-prod 用于我的认证服务。 But it doesn't work.但它不起作用。

When I use to be sure ingress is working or issuer is working both of them are done!当我用来确定入口正在工作或发行人正在工作时,他们都完成了!

kubectl get ing
kubectl get issuer

But when I run:但是当我运行时:

kubectl get cert

Cert is not readt during 2 days . 2 天内未读取证书。 Like below:像下面这样: 在此处输入图片说明 it creates problem like below.它会产生如下问题。 certification is not binding mandrakee.xyz.Mandrakee.xyz looks still not secure!认证没有约束力 mandrakee.xyz.Mandrakee.xyz 看起来还是不安全! how can I make my website secyre via cert manager?如何通过证书管理器使我的网站保密? Deployment.yaml:部署.yaml:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: echo-deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      app: echo-server
  template:
    metadata:
      labels:
        app: echo-server
    spec:
      containers:
      - name: httpapi-host
        image: jmalloc/echo-server
        imagePullPolicy: Always
        resources:
          requests:
            memory: "128Mi"
            cpu: "500m"
        ports:
        - containerPort: 80                                     

Service.yaml:服务.yaml:

apiVersion: v1
kind: Service
metadata:
  name: echo-service
spec:
  ports:
    - name: http-port
      port: 80
      targetPort: 8080
  selector:
    app: echo-server

Ingress.yaml:入口.yaml:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations:
    kubernetes.io/ingress.class: ambassador
    cert-manager.io/issuer: letsencrypt-prod
  name: test-ingress
spec:
  tls:
    - hosts:
        - mandrakee.xyz
      secretName: letsencrypt-prod 
  rules:
  - host: mandrakee.xyz
    http:
      paths:
      - backend:
          service:
            name: echo-service
            port: 
              number: 80
        path: /
        pathType: Prefix

issuer.yaml:发行者.yaml:

apiVersion: cert-manager.io/v1
kind: Issuer
metadata:
  name: letsencrypt-prod
spec:
  acme:
    email: ykaratoprak@sphereinc.com
    server: https://acme-v02.api.letsencrypt.org/directory
    privateKeySecretRef:
      name: letsencrypt-prod
    solvers:
    - dns01:
        digitalocean:
          tokenSecretRef:
            name: digitalocean-dns
            key: ce28952b5b4e33ea7d98de190f3148a7cc82d31f030bde966ad13b22c1abc524

If you have setup your issuer correctly, which you have assured us, you will see in your namespace a pod belonging to cert manager.如果您已正确设置您的颁发者(您已向我们保证),您将在您的命名空间中看到一个属于 cert manager 的 pod。 This creates a pod that will validate that the server requesting the certificate resolves to the DNS record.这将创建一个 pod,它将验证请求证书的服务器是否解析为 DNS 记录。

In your case, you would need to point your DNS towards your ingress.在您的情况下,您需要将 DNS 指向您的入口。

If this is done successfully, then the next stage of debugging is to validate that both 443 and 80 can be resolved.如果此操作成功完成,那么下一阶段的调试是验证 443 和 80 是否都可以解决。 The Validation Pod created by Cert Manager uses port 80 to validate the communication. Cert Manager 创建的 Validation Pod 使用端口 80 来验证通信。 A common mistake people make is assuming that they will only use port 443 for ssl and disable 80 for security reasons to find out later that letsencrypt can't validate the hostname without port 80.人们犯的一个常见错误是假设他们只会将端口 443 用于 ssl,并出于安全原因禁用 80,以便稍后发现 letencrypt 在没有端口 80 的情况下无法验证主机名。

Otherwise, the common scenario is that cert-manager is installed in the namespace cert-manager and so you should check the logs of the manager.否则,常见的情况是 cert-manager 安装在命名空间 cert-manager 中,因此您应该检查管理器的日志。 This will provided a limited amount of logs and can be sometimes cryptic to finding the remedy to your issues.这将提供有限数量的日志,有时可能难以找到解决问题的方法。

To find the direct error, the pod spawned by cert-manager in the namespace you have deployed the ingress is a good place to focus.要查找直接错误,在您部署 ingress 的命名空间中由 cert-manager 生成的 pod 是一个值得关注的好地方。

A test I would run is to setup the ingress with both 80 and 443, if you use your domain from your browser you should get some invalid kubernetes generic certificates response on the port 443 and just "Not Found" on port 80. If this is successful, it rules out the limitation I have mentioned before.我将运行的测试是使用 80 和 443 设置入口,如果您从浏览器使用您的域,您应该在端口 443 上获得一些无效的 kubernetes 通用证书响应,而在端口 80 上只是“未找到”。如果这是成功,它排除了我之前提到的限制。

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

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