<p>I've unsuccessfully been trying to create a simple "run" command using kubectl whereby the container is started and passed in the (partial) arguments to initially create my certificates (which I will initially do manually through PowerShell) and could do with some input from the community.</p>

<p><strong>My Environment</strong>: </p>

<ul>
<li>(Local) Windows 10 with PowerShell</li>
<li>(Remote) Azure Kubernetes Cluster</li>
</ul>

<p>My efforts consist of two key commands, the first being the creation of the overrides (in JSON) for the container (primarily so I can mount the Azure File Shares where I want certificates to be stored):</p>

<pre><code>$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
</code></pre>

<p>The second is then the kubectl run command which would be used as the basis for the CronJob (creating the CronJob itself is my next task once I've gotten this working correctly):</p>

<pre><code>kubectl run -i --rm --tty certbot --namespace=prod --overrides=$override --image=certbot/certbot -- certonly --manual
</code></pre>

<p>I've been trying a number of variations, and this approach seems the cleanest. However, I'm currently getting the following response from Kubernetes:</p>

<pre><code>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.
</code></pre>

<p>The latter part of the warning indicates that certbot is not receiving any of the arguments (in this case "certonly" and "--manual"), but I can't figure out quite where I'm going wrong. I feel like I've sanity checked the commands with both the Kubernetes &amp; certbot docs and can't see any obvious issues.</p>

<p>Can anyone point out the gremlin here?</p>

<p><strong>Note</strong>: I've successfully tested this approach using Docker locally, and am now trying to recreate this within Azure.</p>

Matt Woodward
<p>You dont need to create a image from image to do that, just create a pod like this:</p>

<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: certbot
spec:
  containers:
  - name: certbot
    image: certbot/certbot
    command: ["/bin/sh"] &lt;&lt; this overrides entrypoint
  restartPolicy: Never
</code></pre>

<p><a href="https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/" rel="nofollow noreferrer">https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/</a></p>
