Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

K8s #63

Open
wants to merge 116 commits into
base: master
Choose a base branch
from
Open

K8s #63

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
116 commits
Select commit Hold shift + click to select a range
7c7e792
Create jenkinsfile
tarundanda147 Jan 17, 2024
b7ba949
Rename jenkinsfile to Jenkinsfile
tarundanda147 Jan 17, 2024
c2b32fc
Update Jenkinsfile
tarundanda147 Jan 17, 2024
1bde0c2
Update Jenkinsfile
tarundanda147 Jan 17, 2024
ecfe6ee
Update Jenkinsfile
tarundanda147 Jan 17, 2024
87b90c4
Update Jenkinsfile
tarundanda147 Jan 17, 2024
6f9393f
Update Jenkinsfile
tarundanda147 Jan 17, 2024
7d2a53a
Update Jenkinsfile
tarundanda147 Jan 17, 2024
1e3d9e7
Update Jenkinsfile
tarundanda147 Jan 17, 2024
1b44c29
Update Jenkinsfile
tarundanda147 Jan 17, 2024
056db2a
Update Jenkinsfile
tarundanda147 Jan 17, 2024
40c2bf1
Update Jenkinsfile
tarundanda147 Jan 17, 2024
bbbe9df
Update Jenkinsfile
tarundanda147 Jan 17, 2024
19a09bf
Update Jenkinsfile
tarundanda147 Jan 17, 2024
eb9a687
Update Jenkinsfile
tarundanda147 Jan 17, 2024
1878379
Update Jenkinsfile
tarundanda147 Jan 17, 2024
1449ccd
Update Jenkinsfile
tarundanda147 Jan 17, 2024
573d94c
Update Jenkinsfile
tarundanda147 Jan 17, 2024
2df2763
Update Jenkinsfile
tarundanda147 Jan 17, 2024
4d1bcce
Update Jenkinsfile
tarundanda147 Jan 19, 2024
bfa18bd
Create artifactory
tarundanda147 Jan 19, 2024
86c6710
Update artifactory
tarundanda147 Jan 19, 2024
3a8dfda
Update Jenkinsfile
tarundanda147 Mar 15, 2024
a248531
Create Dockerfile
tarundanda147 Mar 15, 2024
d910ea9
Update Jenkinsfile
tarundanda147 Mar 15, 2024
1575f67
Update Jenkinsfile
tarundanda147 Mar 15, 2024
e653914
Update Jenkinsfile
tarundanda147 Mar 15, 2024
a377b63
Update Jenkinsfile
tarundanda147 Mar 15, 2024
c802265
Update Jenkinsfile
tarundanda147 Mar 18, 2024
4c3d58e
Update Jenkinsfile
tarundanda147 Mar 20, 2024
2e37500
Update Jenkinsfile
tarundanda147 Mar 20, 2024
053ecf3
Update Jenkinsfile
tarundanda147 Mar 20, 2024
48b1de6
Update Jenkinsfile
tarundanda147 Mar 20, 2024
167fa5b
Update Jenkinsfile
tarundanda147 Mar 20, 2024
4b4c247
Update Jenkinsfile
tarundanda147 Mar 20, 2024
fd0e578
Update Jenkinsfile
tarundanda147 Mar 20, 2024
c94f9a9
Update Jenkinsfile
tarundanda147 Mar 20, 2024
0038553
Update Jenkinsfile
tarundanda147 Mar 20, 2024
4e965be
Update Jenkinsfile
tarundanda147 Mar 20, 2024
704dc3e
Create deployment.yml
tarundanda147 Apr 15, 2024
e8719db
Create storageclass.yml
tarundanda147 Apr 15, 2024
66dd6e9
Create pvc.yml
tarundanda147 Apr 15, 2024
bf58aca
Update deployment.yml
tarundanda147 Apr 15, 2024
71afe05
Create service.yml
tarundanda147 Apr 15, 2024
050e827
Create ingress-route.yml
tarundanda147 Apr 15, 2024
faa903b
Create values.yml
tarundanda147 Apr 15, 2024
0708fc3
Update deployment.yml
tarundanda147 Apr 15, 2024
5ce841f
Update ingress-route.yml
tarundanda147 Apr 15, 2024
650e3ff
Update ingress-route.yml
tarundanda147 Apr 15, 2024
d83521b
Update values.yml
tarundanda147 Apr 15, 2024
5c918d6
Update service.yml
tarundanda147 Apr 15, 2024
7ab748c
Update ingress-route.yml
tarundanda147 Apr 15, 2024
0f8d5d8
Update values.yml
tarundanda147 Apr 15, 2024
5f16903
Update Jenkinsfile
tarundanda147 Apr 16, 2024
0d5aaaa
Update Jenkinsfile
tarundanda147 Apr 16, 2024
1fbf277
Update Jenkinsfile
tarundanda147 Apr 16, 2024
0675b49
Update Jenkinsfile
tarundanda147 Apr 16, 2024
9fc5471
Update Jenkinsfile
tarundanda147 Apr 16, 2024
673d891
Rename values.yml to values.yaml
tarundanda147 Apr 16, 2024
5c1fab0
Update values.yaml
tarundanda147 Apr 16, 2024
f0cb18f
Update service.yml
tarundanda147 Apr 16, 2024
f450099
Update deployment.yml
tarundanda147 Apr 16, 2024
fb2e0b4
Update values.yaml
tarundanda147 Apr 16, 2024
c176e13
Update Jenkinsfile
tarundanda147 Apr 16, 2024
b650b62
Create Chart.yaml
tarundanda147 Apr 16, 2024
454bb19
done
tarundanda147 Apr 16, 2024
ba371bd
Update values.yaml
tarundanda147 Apr 16, 2024
ebe5d71
Update deployment.yml
tarundanda147 Apr 16, 2024
dda3a6a
Update values.yaml
tarundanda147 Apr 16, 2024
91369d6
Update Jenkinsfile
tarundanda147 Apr 16, 2024
69a43b4
Update Jenkinsfile
tarundanda147 Apr 16, 2024
eb114a6
Update Jenkinsfile
tarundanda147 Apr 16, 2024
9bd83ab
Update Jenkinsfile
tarundanda147 Apr 16, 2024
69db2e5
Update Jenkinsfile
tarundanda147 Apr 16, 2024
9066d3e
Update Jenkinsfile
tarundanda147 Apr 16, 2024
96de145
Update Jenkinsfile
tarundanda147 Apr 16, 2024
3614eb0
Update Jenkinsfile
tarundanda147 Apr 16, 2024
458be9e
Update Jenkinsfile
tarundanda147 Apr 16, 2024
81f847c
Update Jenkinsfile
tarundanda147 Apr 16, 2024
a6ad39d
Update Jenkinsfile
tarundanda147 Apr 16, 2024
90f2467
Update Jenkinsfile
tarundanda147 Apr 16, 2024
be507a6
Update Jenkinsfile
tarundanda147 Apr 16, 2024
0b9c951
Update Jenkinsfile
tarundanda147 Apr 16, 2024
9be06ca
Update Jenkinsfile
tarundanda147 Apr 16, 2024
a0649c2
Update Jenkinsfile
tarundanda147 Apr 16, 2024
2ae072c
Update Jenkinsfile
tarundanda147 Apr 16, 2024
1434f7e
Update Jenkinsfile
tarundanda147 Apr 16, 2024
9398862
Update Jenkinsfile
tarundanda147 Apr 16, 2024
79282d3
Update Jenkinsfile
tarundanda147 Apr 16, 2024
539c06f
Update Jenkinsfile
tarundanda147 Apr 16, 2024
a568e39
Update Jenkinsfile
tarundanda147 Apr 16, 2024
f0a4a67
Update Jenkinsfile
tarundanda147 Apr 16, 2024
e7e2724
Update Jenkinsfile
tarundanda147 Apr 17, 2024
9c0e3f1
Update Jenkinsfile
tarundanda147 Apr 17, 2024
1a04552
Update Jenkinsfile
tarundanda147 Apr 17, 2024
b811760
Update Jenkinsfile
tarundanda147 Apr 17, 2024
6d322e0
Update Jenkinsfile
tarundanda147 Apr 17, 2024
66225aa
Update Jenkinsfile
tarundanda147 Apr 17, 2024
f150041
Update Jenkinsfile
tarundanda147 Apr 17, 2024
c6ac295
Update Jenkinsfile
tarundanda147 Apr 17, 2024
a0ab736
Update Jenkinsfile
tarundanda147 Apr 17, 2024
855da0f
Update Jenkinsfile
tarundanda147 Apr 17, 2024
1442e65
Update Jenkinsfile
tarundanda147 Apr 17, 2024
cf50a30
Update Jenkinsfile
tarundanda147 Apr 17, 2024
589dd8d
Update Jenkinsfile
tarundanda147 Apr 17, 2024
9c882d0
Update Jenkinsfile
tarundanda147 Apr 17, 2024
b039de4
Update Jenkinsfile
tarundanda147 Apr 17, 2024
cd94e90
Update ingress-route.yml
tarundanda147 Apr 17, 2024
09c1c2e
Update deployment.yml
tarundanda147 Apr 17, 2024
f63aae2
Update deployment.yml
tarundanda147 Apr 17, 2024
72bcd51
Create secrets.yml
tarundanda147 Apr 17, 2024
230ecd0
Update deployment.yml
tarundanda147 Apr 17, 2024
a45da06
Delete templates/secrets.yml
tarundanda147 Apr 17, 2024
caef11d
Update deployment.yml
tarundanda147 Apr 17, 2024
0eea549
Update deployment.yml
tarundanda147 Apr 17, 2024
039e1eb
Create secrets.yml
tarundanda147 Apr 17, 2024
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
23 changes: 23 additions & 0 deletions .helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
24 changes: 24 additions & 0 deletions Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: hello-world-war
description: A Helm chart for Kubernetes

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "1.16.0"
10 changes: 10 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM maven:3.3-jdk-8 as mavenbuilder
ARG DIR=/home/devops
WORKDIR $DIR
COPY . .
RUN /usr/bin/mvn clean install
RUN ls target/
RUN which mvn
FROM tomcat:9.0
ARG DIR=/home/devops/target
COPY --from=mavenbuilder ${DIR}/hello-world-war-1.0.0.war /usr/local/tomcat/webapps/
49 changes: 49 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
pipeline {
agent any

stages {
stage('checkout') {
steps {
sh 'rm -rf hello-world-war'
sh 'git clone -b k8s https://github.com/tarundanda147/hello-world-war.git'
}
}

stage('build') {
steps {
dir("hello-world-war") {
sh 'echo "inside build"'
sh "docker build -t tomcat-war:${BUILD_NUMBER} ."
}
}
}

stage('push') {
steps {
withCredentials([usernamePassword(credentialsId: '773e6289-72b6-476b-9e54-19702f9fb5d3', usernameVariable: 'DOCKER_USERNAME', passwordVariable: 'DOCKER_PASSWORD')]) {
sh "docker login -u ${DOCKER_USERNAME} -p ${DOCKER_PASSWORD}"
sh "docker tag tomcat-war:${BUILD_NUMBER} tarundanda147/tomcat:${BUILD_NUMBER}"
sh "docker push tarundanda147/tomcat:${BUILD_NUMBER}"
}
}
}

stage('Helm Deploy') {
steps {
// Authenticate with AWS using IAM credentials stored in Jenkins
withCredentials([[
$class: 'AmazonWebServicesCredentialsBinding',
credentialsId: '03bb86f5-d824-42dd-b9c7-da3dc566f56c',
accessKeyVariable: 'AWS_ACCESS_KEY_ID',
secretKeyVariable: 'AWS_SECRET_ACCESS_KEY'
]]) {
sh "aws eks --region us-east-1 update-kubeconfig --name eks-cluster"
echo 'Deploying to Kubernetes using Helm'
// Deploy Helm chart to Kubernetes cluster
sh "helm upgrade first /var/lib/jenkins/workspace/eks-docker/hello-world-war --namespace hello-world-war --set image.tag=$BUILD_NUMBER --dry-run"
sh "helm upgrade first /var/lib/jenkins/workspace/eks-docker/hello-world-war --namespace hello-world-war --set image.tag=$BUILD_NUMBER"
}
}
}
}
}
60 changes: 60 additions & 0 deletions artifactory
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
pipeline {
agent { label 'java' }
stages {
stage('checkout') {
steps {
sh 'rm -rf bus_booking'
sh 'git clone https://github.com/tarundanda147/bus_booking.git'
}
}

stage('build') {
steps {
script {
sh "mvn clean install"
}
}
}
stage('Deploy to JFrog Artifactory') {
steps {
// Remember this is the step which I followed for free style project.
script {
rtServer(
id: "Artifact",
url: "http://13.238.154.172:8081/artifactory",
username: "jenkins",
password: "passwd"
)
}
}
}

stage('Upload') {
steps {
script {
// For my undertanding rtUpload is a part of jFrog Artifactory plugin to upload artifacts to artifacts repo
rtUpload (
serverId: 'Artifact',
spec: '''{
"files": [
{
"pattern": "target/*.jar",
"target": "libs-release-local/"
}
]
}'''
)
}
}
}

stage('Publish build info') {
steps {
script {
// For my understanding to publish build info
rtPublishBuildInfo serverId: "Artifact"
}
}
}
}
}
38 changes: 38 additions & 0 deletions templates/deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: myreplica
labels:
app: {{ .Values.deploymentLabel }}
spec:
replicas: {{ .Values.replicas }}
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
selector:
matchLabels:
app: {{ .Values.deploymentLabel }}
template:
metadata:
name: {{ .Values.deploymentLabel }}
labels:
app: {{ .Values.deploymentLabel }}
spec:
containers:
- name: {{ .Values.deploymentLabel }}
image: {{ .Values.imageName }}:{{ .Values.image.tag }}
imagePullSecrets:
- name: regcred
env:
- name: TOMCAT_OPTS
value: --prefix=/tomcat
volumeMounts:
- name: {{ .Values.volumeName }}
mountPath: /usr/local/tomcat/webapps
volumes:
- name: {{ .Values.volumeName }}
persistentVolumeClaim:
claimName: {{ .Values.claimName }}

16 changes: 16 additions & 0 deletions templates/ingress-route.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ .Values.ingressName }}
spec:
ingressClassName: nginx
rules:
- http:
paths:
- path: /hello-world-war-1.0.0
pathType: Prefix
backend:
service:
name: {{ .Values.serviceName }}
port:
number: 8090
11 changes: 11 additions & 0 deletions templates/pvc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ .Values.claimName }}
spec:
accessModes:
- ReadWriteOnce
storageClassName: {{ .Values.storageClass }}
resources:
requests:
storage: {{ .Values.requestStorage }}
8 changes: 8 additions & 0 deletions templates/secrets.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: v1
kind: Secret
metadata:
name: regcred
type: kubernetes.io/dockerconfigjson
data:
.dockerconfigjson: |-
ewogICAgImF1dGhzIjogewogICAgICAgICJodHRwczovL2luZGV4LmRvY2tlci5pby92MS8iOiB7CiAgICAgICAgICAgICJ1c2VybmFtZSI6ICJ0YXJ1bmRhbmRhMTQ3IiwKICAgICAgICAgICAgInBhc3N3b3JkIjogImRja3JfcGF0XzEtMk9nVFczNFlIMnFDb00zWnFvSTBKU2lJRSIsCiAgICAgICAgICAgICJlbWFpbCI6ICJob25leWNvY28xNDdAZ21haWwuY29tIgogICAgICAgIH0KICAgIH0KfQoK
13 changes: 13 additions & 0 deletions templates/service.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: Service
metadata:
name: {{ .Values.serviceName }}
spec:
type: ClusterIP
selector:
app: {{ .Values.deploymentLabel }}
ports:
- name: podport
protocol: TCP
port: 8090
targetPort: 8080
6 changes: 6 additions & 0 deletions templates/storageclass.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: {{ .Values.storageClass }}
provisioner: ebs.csi.aws.com
volumeBindingMode: WaitForFirstConsumer
11 changes: 11 additions & 0 deletions values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
deploymentName: "my-tomcat"
deploymentLabel: "tomcat"
replicas: 1
volumeName: "volume-tomcat"
claimName: "claim-tomcat"
storageClass: "tomcat-ebs"
requestStorage: "5Gi"
serviceName: "tomcat"
ingressName: "tomcat-ingress"
imageName: "tarundanda147/tomcat"
imageTag: "lts"