<p>I have an image in ECR I want to use as a container in my jenkins pipeline.  My Kubernetes cluster is a k3s cluster running local.   I am unable to pull the image (I am guessing) because I am not properly passing my AWS creds (stored in a username with password secret homelab-k3s-ecr).  Through my searching I cannot find how to set the AWS creds when pulling from ECR.  Below is my Jenkinfile and the error.  Any guidance on how to pass the AWS creds to the kuberenetes agent config so that when I attempt to pull it can authenticate?</p>
<pre><code>pipeline {
    agent {
        kubernetes {
            yaml &quot;&quot;&quot;
apiVersion: v1
kind: Pod
metadata:
  name: vapi
  namespace: jenkins
spec:
  containers:
    - name: homelab
      image: &lt;id&gt;.dkr.ecr.us-east-2.amazonaws.com/homelab:1.0.0
      imagePullSecrets:
        - name: homelab-k3s-ecr
&quot;&quot;&quot;
        }
    }
    stages {
        stage('Build') {
            steps {
                container('homelab') {
                    sh 'echo &quot;Running build inside the ECR container&quot;'
                }
            }
        }
    }
}
</code></pre>
<pre><code>ERROR: Unable to pull Docker image &quot;&lt;id&gt;.dkr.ecr.us-east-2.amazonaws.com/homelab:1.0.0&quot;. Check if image tag name is spelled correctly.
</code></pre>
<p>I have tried using the imagePullSecrets value as i found in the docs <a href="https://www.jenkins.io/doc/pipeline/steps/kubernetes/" rel="nofollow noreferrer">https://www.jenkins.io/doc/pipeline/steps/kubernetes/</a> but i could not get it to work</p>

Danny
<p>You can use environment variables</p>
<pre><code>environment {
    AWS_ACCESS_KEY_ID     = credentials('aws_access_key_id')
    AWS_SECRET_ACCESS_KEY = credentials('aws_secret_access_key')
}
</code></pre>
<p>Read the offical docs
<a href="https://www.jenkins.io/doc/book/pipeline/jenkinsfile/#using-environment-variables" rel="nofollow noreferrer">using environment variables</a></p>
