Sonatype Nexus 3 on Kubernetes

Sonatype Nexus 3 repository


In this installment, we will deploy and setup Sonatype nexus 3 repository on Kubernetes.


  • Introduction
  • prerequisites
  • Creating deployment
  • Accessing web UI
  • Complete resources

1. Introduction

maven central has been always a go to and convenient resource for every java developer for any libraries. There are over 18M artifacts available for download.

That’s great, but what if we want to host our own artifacts in order for us to reuse but don't necessarily want to make them public?

That’s where self-hosted private repository comes in to picture. Nexus in one among many options available out there and is quite popular.

There are other ways of course to run nexus 3. But we will focus on Kubernetes in this article.

so let’s go ahead and see how can we run nexus in our own Kubernetes cluster.

2. prerequisites

  • Basic understanding of Kubernetes
  • Kubernetes cluster (any Kubernetes distro)

3. creating deployment


now run

This will create a deployment with 1 pod. We are pulling nexus 3 images from docker hub specified by containers:

now if you check logs for pod,

NAME                                  READY   STATUS    RESTARTS   AGEsonatype-registry-cb5d64895-czgdx     1/1     Running   0          20s

you will find something like this in the logs. Which means nexus is started.

Started Sonatype Nexus OSS 3.29.2–02— — — — — — — — — — — — — — — — — — — — — — — — -

Your first time password will be store in /nexus-data/admin.password

<your first time password>

4. Accessing web UI

In order to access the web UI, we will create a service of type NodePort

Now you can access Web UI at http://<node ip>:32323

That’s it. We deployed nexus in Kubernetes. But if we restart the pod, all the data get deleted. We need to use persistence. Lets do that.

In order for PVC to work, you need some kind of previsioner like NFS.
To set up NFS you can refer this link

Below is the complete yamls to create service, deployment and volumes.

5. Complete resources

apiVersion: apps/v1
kind: Deployment
name: sonatype-registry
app: sonatype-registry
replicas: 1
app: sonatype-registry
app: sonatype-registry
- name: registry-vol
claimName: sonatype-registry-data
- image: sonatype/nexus3
name: nexus
- containerPort: 8081
- name: registry-vol
mountPath: /nexus-data
subPath: sonatype

And that is it. Thanks.

Cloud Engineer, Java progammer