DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

Balaji SR
Balaji SR

Posted on

DevOps tool-chain setup on Kubernetes cluster. Part - 3/3

alt text

Introduction

This is the 3rd and final part in continuation with my previous articles on DevOps tool-chain setup on Kubernetes cluster. In this article, I have explained how to setup Nexus on the Kubernetes cluster.

Nexus setup on Kubernetes cluster

Nexus is an artifact repository which plays an important role in the software development lifecycle especially in the age of Docker containers. I have created the below list of Kubernetes components to host Nexus artifact repository on the cluster.

Storage class for Nexus

I have created the Storage Class for Nexus.

kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: nexus-storage-data
  labels:
    app: nexus-storage-data
provisioner: kubernetes.io/aws-ebs
parameters:
  type: gp2
  zone: eu-west-2a
allowVolumeExpansion: true
Enter fullscreen mode Exit fullscreen mode

Persistence Volume for Nexus

I have created Persistence Volume for Nexus with Storage space of 2GB on the Kubernetes Cluster.

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: nexus-storage
  labels:
    app: nexus-storage
  annotations:
    volume.beta.kubernetes.io/storage-class: "nexus-storage-data"
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 2Gi
Enter fullscreen mode Exit fullscreen mode

Deployment for Nexus

I have created a deployment script which pulls the Nexus image if not persent in the Kubernetes cluster and configured on port 8081. I have configured user group for Nexus user.

kind: Deployment
apiVersion: extensions/v1beta1
metadata:
  name: nexus
spec:
  replicas: 1
  template:
    metadata:
      name: nexus
      labels: 
        app: nexus
    spec:
      securityContext:
        fsGroup: 2000
      containers:
        - name: nexus
          image: sonatype/nexus3:3.8.0
          imagePullPolicy: IfNotPresent
          ports:
            - containerPort: 8081
              name: nexusport
          volumeMounts:
            - name: nexus-data
              mountPath: /nexus-data
      volumes:
        - name: nexus-data
          persistentVolumeClaim:
            claimName: nexus-storage
Enter fullscreen mode Exit fullscreen mode

Service for Nexus

I have created service for Nexus on port 8081

kind: Service
apiVersion: v1
metadata:
  name: nexus
  labels:
    app: nexus-svc
spec:
  type: NodePort
  ports:
    - port: 8081
      targetPort: 8081
      name: nexusport
  selector:
    app: nexus
  type: LoadBalancer
Enter fullscreen mode Exit fullscreen mode

By now I have created storage class, persistent volume, deployment, and service for Nexus and it is up & running.

$kubectl get deployment
$kubectl get pod
$kubectl get svc
Enter fullscreen mode Exit fullscreen mode

By now all Kubernetes components are created for the CI/CD pipeline and it can be verified either by executing a command or by using the Kubernetes dashboard. In the below section, I am going to use the Kubernetes dashboard to verify the components that I have created.

Kubernetes cluster components

Kubernetes dashboard with details of components that are created as a part of this cluster setup are available below.

Persistent Volumes

Below is the screenshot that contains list of Persistent Volumes

alt text

Storage Classes – Below is the list of Storage Classes
alt text

Deployments – Below is the list of Deployments
alt text

Services – Below is the list of services
alt text

Conclusion

By now, I have covered the entire CI/CD toolset - Jenkins, sonarqube with PostgreSQL and nexus set up with the single replica on the kubernetes cluster. This can be used to establish a DevOps pipeline on the kubernetes cluster.

Top comments (0)

Timeless DEV post...

Git Concepts I Wish I Knew Years Ago

The most used technology by developers is not Javascript.

It's not Python or HTML.

It hardly even gets mentioned in interviews or listed as a pre-requisite for jobs.

I'm talking about Git and version control of course.

One does not simply learn git