GKE Ingress 无法使用证书管理器 ssl 机密

时间:2021-01-24 15:21:18

标签: google-cloud-platform google-kubernetes-engine kubernetes-secrets cert-manager

我正在尝试让 Letencrypt 与 GKE LB 一起工作,我知道有 GCP 托管证书,但它不适用于内部 LB,因为挑战无法通过。 Letsencrypt DNS 认证使用 cert-manager 已准备就绪,可供使用。

❯ k get secrets letsencrypt-prod -o yaml
apiVersion: v1
data:
  tls.key: LS0tLS1CRUdJTiBSU0EgUFJJVkFURSBLRVktLS0tLQpNSUlFb3dJQkFBS0NBUUVBdlVZTVhXdGNZZUJpMkdadzljRFRLNzY==
kind: Secret
metadata:
  creationTimestamp: "2021-01-24T15:03:39Z"
  name: letsencrypt-prod
  namespace: elastic-system
  resourceVersion: "3636289"
  selfLink: /api/v1/namespaces/elastic-system/secrets/letsencrypt-prod
  uid: f4bec5a9-d3b5-4f4a-9ec6-01a4ce3ba47c
type: Opaque

spec:
  tls:
    - hosts:
      - staging.example.com
      - staging2.example.com
      secretName: letsencrypt-prod

GCP 报告此错误 Error syncing to GCP: error running load balancer syncing routine: error getting secrets for Ingress: secret "letsencrypt-prod" does not specify cert as string data

有人可以帮我解决它缺少的东西吗?

2 个答案:

答案 0 :(得分:1)

根据 this,您必须为 GCP 提供有效的格式,例如您已经提供的 Let's Encrypt 有效证书:

kubectl create secret generic letsencrypt-prod --from-file=tls.crt="cert.pem" --from-file=tls.key="privkey.pem" --dry-run -o yaml > output
kubectl apply -f output

此外,(似乎您已经在使用它,但安全总比抱歉好),您必须按照 this

tls 的 Ingress 部分定义它>

答案 1 :(得分:0)

实际上,它在文档中遗漏了,或者我遗漏了,因为示例在任何地方都使用与元数据相同的名称。

---
apiVersion: cert-manager.io/v1alpha2
kind: Certificate
metadata:
  name: cert-example
  namespace: example
spec:
  secretName: REAL_NAME_OF_SECRET << This need to include in ingress.
  issuerRef:
    name: letsencrypt-prod
  dnsNames:
  - 'staging.domain.com'
  - '*.staging.domain.com'

所以 REAL_NAME_OF_SECRET 你应该放在 ingress 或任何你想使用 tls.crttls.key 的地方。

相关问题