Github Repository : https://github.com/Razorops-code/spring-boot.git
You can create GKE cluster by following the official documentation or GUI model
After creating GKE cluster
To access a cluster using kubectl, you have to set up a Kubernetes configuration file (commonly known as a ‘kubeconfig’ file) for the cluster. The kubeconfig file (by default named config and stored in the $HOME/.kube directory) provides the necessary details to access the cluster. Having set up the kubeconfig file, you can start using kubectl to manage the cluster. For razorops you can follow the process mentioned here to access the cluster
Here you can add name for cluster and authentication method Here we can go with kubernetes ConfigFile (which is generated by connect credentials )
You can navigate to the add a new pipeline dashboard by clicking on New Pipeline.
tasks:
build-job:
steps:
- checkout
- commands:
- |
mvn clean package # build the package
ls -a
ls target
- docker/build:
image: razoropsrepocode/spring # build the image with Dockerfile
push: true # push image to docker hub repository Which is integrated
tags: ["latest-v2"]
# kubernets deployment
deploy-kubernets:
when: branch == 'master' # only run if code is pushed to develop branch
depends: [build-job]
steps:
- checkout
- commands:
- |
kubectl create -f deployment.yml
kubectl create -f service.yml
kubectl get svc
deployment.yml
apiVersion: apps/v1
kind: Deployment
metadata:
name: sample-java-app
spec:
replicas: 1
selector:
matchLabels:
app: java-app
template:
metadata:
labels:
app: java-app
spec:
containers:
- name: java-app
image: razoropsrepocode/spring:latest-v2
imagePullPolicy: Always
ports:
- containerPort: 8080
service.yml
apiVersion: v1
kind: Service
metadata:
name: sample-java-app
spec:
type: NodePort
ports:
- port: 8080
targetPort: 8080
selector:
app: java-app
Successfully Sample-java-app pod up and running and works on NodePort-service- 30516
We can find
Note:- This application working on tomcat server we need to mention application name i.e spring3</b>