<p>I am trying to deploy the popular sock shop app in my AWS EKS cluster. I have successfully created the cluster but whenever I try to deploy to the cluster I keep getting this error.</p>
<pre><code>Error from server (Forbidden): &lt;html&gt;&lt;head&gt;&lt;meta http-equiv='refresh' content='1;url=/login?from=%2Fswagger-2.0.0.pb-v1%3Ftimeout%3D32s'/&gt;&lt;script&gt;window.location.replace('/login?from=%2Fswagger-2.0.0.pb-v1%3Ftimeout%3D32s');&lt;/script&gt;&lt;/head&gt;&lt;body style='background-color:white; color:white;'&gt;


Authentication required
&lt;!--
--&gt;

&lt;/body&gt;&lt;/html&gt;
</code></pre>
<p>I have added my jenkins user to my sudo group but I still get same error. Also I tried to run this command directly on my ec2 instance</p>
<pre><code>kubectl create -f complete-demo.yaml
</code></pre>
<p>And it deployed. What am I getting wrongs that keeps giving this error.</p>
<p>This is my Jenkins content</p>
<pre><code>#!/usr/bin/env groovy
pipeline {
    agent any
    environment {
        AWS_ACCESS_KEY_ID = credentials('AWS_ACCESS_KEY_ID')
        AWS_SECRET_ACCESS_KEY = credentials('AWS_SECRET_ACCESS_KEY')
        AWS_DEFAULT_REGION = &quot;us-east-1&quot;
    }
    stages {
        stage(&quot;Deploy to EKS&quot;) {
            steps {
                script {
                    dir('deploy/kubernetes') {
                        sh &quot;kubectl create -f complete-demo.yaml&quot;

                    }
                }
            }
        }
    }
}
</code></pre>
<p>This is the github profile I am deploying from.</p>
<p><a href="https://github.com/Okeybukks/Altschool-Final-Cloud-Project" rel="nofollow noreferrer">https://github.com/Okeybukks/Altschool-Final-Cloud-Project</a></p>

Achebe Peter
<p>Since you are using <code>EC2</code> instance and some AWS credentials please make sure that user connected with those creds is listed in <code>aws-auth</code> configmap located in <code>kube-system</code> namespace.</p>
<p>If yes then you should probably run <code>EKS</code> login command before you apply your manifest to be able to generate proper <code>config</code> file which is not present in <code>Jenkins</code> workspace. So your pipeline should looks like:</p>
<pre><code>#!/usr/bin/env groovy
pipeline {
    agent any
    environment {
        AWS_ACCESS_KEY_ID = credentials('AWS_ACCESS_KEY_ID')
        AWS_SECRET_ACCESS_KEY = credentials('AWS_SECRET_ACCESS_KEY')
        AWS_DEFAULT_REGION = &quot;us-east-1&quot;
    }
    stages {
        stage(&quot;Deploy to EKS&quot;) {
            steps {
                script {
                    dir('deploy/kubernetes') {
                        sh &quot;&quot;&quot;
                           aws eks update-kubeconfig --name my_cluster_name
                           kubectl create -f complete-demo.yaml
                        &quot;&quot;&quot;
                    }
                }
            }
        }
    }
}
</code></pre>
<p>Please refer to <a href="https://aws.amazon.com/premiumsupport/knowledge-center/eks-cluster-connection/" rel="nofollow noreferrer">this</a> doc regarding login to <code>EKS</code>.</p>
