Anand:
Al West:
It looks like your Kubernetes plugin is not configured properly.
Anand:
Let me check again.
But same error I am getting if i am running kubectl version command on the EC2 instance directly.
Below mentioned fixes I tried so far -
- installed AWS CLI-2 and latest kubectl & eksctl version.
After applying above fixes ate least kubectl apply command is working fine on EC2 instance but the problem is persists with Jenkins, it is unresolved.
Al West:
If you inspect the kube config file you will see under users is executes a command to get a token using aws cli. Run this manually and add the token as a Secret Text
credential in Jenkins. Then you can use this to connect to your Kubernetes cluster.
Al West:
Oh sorry that is not a viable method as the token only has a lifetime of 15 minutes.
Al West:
So I got the Jenkins Kubernetes plugin working with EKS. From the AWS Console copy and paste the URL and Cert into the Kubernetes configuration in Jenkins. You will then need to create a secret for the token (as secret text). To get the token, run the following using kubectl to connect to your EKS cluster:
kubectl create ns jenkins
kubectl create serviceaccount jenkins --namespace jenkins
kubectl create rolebinding jenkins-admin-binding --clusterrole admin --serviceaccount jenkins:jenkins --namespace jenkins
kubectl create token jenkins --namespace jenkins
The last command should provide the token. This is what you add to the secret in Jenkins.