Reputation: 2424
I have created a EC2 instance where Jenkins is running connected to my GitHub account. The following are the two steps of my Jenkins pipeline:
pipeline {
agent any
stages {
stage('Kubernetes cluster') {
steps {
withAWS(region:'us-west-2', credentials:'aws-kubernetes') {
sh '''
if [ ! aws cloudformation describe-stacks --region us-west-2 --stack-name eksctl-EmaJarK8sCluster-cluster ] ; then
if [ ! aws cloudformation describe-stacks --region us-west-2 --stack-name eksctl-EmaJarK8sCluster-nodegroup-standard-workers ] ; then
eksctl create cluster \
--name EmaJarK8sCluster \
--version 1.13 \
--nodegroup-name standard-workers \
--node-type t2.small \
--nodes 2 \
--nodes-min 1 \
--nodes-max 3 \
--node-ami auto \
--region us-west-2 \
--zones us-west-2a \
--zones us-west-2b \
--zones us-west-2c \
fi
fi
'''
}
}
}
stage('Configuration file cluster') {
steps {
withAWS(region:'us-west-2', credentials:'aws-kubernetes') {
sh '''
aws eks --region us-west-2 update-kubeconfig --name EmaJarK8sCluster
'''
}
}
}
}
}
The first step creates a Kubernetes cluster if it doesn't exist, the second one creates a configuration file for that cluster. This step works pretty well and creates two cloudformation stacks and one EC2 machine where the Kubernetes cluster is running.
The second stage fails with the following error:
Invalid choice: 'eks', maybe you meant:
* es
After reading a couple of tutorial I've found out that I needed to update awscli
to version 1.18.57
in order to have the eks
command available. So I've logged into my Jenkins machine (not the one dedicated to the k8s cluster) ad I've update the awscli
.
Unfortunately this is not enough. I still get the same error. I can run the command manually into Jenkins the machine but, for some reason, I cannot run it via Jenkins pipeline.
Can someone help me with this problem?
Thanks in advance.
Upvotes: 1
Views: 1326
Reputation: 2424
Unfortunately the solutions provided didn't work for me. My goal was to setup an machine where I could run a Kubernetes environment in order to implement a blue/green deployment. The deployment had to be handled using Jenkins so I had to create a dedicated machine for Jenkins itself.
I followed this guide to set up all the dependencies: https://medium.com/faun/learning-kubernetes-by-doing-part-1-setting-up-eks-in-aws-50dcf7a76247
The mistake that I made before was to install all those dependencies using brew
. This caused many problems and polluted my PATH environment variable. I solved it terminating the machine and creating a new instance. In this case I installed the dependencies manually or using apt-get.
The resources I had to install:
A couple of notes:
"aws-iam-authenticator": executable file not found in $PATH
be sure to install aws-iam-authenticator
following this guideUpvotes: 0
Reputation: 4474
Are you updated jenkins
agents?
If not:
Upgrading Windows Service Wrapper
- Upgrade Jenkins to the version, which provides this module
- Jenkins is expected to automatically upgrade
jenkins-slave.exe
executables- If the upgrade happens, you should be able to see the message in the
Agent log
in Jenkins Web UI- Once upgrade is done, the changes will be applied on the next Windows service restart
Upvotes: 1
Reputation: 13642
Can you provide the full path to the aws
command? Also add which aws
and aws --version
to the second stage script, and confirm that output.
The above should highlight the actual path of the command, and the current version. Correct your configuration as needed.
Upvotes: 1