Deprecation Warning:
- Nexus helm chart referred in this KB is deprecated and newer HA helm chart is provided by Sonatype, even for standalone deployments.
- Refer to below KB for more details : https://support.sonatype.com/hc/en-us/articles/35673180613651-How-to-install-Nexus-Pro-standalone-instance-using-Sonatype-nxrm-ha-helm-chart
- There is no direct upgrade option available from old helm chart to newer HA helm chart, refer to below doc link for more details.
https://help.sonatype.com/en/migrating-from-the-legacy-orientdb-helm-chart.html#migrating-to-the-high-availability-helm-chart--optional-
Overview:
Nexus Repository Manager can be deployed in kubernetes cluster using various methods
1. Using YAML files
2. Using Helm Charts
3. Using Openshift Operator.
This article explains installing Nexus instance with pro license using Sonatype helm3 charts.
Note: Sonatype does not support nexus instances with embedded DB in container Environment and strongly recommend to use external database.
PreRequisites:
- Kubernetes 1.19+
- kubectl
- Helm 3
- External Postgresql DB for nexus instance
- A Nexus Repository Pro license (base64 encoded)
Base64 encoded data of Nexus Pro license file named in this example as nx-license.lic.
$ base64 nx-license.lic
cylwwtYx6Fjh7o4k34Ih3KM.....
- Preferably Separate namespace for Nexus deployment. This example uses namespace name, nexus
$ kubectl create namespace nexus
namespace/nexus created
- If minikube is used, please ensure ingress addons are enabled by following installation (step 2) and minikube IP configured (step 3).
- For minikube using Docker driver on Mac M1, please follow https://github.com/kubernetes/minikube/issues/13510#issuecomment-1130152467 to configure the ingress hostname.
Deploying Nexus Repository
- Install Sonatype Helm3 charts
$ helm repo add sonatype https://sonatype.github.io/helm3-charts/
"sonatype" has been added to your repositories
- Create a local myvalues.yaml file overriding with nexus license details. Please note down correct indentation in the example yaml file below.
Note: Below config uses external DB values, hostname postgresql-host, database named nexusdb, DB user nexus with password nexus123. Modify them with your local values as appropriate. Attached myvalues.yaml file, can be used as reference.
nexus:
env:
# minimum recommended memory settings for a small, person instance from
# https://help.sonatype.com/repomanager3/product-information/system-requirements
- name: INSTALL4J_ADD_VM_PARAMS
value: |-
-Xms2703M -Xmx2703M
-XX:+UnlockExperimentalVMOptions -XX:ActiveProcessorCount=4
-XX:+UseCGroupMemoryLimitForHeap
-Djava.util.prefs.userRoot=/nexus-data/javaprefs
-Dnexus.licenseFile=/etc/nexus-license/license.lic
-Dnexus.datastore.enabled=true
-Dnexus.datastore.nexus.jdbcUrl=jdbc:postgresql://postgresql-host:5432/nexusdb
-Dnexus.datastore.nexus.username=nexus
-Dnexus.datastore.nexus.password=nexus123
- name: NEXUS_SECURITY_RANDOMPASSWORD
value: "true"
# # To use an additional secret, set enable to true and add data
ingress:
enabled: true
ingressClassName: nginx
annotations:
nginx.ingress.kubernetes.io/proxy-body-size: "0"
hostPath: /
hostRepo: nx340.minikube.mydomain
secret:
enabled: true
mountPath: /etc/nexus-license/
readOnly: true
data:
license.lic : 'cylwwtYx6Fjh7o4k34Ih3KMhWlu1TvWP...'
- Deploy nexus instance using helm
$ helm install nx340 -n nexus -f myvalues.yaml sonatype/nexus-repository-manager
coalesce.go:223: warning: destination for nexus-repository-manager.secret.data is a table. Ignoring non-table value ([])
NAME: nx340
LAST DEPLOYED: Tue Jul 12 13:05:40 2022
NAMESPACE: nexus
STATUS: deployed
REVISION: 1
NOTES:
1. Your ingresses are available here:
http://nx340.minikube.mydomain/
- Obtain the admin user password from the deployed nexus pod.
$ kubectl get pods -n nexus
NAME READY STATUS RESTARTS AGE
nx340-nexus-repository-manager-55bd6d98b6-xlzv5 1/1 Running 0 5m27s
$ kubectl exec -it -n nexus nx340-nexus-repository-manager-55bd6d98b6-xlzv5 -- cat /nexus-data/admin.password
722639fa-d45a-465e-853f-e0e9faf60eb6
- Access Nexus UI using the configured Ingress URL and login as admin using password obtained in previous step. Complete the nexus setup.
Upgrading Nexus deployment
Below example upgrades nexus 3.39.0 version deployed on nx3 namespace to latest nexus 3.40.1.
NOTE: Please follow all the steps explained in our document link prior to upgrading nexus deployment, including backing up nexus database.
- Check current nexus deployment version
$ helm list -n nx3
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
nexus3 nx3 1 2022-07-14 14:56:26.283526 +1000 AEST deployed nexus-repository-manager-39.0.0 3.39.0
- Check current helm chart version (Below example helm repo has chart version 39.0.1)
$ helm search repo sonatype/nexus-repository-manager --versions
NAME CHART VERSION APP VERSION DESCRIPTION
sonatype/nexus-repository-manager 39.0.1 3.39.0 Sonatype Nexus Repository Manager - Universal B...
sonatype/nexus-repository-manager 39.0.0 3.39.0 Sonatype Nexus Repository Manager - Universal B...
- Update helm repo to get latest versions
$ helm repo update sonatype
Hang tight while we grab the latest from your chart repositories...
...Successfully got an update from the "sonatype" chart repository
Update Complete. ⎈Happy Helming!⎈
- Confirm new chart version is updated
$ helm search repo sonatype/nexus-repository-manager --versions
NAME CHART VERSION APP VERSION DESCRIPTION
sonatype/nexus-repository-manager 40.1.0 3.40.1 Sonatype Nexus Repository Manager - Universal B...
sonatype/nexus-repository-manager 40.0.0 3.40.0 Sonatype Nexus Repository Manager - Universal B...
sonatype/nexus-repository-manager 39.0.1 3.39.0 Sonatype Nexus Repository Manager - Universal B...
sonatype/nexus-repository-manager 39.0.0 3.39.0 Sonatype Nexus Repository Manager - Universal B...
- Upgrade current deployment to latest version
$ helm upgrade nexus3 -n nx3 sonatype/nexus-repository-manager
coalesce.go:223: warning: destination for nexus-repository-manager.secret.data is a table. Ignoring non-table value ([])
Release "nexus3" has been upgraded. Happy Helming!
NAME: nexus3
LAST DEPLOYED: Thu Jul 14 15:06:49 2022
NAMESPACE: nx3
STATUS: deployed
REVISION: 2
NOTES:
1. Your ingresses are available here:
http://nexus3.minikube.mydomain/
- Confirm nexus deployment is updated
$ helm list -n nx3
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
nexus3 nx3 2 2022-07-14 15:06:49.402834 +1000 AEST deployed nexus-repository-manager-40.1.0 3.40.1
- Login to Nexus UI and confirm that new version is upgraded
Uninstalling Nexus deployment
- List current helm deployment
$ helm list -n nexus
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
nx340 nexus 1 2022-07-12 13:05:40.422695 +1000 AEST deployed nexus-repository-manager-40.1.0 3.40.1
- Uninstall the helm release.
Please note, this would remove the persistent volume as well, thus result in data loss.
$ helm uninstall nx340 -n nexus
release "nx340" uninstalled