development tools

Integrate RazorOps with IBM K8s


Prerequisite :

  • An existing Razorops account
  • Creating clusters on cloud IBM

**Github Repository : ** https://github.com/Razorops-code/spring-boot.git

You can follow the these steps for creating IBM-cluster click here

After creating IBM-kubernetes cluster

Setting Up Cluster Access

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 to access the cluster Click here

After creating IBM-kubernetes-cluster successfully (Cluster name:- traing)

Next sign in to razorops with working github account

Next move to kubernetes section and click on Add New

Next you navigate to existing cluster Here you can add name for cluster and authentication method Here we can go with kubernetes ConfigFile (which is generated by connect credentials )

Here your config file looks like

Just copy and past at authentication section and click on Create Cluster

Next your cluster will added to Razorops kubernetes section successfully show like

luster added process completed next move to workflow section for run a pipeline for deploy our application on to kubernetes eks cluster

Now your in workflow dashboard

Next click on pipeline , you can navigate to the add a new pipeline dashboard

SELECT GITHUB

SELECT REPOSITORY

And confirm it

Enter the razorops 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"]
        # kubernetes deployment
  deploy-kubernetes:
    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

Next Run your first Build

Next automatically

  • clone source code from repository
  • Build code with maven
  • Create image with dockerfile
  • Push the image from dockerhub repository
  • Deploy the container on EKS cluster with kubernetes manifest file i.e (deployment.yml and service.yml )
  • Access the application with NodePort ip service

After pipeline running succeeded

We can find logs in logs section

And we can also find same logs in IBM shell

Successfully Sample-java-app pod up and running and works on NodePort-service- 30612

We can find :30612 In my case i.e 3.109.54.147:30612/spring3/ Note:- This application working on tomcat server we need to mention application name i.e spring3</b>

![]()