Deploy To Kubernetes with Jenkins GitOps GitHub Pipeline
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
https://www.youtube.com/watch?v=o4QG_kqYvHk
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Basic Jenkins file for the pipeline. Docker image creation and building
pipeline {
agent any
environment {
ECR_REPOSITORY = 'your-ecr-repository'
GITOPS_REPO_URL = 'https://github.com/your-gitops-repo.git'
GITOPS_REPO_CREDENTIALS = credentials('your-gitops-credentials-id')
}
stages {
stage('Build Docker Image') {
steps {
script {
def dockerImage = docker.build("${ECR_REPOSITORY}:${BUILD_NUMBER}")
}
}
}
stage('Push Docker Image to ECR') {
steps {
script {
withCredentials([
usernamePassword(credentialsId: 'your-ecr-credentials-id', usernameVariable: 'AWS_ACCESS_KEY_ID', passwordVariable: 'AWS_SECRET_ACCESS_KEY')
]) {
sh """
docker login -u \${AWS_ACCESS_KEY_ID} -p \${AWS_SECRET_ACCESS_KEY} ${ECR_REPOSITORY}
docker push ${ECR_REPOSITORY}:${BUILD_NUMBER}
"""
}
}
}
}
stage('Push Deployment File to GitOps Repo') {
steps {
script {
git branch: 'main', credentialsId: GITOPS_REPO_CREDENTIALS, url: GITOPS_REPO_URL
sh """
cp path/to/your/deployment.yaml .
git add deployment.yaml
git commit -m "Update deployment.yaml"
git push origin main
"""
}
}
}
}
}
SECOND VIDEO IS BETTER
https://www.youtube.com/watch?v=mhMMNl8mgbY
Comments
Post a Comment