【问题标题】:Kubernetes ingress controller not able to find the certificate secretKubernetes 入口控制器无法找到证书机密
【发布时间】:2021-03-04 06:21:07
【问题描述】:

我正在设置一个包含入口控制器证书的密钥,但是当我检查入口日志时出现以下错误

入口日志:

W0304 05:47:32.020497       7 controller.go:1153] Error getting SSL certificate "default/auth-tls": local SSL certificate default/auth-tls was not found. Using default certificate
W0304 05:47:32.020516       7 controller.go:1407] Error getting SSL certificate "default/auth-tls": local SSL certificate default/auth-tls was not found
I0304 05:47:32.114777       7 main.go:117] "successfully validated configuration, accepting" ingress="hello-kubernetes-ingress" namespace="default"

秘密:

$ kubectl create secret tls auth-tls --cert key.pem --key out.key
$ kubectl describe secret auth-tls
Name:         auth-tls
Namespace:    default
Labels:       <none>
Annotations:  <none>

Type:  kubernetes.io/tls

Data
====
tls.crt:  3231 bytes
tls.key:  1732 bytes

下面是我的入口 yaml 文件

apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: hello-kubernetes-ingress
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/auth-url: https://externalauthentication/authorize
spec:
  rules:
  - host: hw1.yourdomain
    http:
      paths:
      - backend:
          serviceName: hello-kubernetes-first
          servicePort: 80
  - host: hw2.yourdomain
    http:
      paths:
      - backend:
          serviceName: hello-kubernetes-second
          servicePort: 80
  tls:
  - hosts:
    - externalauthentication
    - hw1.yourdomain
    secretName: auth-tls

【问题讨论】:

  • 你是如何安装你的入口控制器的,在哪个命名空间中?这可能与权限有关。
  • 我通过 minikube 插件启用了 ingress-controller,它在 kube-system 命名空间中运行
  • secret 和 pod hello-kubernetes-ingress 在同一个命名空间,它们应该在同一个命名空间
  • @DivyaVyas 你能否验证这两个资源是否在同一个命名空间中?
  • @DivyaVyas,这个问题有什么进展吗?你解决了吗?

标签: kubernetes kubernetes-ingress kubernetes-secrets


【解决方案1】:

IngressSecret 都是命名空间资源。您可以通过以下方式检查自己:

$ kubectl api-resources --namespaced=true
NAME                        SHORTNAMES   APIGROUP                    NAMESPACED   KIND
...
secrets                                                              true         Secret
...
ingresses                   ing          extensions                  true         Ingress
ingresses                   ing          networking.k8s.io           true         Ingress

他们只能在namespace 内工作。因此,在您的用例中,您需要将它们(IngressSecret)放在同一个命名空间中。

【讨论】:

  • 我也有这个问题,但是我的入口和秘密在同一个“默认”命名空间中。
猜你喜欢
  • 2022-10-24
  • 2019-08-02
  • 2018-03-25
  • 2018-07-22
  • 2020-04-24
  • 1970-01-01
  • 1970-01-01
  • 2021-01-28
  • 2021-04-17
相关资源
最近更新 更多