Quick Start
This document will help you quickly understand how to create a Nexus connector to connect to a Nexus repository and perform mvn operations securely without directly handling credentials.
We will create a Nexus connector and use it to perform mvn deploy without directly handling credentials on the client side.
TOC
Estimated Reading TimePrerequisitesProcess OverviewSteps to OperateStep 1: Create NamespaceStep 2: Create Nexus Repository Credentials and ConnectorStep 3: Create a Job to Performmvn deployKey SettingsStep 4: Verify OperationWhat Happens Under the HoodKey NotesTroubleshootingFurther ReadingReferencesEstimated Reading Time
15 minutes
Prerequisites
- Kubernetes cluster with Connectors system installed (Operator, ConnectorsCore and ConnectorsNexus components). See the Installation Guide for details on installing these components.
- Nexus repository address and credentials
- Basic knowledge of Kubernetes and Maven
Process Overview
Steps to Operate
Step 1: Create Namespace
Create a dedicated namespace for this demonstration:
Step 2: Create Nexus Repository Credentials and Connector
Create both the Secret containing Nexus credentials and the Nexus connector resource. Your Nexus repository should be a snapshots repository.
For more detailed information about creating and configuring connectors, please refer to the Connectors Quick Start Guide.
Verify that the connector is in "Ready" status:
The output should show:
Step 3: Create a Job to Perform mvn deploy
Create a job that uses the connector to perform Maven operations:
Key Settings
MAVEN_OPTS in container environment:
Set to MAVEN_OPTS=-Dmaven.resolver.transport=wagon
Scripts in container:
Using the keytool command to import the ca.cert file to your client's truststore for trusting the connector proxy server before executing mvn operations.
volumes[].volumeAttributes
connector.name: The name of your Nexus connectorconfiguration.names: Set tosettings, which references the Maven configuration template defined in the Nexus ConnectorClass. This template generates asettings.xmlfile with the appropriate proxy and authentication settings.configuration.params: JSON string for runtime configuration parameters. Forconfiguration.names: "settings", you can setsettings.mirrorRepository(optional). If omitted, the ConnectorClass default ("") is used and no Maven mirror is injected intosettings.xml.
Step 4: Verify Operation
Check the job's logs to confirm the mvn deploy operations were successfully performed:
You should see the mvn deploy operations completing successfully and uploading the jar to the Nexus repository.
Example output:
What Happens Under the Hood
The Nexus connector works by:
- Creating a proxy service that sits between your client and the target Nexus repository
- Injecting authentication information when requests pass through the proxy
- Providing configuration files (e.g.,
settings.xml,.npmrc,pip.conf) for clients to perform operations via the proxy
To demonstrate this mechanism, inspect the generated settings.xml file:
View the generated files in /opt/maven/:
View the generated settings.xml file:
Example output:
Key Notes
- Two files are mounted into the Pod via Connectors CSI Driver:
settings.xmlandca.cert. - The
settings.xmlfile contains the proxy configuration section, which provides the ability to connect to the Nexus Maven repository via the proxy. The proxy injects authentication information when requests pass through. - The
settings.xmlfile contains no original secret and is mounted into the Pod via Connectors CSI Driver.
Troubleshooting
If your operation fails, check the following:
-
Connector Status: Ensure the connector is in "Ready" state:
-
Verify the connectors deployment status: ensure all components are deployed and in "Ready" state
Further Reading
After successfully performing operations using the Nexus connector, you can:
- Learn more about Concepts of Nexus Connectors