Home > Mobile >  How to install python in Jenkins deployed in EKS
How to install python in Jenkins deployed in EKS

Time:09-16

We are moving EC2-backed Jenkins to Amazon EKS[Elastic Kubernetes Service] & EFS[Elastic File System] backed Jenkins. I have deployed Jenkins in EKS machine and it's opening and working fine. But to run our pipeline we need to install Python and AWS CLI in the slave node. But we don't know where and how to install them. Any help would be highly appreciated.

enter image description here

CodePudding user response:

Simply create a new Docker image with all the dependencies you need and push it to ECR or any other Registry and use that image.

CodePudding user response:

You can get the publicly available image and include it in your pipeline.

This how I run it on my jenkins

pipeline {
    options {
      ansiColor('xterm')
  }
    environment {

    }
    agent {
        kubernetes {
          yaml '''
apiVersion: v1
kind: Pod
spec:
  containers:
  - name: kaniko
    image: gcr.io/kaniko-project/executor:v1.9.0-debug
    resources:
      requests:
        cpu: 500m
        memory: 512Mi
    limits:
        cpu: 1000m
        memory: 2048Mi
    command:
    - cat
    tty: true
  - name: aws-cli
    image: public.ecr.aws/bitnami/aws-cli:2.4.25
    resources:
      requests:
        cpu: 200m
        memory: 400Mi
      limits:
        cpu: 1024m
        memory: 2048Mi
    command:
    - cat
    tty: true
  securityContext:
    runAsUser: 0
    fsGroup: 0
'''
        }
    }
    stages {
      stage ('GitLab') {
        steps {
        echo 'Building....'
                updateGitlabCommitStatus name: 'build', state: 'running'
        }
      }
      stage ('Configure AWS Credentials') {
          steps {
              withCredentials([[
              $class: 'AmazonWebServicesCredentialsBinding',
              accessKeyVariable: 'AWS_ACCESS_KEY_ID',
              credentialsId: AWSCRED,  // ID of credentials in Jenkins
              secretKeyVariable: 'AWS_SECRET_ACCESS_KEY'

              ]]){
              container('aws-cli') {
                  sh '''
                  ls -lha
                  aws sts get-caller-identity
                  '''
                  }
              }
          }
          post{
            success{
              echo "==== IAM Role assumed successfully ===="
            }
            failure{
              echo "==== IAM Role failed to be assumed ===="
            }
          }
      }
...
  • Related