How To Setup Latest Nexus OSS On Kubernetes

Nexus is an opensource artifact storage and management system. It is a widely used tool and can be seen in most of the CI/CD workflows. We have covered Nexus setup on Linux VM in another article.

This guide will walk you through the step by step process of deploying Sonatype Nexus OSS on a Kubernetes cluster.

Setup Nexus OSS On Kubernetes

Key things to be noted,

  1. Nexus deployment and service are created in the devops-tools namespace. So make sure you have the namespace created or you can edit the YAML to deploy in a different namespace. Also, we have different deployment files for Nexus 2 & Nexus 3 versions.
  2. In this guide, we are using the volume mount for nexus data. For production workloads, you need to replace host volume mounts with persistent volumes.
  3. Service is exposed as NodePort. It can be replaced with LoadBalancer type on a cloud.

Let’s get started with the setup.

Step 1: Create a namespace called devops-tools

Step 2:  Create a Deployment.yaml file. It is different for nexus 2.x and 3.x. We have given both. Create the YAML based on the Nexus version you need. Note: The images used in this deployment is from public official Sonatype docker repo.(Nexus2 image  & Dockerfile )  (nexus 3 image & Dockerfile)

  1. Deployment YAML for Nexus 2.x: Here we are passing a few customizable ENV variable and adding a volume mount for nexus data.
  2. Deployment YAML for Nexus 3.x: Here we dont have any custom env variables. You can check the official docker repo for the supported env variables.

Step 3: Create the deployment using kubectl command.

Check the deployment pod status

[irp posts=”1851″ name=”Kubernetes Certification Coupon: 16% Off + $100 Off On Kubernetes Course bundle”]

Step 4: Create a Service.yaml file with the following contents to expose the nexus endpoint using NodePort.

Note: If you are on a cloud, you can expose the service using a load balancer using the service type Loadbalancer. Also, the Prometheus annotations will help in service endpoint monitoring by Prometheus.

Check the service configuration using kubectl.

Step 5: Now you will be able to access nexus on any of the Kubernetes node IP on port 32000/nexus as we have exposed the node port. For example,

For Nexus 2,

For Nexus 3,

Note: The default username and password will be admin & admin123

Free DevOps Resources

Get DevOps news, tutorials and resources in your inbox. A perfect way If you want to get started with devops. Like you, we dont like spam.