diff --git a/Application.yml b/Application.yml
new file mode 100644
index 0000000..0d4907d
--- /dev/null
+++ b/Application.yml
@@ -0,0 +1,34 @@
+kind: Service
+apiVersion: v1
+metadata:
+ name: notesapp
+ namespace: euc-ns
+spec:
+ selector:
+ app: notesapp
+ ports:
+ - protocol: TCP
+ port: 8080
+ type: NodePort
+---
+apiVersion: extensions/v1beta1
+kind: Deployment
+metadata:
+ name: notesapp
+ namespace: euc-ns
+spec:
+ selector:
+ matchLabels:
+ app: notesapp
+ replicas: 2
+ template:
+ metadata:
+ labels:
+ app: notesapp
+ spec:
+ containers:
+ - name: notesapp
+ image: venkatadri/springboot-notesapp:31
+ imagePullPolicy: Always
+ ports:
+ - containerPort: 8080
diff --git a/Application_mysql.yml b/Application_mysql.yml
new file mode 100644
index 0000000..010ad2c
--- /dev/null
+++ b/Application_mysql.yml
@@ -0,0 +1,90 @@
+apiVersion: v1
+kind: Service
+metadata:
+ name: mysql
+ namespace: euc-ns
+spec:
+ type: NodePort
+ ports:
+ - port: 3306
+ targetPort: 3306
+ nodePort: 31291
+ selector:
+ app: mysql
+ #clusterIP: None
+---
+apiVersion: v1
+kind: Secret
+metadata:
+ name: mysql-secret
+ namespace: euc-ns
+type: Opaque
+data:
+ MYSQL_ROOT_PASSWORD: cGFzc3dvcmQ= #password
+ MYSQL_DATABASE: dGVzdA== #test
+ MYSQL_USER: dGVzdHVzZXI= #testuser
+ MYSQL_PASSWORD: dGVzdDEyMw== #test123
+---
+apiVersion: v1
+kind: PersistentVolumeClaim
+metadata:
+ name: mysql-pv-claim
+ namespace: euc-ns
+spec:
+ accessModes:
+ - ReadWriteOnce
+ resources:
+ requests:
+ storage: 5Gi
+---
+apiVersion: extensions/v1beta1
+kind: Deployment
+metadata:
+ name: mysql
+ namespace: euc-ns
+spec:
+ selector:
+ matchLabels:
+ app: mysql
+ strategy:
+ type: Recreate
+ template:
+ metadata:
+ labels:
+ app: mysql
+ spec:
+ containers:
+ - image: mysql:5.7
+ name: mysql
+ env:
+ # Use secret in real usage
+ - name: MYSQL_ROOT_PASSWORD
+ valueFrom:
+ secretKeyRef:
+ name: mysql-secret
+ key: MYSQL_ROOT_PASSWORD
+ - name: MYSQL_DATABASE
+ valueFrom:
+ secretKeyRef:
+ name: mysql-secret
+ key: MYSQL_DATABASE
+ - name: MYSQL_USER
+ valueFrom:
+ secretKeyRef:
+ name: mysql-secret
+ key: MYSQL_USER
+ - name: MYSQL_PASSWORD
+ valueFrom:
+ secretKeyRef:
+ name: mysql-secret
+ key: MYSQL_PASSWORD
+ ports:
+ - containerPort: 3306
+ name: mysql
+ volumeMounts:
+ - name: mysql-persistent-storage
+ mountPath: /var/lib/mysql
+ volumes:
+ - name: mysql-persistent-storage
+ persistentVolumeClaim:
+ claimName: mysql-pv-claim
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..1dd7db6
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,20 @@
+# Start with a base image containing Java runtime
+FROM openjdk:8-jdk-alpine
+
+# Add Maintainer Info
+MAINTAINER venkatadri
+
+# Add a volume pointing to /tmp
+VOLUME /tmp
+
+# Make port 8080 available to the world outside this container
+EXPOSE 8080
+
+# The application's jar file
+ARG JAR_FILE=target/easy-notes-1.0.0.jar
+
+# Add the application's jar to the container
+ADD ${JAR_FILE} easy-notes-1.0.0.jar
+
+# Run the jar file
+ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/easy-notes-1.0.0.jar"]
diff --git a/Jenkinsfile b/Jenkinsfile
new file mode 100644
index 0000000..7bdc5b2
--- /dev/null
+++ b/Jenkinsfile
@@ -0,0 +1,102 @@
+pipeline {
+ environment {
+ // SONAR_HOST_URL='http://54.68.58.133:9000/'
+ registry = 'venkatadri/springboot-notesapp'
+
+ //it shoud map to jenkins credentiala
+ registryCredential = 'dokerhubvenkat'
+ dockerImage = ''
+ containerId = sh(script: 'docker ps -aqf "name=notes-app"', returnStdout: true)
+ }
+ agent any
+ tools {
+ maven 'maven'
+ }
+
+ stages {
+
+ stage('Build') {
+ steps {
+ // sh "mvn clean package"
+ sh "mvn -B -DskipTests clean package"
+ }
+ }
+ stage('UnitTest') {
+ steps {
+ sh "mvn test"
+ }
+ post {
+ always {
+ junit 'target/surefire-reports/*.xml'
+ }
+ }
+ }
+ //commanted for time being
+ /*stage('StaticCode Analysis') {
+ steps {
+ sh "mvn sonar:sonar -Dsonar.host.url=$SONAR_HOST_URL"
+ }
+ }*/
+
+ /* stage('cleanup') {
+ steps {
+ sh 'docker stop chat-app'
+ sh 'docker rm chat-app'
+ //sh 'docker rmi -f $registry'
+ }
+ }*/
+ stage('Building image') {
+ steps {
+ script {
+ //Buildnumber will act as tag for the image , if you want to access the image use venkatadri/springboot-notesapp:1
+ dockerImage = docker.build registry + ":$BUILD_NUMBER"
+ }
+ }
+ }
+
+ /* no need to enable it when you are using kubernetes (Application.ymal file)
+ stage('Run Container') {
+ steps {
+ sh 'docker run --name=chat-app -d -p 5000:8080 $registry:$BUILD_NUMBER &'
+ }
+ }*/
+ stage('push image') {
+ steps {
+ script {
+ docker.withRegistry('', registryCredential) {
+ dockerImage.push()
+ }
+ }
+ }
+ }
+
+ /* stage('Deploy the database') {
+ steps{
+ //Deploying the docker image as the service using kubernets cd plug in
+ //mehtod to deploy the ymal file
+ kubernetesDeploy(
+ kubeconfigId: 'kubeconfig',
+ configs: 'Application_mysql.yml',
+ enableConfigSubstitution: false
+ )
+ }
+
+
+
+ }*/
+ stage('Deploy the application') {
+ steps{
+ //Deploying the docker image as the service using kubernets cd plug in
+ //mehtod to deploy the ymal file
+ kubernetesDeploy(
+ kubeconfigId: 'kubeconfig',
+ configs: 'Application.yml',
+ enableConfigSubstitution: false
+ )
+ }
+
+
+
+ }
+ }
+}
diff --git a/pom.xml b/pom.xml
index 9c59df4..c07ac53 100644
--- a/pom.xml
+++ b/pom.xml
@@ -49,10 +49,24 @@
spring-boot-starter-test
test
+
+ junit
+ junit
+ 4.12
+ test
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ 2.22.1
+
+ false
+
+
org.springframework.boot
spring-boot-maven-plugin
diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties
index b0f06a8..a06f4c7 100644
--- a/src/main/resources/application.properties
+++ b/src/main/resources/application.properties
@@ -1,7 +1,9 @@
## Spring DATASOURCE (DataSourceAutoConfiguration & DataSourceProperties)
-spring.datasource.url = jdbc:mysql://localhost:3306/notes_app?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&useSSL=false
+#spring.datasource.url = jdbc:mysql://35.162.116.121:31234/notes_app?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&useSSL=false
+spring.datasource.url = jdbc:mysql://54.202.24.146:31291/test?useSSL=false
+# ip is my sql exposed ip with the port number
spring.datasource.username = root
-spring.datasource.password = callicoder
+spring.datasource.password = password
## Hibernate Properties
@@ -10,4 +12,4 @@ spring.datasource.password = callicoder
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5InnoDBDialect
# Hibernate ddl auto (create, create-drop, validate, update)
-spring.jpa.hibernate.ddl-auto = update
\ No newline at end of file
+spring.jpa.hibernate.ddl-auto = update