Integration of Jenkins, eks and code commit

·

2 min read

Deploying application to eks using just jenkins(not octopus).

-> Install kubernetes continuos deploy plugin in jenkins.

-> Add kubeconfig details to jenkins.

Manage Jenkins >> manage credentials >> global >> add credentials

Select Kind as Kubeconfig.

-> By default, clusterrolebinding has system:anonymous set which blocks the cluster access. Execute the following command to set a clusterrole as cluster-admin which will give you the required access.

cmd -- kubectl create clusterrolebinding cluster-system-anonymous --clusterrole=cluster-admin --user=system:anonymous

-> Push all your config files to aws code commit repo.

-> Now can either create free style project or pipeline project.

-->> Create a free style project.

-- Give your repo details.

-- Select your kubeconfig id which was created previously in global credentials.

Give names of all your config files separated by comma under config files section.

-- Build your project. All your specified yaml files will be deployed in your eks cluster.

-->> Create a pipeline project.

-- Create a pipeline script with all your details(Code commit repo url, config file names, etc)

-- Build your project. Your Application will be deployed to the eks cluster.

Pipeline Script :

pipeline {

agent any

stages {

stage ("checkout from GIT") {

steps {

git branch: 'main', credentialsId: '<<credID>>', url: 'https://git-codecommit.<<aws-region>>.amazonaws.com/v1/repos<<reponame>\>'

}

}

stage ("Deploy Application") {

steps {

kubernetesDeploy configs: '2048-deployment.yaml,2048-service.yaml,2048-ingress.yaml', kubeConfig: [path: ''], kubeconfigId: '<<kubeconfigID>>', secretName: '', ssh: [sshCredentialsId: '*', sshServer: ''], textCredentials: [certificateAuthorityData: '', clientCertificateData: '', clientKeyData: '', serverUrl: 'https://']

}

}

}

}