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 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.
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
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
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
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
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
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 dashboard with details of components that are created as a part of this cluster setup are available below.
Below is the screenshot that contains list of Persistent Volumes
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.