Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 33 additions & 46 deletions Jenkinsfile-K8s-Deploy
Original file line number Diff line number Diff line change
@@ -1,65 +1,52 @@

pipeline {
tools {
maven 'maven3'
}
agent any
environment {
//once you sign up for Docker hub, use that user_id here
registry = "ananthkannan/mypython-app-may20"
//- update your credentials ID after creating credentials for connecting to Docker Hub
registryCredential = 'dockerhub'
dockerImage = ''
environment {
registry = " 136356824322.dkr.ecr.us-east-2.amazonaws.com/yohyoh/kubectl-repo:latest"
}

stages {

stage ('checkout') {
stage('Cloning Git') {
steps {
checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[url: 'https://github.com/akannan1087/myPythonDockerRepo']]])
checkout([$class: 'GitSCM', branches: [[name: '*/main']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: '', url: 'https://github.com/akannan1087/springboot-app']]])
}
}

stage ('Build docker image') {
steps {
script {
dockerImage = docker.build registry + ":$BUILD_NUMBER"
//dockerImage = docker.build registry + ":$BUILD_NUMBER"

}
stage ('Build') {
steps {
sh 'mvn clean install'
}
}

// Uploading Docker images into Docker Hub
stage('Upload Image') {
steps{
script {
docker.withRegistry( '', registryCredential ) {
dockerImage.push()
}
}
}
}

stage('Remove Unused docker image') {
// Building Docker images
stage('Building image') {
steps{
sh "docker rmi $registry:$BUILD_NUMBER"
script {
dockerImage = docker.build registry
}
}
}

stage ('K8S Deploy') {
steps {
// Uploading Docker images into AWS ECR
stage('Pushing to ECR') {
steps{
script {
sh 'aws ecr get-login-password --region us-east-2 | docker login --username AWS --password-stdin 136356824322.dkr.ecr.us-east-2.amazonaws.com'
sh 'docker push 136356824322.dkr.ecr.us-east-2.amazonaws.com/yohyoh/kubectl-repo:latest'
}
}
}

stage('K8S Deploy') {
steps{
script {
kubernetesDeploy(
configs: 'k8s-deployment.yaml',
kubeconfigId: 'K8S',
enableConfigSubstitution: true
)

withKubeConfig([credentialsId: 'K8S', serverUrl: '']) {
sh ('kubectl apply -f eks-deploy-k8s.yaml')
}
}
}
}
}

}
}

always {
// remove built docker image and prune system
print 'Cleaning up the Docker system.'
sh 'docker system prune -f'
}
6 changes: 6 additions & 0 deletions eks-deploy-from-ecr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,9 @@ spec:
port: 80
targetPort: 5000
type: ClusterIP

spec:
containers:
- name: kubectl-repo-container
image: 136356824322.dkr.ecr.us-east-2.amazonaws.com/yohyoh/kubectl-repo:latest
imagePullPolicy: Always # Forces K8s to pull the new 'latest' image every time
2 changes: 1 addition & 1 deletion k8s-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ spec:
spec:
containers:
- name: my-python-app
image: 211223789150.dkr.ecr.us-east-1.amazonaws.com/coachak/my-docker-repo:${BUILD_NUMBER}
image: 136356824322.dkr.ecr.us-east-2.amazonaws.com/mybuilder/docker/repo:latest:${BUILD_NUMBER}
imagePullPolicy: Always
ports:
- containerPort: 5000
Expand Down
2 changes: 1 addition & 1 deletion mychart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
replicaCount: 1

image:
repository: 211223789150.dkr.ecr.us-east-1.amazonaws.com/my-docker-repo
repository: 136356824322.dkr.ecr.us-east-2.amazonaws.com/mybuilder/dodo/repo:latest
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: ""
Expand Down
6 changes: 4 additions & 2 deletions templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<style type="text/css">
body {
background: black;
color: red;
color: yellow;
}
div.container {
max-width: 500px;
Expand All @@ -19,9 +19,11 @@
</head>
<body>
<div class="container">
<h4>Welcome to Richiyo Dickson Docker Container running inside EKS Cluster - Feb 11th, 2026!!</h4>
<h4>Deploying Containers into EKS cluster using Jenkins Pipeline !!!!!</h4>
<h4>Welcome to Docker Container running inside Docker container.. on June 11th, 2025!!</h4>
<br>
<h4>Learning containers is really fun and awesome!!!!!</h4>
<h4>Learning containers is really fun and awesome i love it !!!!!</h4>
</div>
</body>
</html>
Loading