Nexus(全称为 Sonatype Nexus Repository Manager)是一款开源的制品仓库管理器,是企业 DevOps 与 CI/CD 流水线中的核心组件,用于统一存储、代理和管理各类软件依赖包与构建产物。
我们用这个存储maven的jar包
helm repo add sonatype https://sonatype.github.io/helm3-charts/
helm repo update
values.yaml
---
statefulset:
# This is not supported
enabled: false
deploymentStrategy: Recreate
image:
# Sonatype Official Public Image
repository: sonatype/nexus3
tag: 3.64.0
pullPolicy: IfNotPresent
imagePullSecrets:
nexus:
resources:
requests:
cpu: 2
memory: 4Gi
limits:
cpu: 4
memory: 8Gi
# The ports should only be changed if the nexus image uses a different port
nexusPort: 8081
# hostAliases allows the modification of the hosts file inside a container
hostAliases: []
# - ip: "192.168.1.10"
# hostnames:
# - "example.com"
# - "www.example.com"
ingress:
enabled: true
annotations:
ingressClassName: nginx
nginx.ingress.kubernetes.io/proxy-body-size: "0"
hostRepo: nexus.cyan.com
hostPath: /
persistence:
enabled: true
accessMode: ReadWriteOnce
storageClass: "local-storage"
storageSize: 20Gi
install.sh
helm install nexus sonatype/nexus-repository-manager -f values.yaml -n nexus --create-namespace
maven配置
/Users/cy/.m2/repository
<pluginGroups>
</pluginGroups>
<proxies>
</proxies>
<!-- 1. 私服账号(拉取私有依赖/上传依赖时用) -->
<servers>
<server>
<id>maven-releases</id>
<username>admin</username> <!-- 替换为你的Nexus账号 -->
<password>123456</password>
</server>
<server>
<id>maven-snapshots</id>
<username>admin</username>
<password>123456</password>
</server>
</servers>
<mirrors>
<mirror>
<id>maven-public</id>
<name>Nexus Public Repository</name>
<url>http://10.0.0.2:20010/repository/maven-public/</url>
<mirrorOf>*</mirrorOf>
</mirror>
</mirrors>
<!-- 🔥 关键:添加 profiles 配置 -->
<profiles>
<profile>
<id>nexus</id>
<repositories>
<repository>
<id>public</id>
<url>http://10.0.0.2:20010/repository/maven-public/</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots> <!-- 允许 SNAPSHOT -->
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>public</id>
<url>http://10.0.0.2:20010/repository/maven-public/</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<!-- 激活上面定义的 profile -->
<activeProfiles>
<activeProfile>nexus</activeProfile>
</activeProfiles>