OpenShift Nexus

From NovaOrdis Knowledge Base
Jump to: navigation, search




Nexus is a repository and artifact manager used by OpenShift to cache locally build dependencies, and those used by Maven in particular, close to builds. It is recommended to set up one per OpenShift cluster, to speed up Maven builds. Nexus can be deployed using the procedure described below. An alternate method is to use the template available: here

Deploy Nexus Based on a Standard Sonatype Docker Image

oc new-app
For more details what happens during a new application creation based on a container image, see:
Create an Application from a Docker Image

Post-Creation Operations

These operations are explained in detail in
Create an Application from a Docker Image

1. Disable automatic deployment and drop what has already been deployed, to allow for reconfiguration:

oc rollout pause dc nexus3
oc delete rc <rc-name>

2. Change the deployment strategy.

oc patch dc nexus3 --patch='{ "spec": { "strategy": { "type": "Recreate" }}}'

3. Attach a valid persistence volume.

For this to work, a 2Gi or more persistent volume must be already provisioned and available.

Create the persistent volume claim:

echo "apiVersion: v1
kind: PersistentVolumeClaim
 name: production-nexus-pvc
 - ReadWriteOnce
     storage: 2Gi" | oc create -f -

If an appropriate persistent volume exists, it will be immediately bound after the persistent volume claim creation.

Modify the deployment configuration to use the persistent volume claim:

oc set volumes dc/nexus3 --remove --name=nexus3-volume-1
oc set volumes dc/nexus3 --add --name=nexus-data --mount-path=/nexus-data/ --type persistentVolumeClaim --claim-name=production-nexus-pvc

4. Setup resources.

oc set resources dc/nexus3 --limits=memory=2Gi --requests=memory=1Gi

5. Setup the readiness and liveness probes

oc set probe dc/nexus3 --readiness \
--failure-threshold 3 --initial-delay-seconds 120 \
oc set probe dc/nexus3 --liveness \
--failure-threshold 3 --initial-delay-seconds 120 \
-- echo ok

6. Expose the service.

oc expose service nexus3

7. Resume rollout.

oc rollout resume dc nexus3

Smoke Test the Deployment

Wait for the pod to be brought on-line, go to The repository should be on-line.


Administrator Password

Connect as admin/admin123 and change the default password. The changes will be persisted in storage.


Production Configuration

Sonatype Nexus 3 Configuration

Interaction with OpenShift


'MAVEN_MIRROR_URL' is an environment variable interpreted by the OpenShift s2i builders, which use the Maven repository whose URL is specified as a source of artifacts.

OpenShift image builders check for the environment variable MAVEN_MIRROR_URL, which should point to:

Configure Maven from Maven Build Pods to Use Nexus as Mirror

In all Maven build pods, invoke maven with an alternate settings file that specifies Nexus as a Maven mirror.

mvn -s ./openshift/nexus-settings.xml

Maven command can also be defined as:

def mavenCommand="mvn -s openshift/nexus-settings.xml"

where nexus-settings.xml should be similar to:

            <!--Enable snapshots for the built in central repo to direct -->
            <!--all requests to nexus via the mirror -->