我有一个运行良好的 K8s 集群,其域具有自定义 SSL 证书,所有其他子域都使用 Let's encrypt 通配符。
现在,我想添加另一个将使用自定义 SSL 证书的域,但它似乎不起作用。
.crt
首先,我使用和.key
文件创建一个 configMap
kubectl create configmap traefik-sge-certificate --from-file=certificate/sge-prod.crt --from-file=certificate/sge-prod.key --dry-run -o yaml | kubectl apply -f -
然后我添加我的证书traefik.toml
traefik.toml:
----
# traefik.toml
defaultEntryPoints = ["http","https"]
[entryPoints]
[entryPoints.http]
address = ":80"
[entryPoints.http.redirect]
entryPoint = "https"
[entryPoints.https]
address = ":443"
[entryPoints.https.tls]
[[entryPoints.https.tls.certificates]]
certFile = "/etc/ene-certificate/api.crt"
keyFile = "/etc/ene-certificate/api.key"
[[entryPoints.https.tls.certificates]]
certFile = "/etc/sge-certificate/sge-prod.crt"
keyFile = "/etc/sge-certificate/sge-prod.key"
[acme] # Automatically add Let's Encrypt Certificate.
storage= "/etc/certificate/acme.json"
email = "julien@company.fr"
entryPoint = "https"
onHostRule = true
caServer = "https://acme-v02.api.letsencrypt.org/directory"
[acme.dnsChallenge]
provider = "route53"
delayBeforeCheck = 0
[[acme.domains]]
main = "*.company.fr"
现在部署:
kind: Deployment
apiVersion: apps/v1
metadata:
name: traefik-deployment
labels:
app: traefik
spec:
replicas: 1
selector:
matchLabels:
app: traefik
template:
metadata:
labels:
app: traefik
spec:
serviceAccountName: traefik-ingress-controller
terminationGracePeriodSeconds: 60
volumes:
- name: traefik-certificate
persistentVolumeClaim:
claimName: traefik-certificate
- name: config
configMap:
name: traefik-config
- name: traefik-ene-certificate
configMap:
name: traefik-ene-certificate
- name: traefik-sge-certificate
configMap:
name: traefik-sge-certificate
containers:
- name: traefik
image: "traefik:1.7"
envFrom:
- secretRef:
name: traefik-env
volumeMounts:
- mountPath: "/etc/traefik/config"
name: config
- mountPath: "/etc/certificate"
name: traefik-certificate
- mountPath: "/etc/ene-certificate/api.crt"
name: traefik-ene-certificate
subPath: api.crt
- mountPath: "/etc/ene-certificate/api.key"
name: traefik-ene-certificate
subPath: api.key
- mountPath: "/etc/sge-certificate/sge-prod.crt"
name: traefik-sge-certificate
subPath: sge-prod.crt
- mountPath: "/etc/sge-certificate/sge-prod.key"
name: traefik-sge-certificate
subPath: sge-prod.key
args:
- --configfile=/etc/traefik/config/traefik.toml
- --api
- --kubernetes
但是当我这样做时,有两个问题:
- 我的新应用:https ://sge.company.fr使用通配符证书,而不是自定义证书(此操作的目的)
- 使用自定义证书 api.crt 的应用程序(以前使用自定义 SSL 证书运行良好)没有使用通配符证书,这是一种回归。
我检查了traefik日志,似乎没有任何问题。
我也不明白,自定义 SSL 证书与域的链接在哪里。
谁能告诉我为什么会这样,我应该如何解决?
PD:我知道我应该使用秘密而不是 configMaps,但首先要做的是!