在 Kubernetes 中使用 Certbot(作为 CronJob)生成证书
Generating Certificates using Certbot (as a CronJob) within Kubernetes
我一直在尝试使用 kubectl 创建一个简单的 "run" 命令,但没有成功) 并且可以处理来自社区的一些意见。
我的环境:
- (本地)Windows 10 使用 PowerShell
- (远程)Azure Kubernetes 集群
我的工作包括两个关键命令,第一个是为容器创建覆盖(在 JSON 中)(主要是为了我可以在我想要存储证书的地方安装 Azure 文件共享) :
$override= '{ "spec": { "template": { "spec": { "containers": [ { "name": "certbot", "image": "certbot/certbot", "stdin": true, "tty": true, "volumeMounts": [{ "name": "certdata", "mountPath": "/etc/letsencrypt" }] } ], "volumes": [{ "name": "certdata", "persistentVolumeClaim": { "claimName": "azure-fileshare" } }] } } } }' | ConvertTo-Json
第二个是 kubectl 运行 命令,它将用作 CronJob 的基础(创建 CronJob 本身是我的下一个任务,一旦我让它正常工作):
kubectl run -i --rm --tty certbot --namespace=prod --overrides=$override --image=certbot/certbot -- certonly --manual
我一直在尝试多种变体,这种方法似乎是最干净的。但是,我目前从 Kubernetes 收到以下回复:
Error attaching, falling back to logs: unable to upgrade connection: container certbot not found in pod certbot-9df67bd65-w96rq_prod
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Certbot doesn't know how to automatically configure the web server on this system. However, it can still get a certificate for you. Please run "certbot certonly" to do so. You'll need to manually configure your web server to use the resulting certificate.
警告的后半部分表明 certbot 没有收到任何参数(在本例中为 "certonly" 和“--manual”),但我不知道我在哪里出错了。我觉得我已经对 Kubernetes 和 certbot 文档的命令进行了理智检查,没有发现任何明显的问题。
谁能指出这里的小鬼?
注意:我已经在本地使用 Docker 成功测试了这种方法,现在正尝试在 Azure 中重新创建它。
您不需要从图像创建图像来执行此操作,只需像这样创建一个广告连播:
apiVersion: v1
kind: Pod
metadata:
name: certbot
spec:
containers:
- name: certbot
image: certbot/certbot
command: ["/bin/sh"] << this overrides entrypoint
restartPolicy: Never
https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/
我一直在尝试使用 kubectl 创建一个简单的 "run" 命令,但没有成功) 并且可以处理来自社区的一些意见。
我的环境:
- (本地)Windows 10 使用 PowerShell
- (远程)Azure Kubernetes 集群
我的工作包括两个关键命令,第一个是为容器创建覆盖(在 JSON 中)(主要是为了我可以在我想要存储证书的地方安装 Azure 文件共享) :
$override= '{ "spec": { "template": { "spec": { "containers": [ { "name": "certbot", "image": "certbot/certbot", "stdin": true, "tty": true, "volumeMounts": [{ "name": "certdata", "mountPath": "/etc/letsencrypt" }] } ], "volumes": [{ "name": "certdata", "persistentVolumeClaim": { "claimName": "azure-fileshare" } }] } } } }' | ConvertTo-Json
第二个是 kubectl 运行 命令,它将用作 CronJob 的基础(创建 CronJob 本身是我的下一个任务,一旦我让它正常工作):
kubectl run -i --rm --tty certbot --namespace=prod --overrides=$override --image=certbot/certbot -- certonly --manual
我一直在尝试多种变体,这种方法似乎是最干净的。但是,我目前从 Kubernetes 收到以下回复:
Error attaching, falling back to logs: unable to upgrade connection: container certbot not found in pod certbot-9df67bd65-w96rq_prod
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Certbot doesn't know how to automatically configure the web server on this system. However, it can still get a certificate for you. Please run "certbot certonly" to do so. You'll need to manually configure your web server to use the resulting certificate.
警告的后半部分表明 certbot 没有收到任何参数(在本例中为 "certonly" 和“--manual”),但我不知道我在哪里出错了。我觉得我已经对 Kubernetes 和 certbot 文档的命令进行了理智检查,没有发现任何明显的问题。
谁能指出这里的小鬼?
注意:我已经在本地使用 Docker 成功测试了这种方法,现在正尝试在 Azure 中重新创建它。
您不需要从图像创建图像来执行此操作,只需像这样创建一个广告连播:
apiVersion: v1
kind: Pod
metadata:
name: certbot
spec:
containers:
- name: certbot
image: certbot/certbot
command: ["/bin/sh"] << this overrides entrypoint
restartPolicy: Never
https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/