kubernetes部署Maven私有仓库Nexus3
系统环境
- Kubernetes 版本:1.20.0
- Sonatype Nexus 版本:3.25.1-04
Nexus3简介
Nexus 是 Maven 仓库管理器,通过 nexus 可以搭建 Maven仓库,极大的简化了本地内部仓库的维护和外部仓库的访问,同时是一套开箱即用的系统不需要数据库,并且还提供强大的仓库管理、构建、搜索等功能
优点
- 节省外网带宽
- 加速Maven构建
- 可以为本地建立本地内部仓库
- 方便项目组存放各种jar的管理
kubernetes部署Nexus3
nexus.yaml
[root@k8s01 nexus]# vim nexus.yaml
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: nexus-pvc
namespace: tools-env
labels:
app: nexus
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 50Gi
storageClassName: managed-nfs-storage
---
apiVersion: v1
kind: Service
metadata:
name: nexus
namespace: tools-env
labels:
app: nexus
spec:
type: NodePort
ports:
- name: nexus
port: 8081
targetPort: 8081
nodePort: 30881
protocol: TCP
selector:
app: nexus
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: nexus
namespace: tools-env
labels:
app: nexus
spec:
replicas: 1
selector:
matchLabels:
app: nexus
template:
metadata:
labels:
app: nexus
spec:
containers:
- name: nexus
image: sonatype/nexus3:3.25.1
imagePullPolicy: IfNotPresent
ports:
- name: nexus
containerPort: 8081
livenessProbe:
httpGet:
path: /
port: 8081
initialDelaySeconds: 30
periodSeconds: 30
failureThreshold: 6
readinessProbe:
httpGet:
path: /
port: 8081
initialDelaySeconds: 30
periodSeconds: 30
failureThreshold: 6
env:
- name: INSTALL4J_ADD_VM_PARAMS #设置分配资源大小,一定要等于或小于resources设置的值
value: "
-Xms1200M
-Xmx1200M
-XX:MaxDirectMemorySize=2G
-XX:+UnlockExperimentalVMOptions
-XX:+UseCGroupMemoryLimitForHeap
"
resources: #资源限制
limits:
cpu: 1000m #推荐设置为4000m以上cpu
memory: 2048Mi
requests:
cpu: 500m
memory: 1024Mi
volumeMounts:
- name: nexus-data
mountPath: /nexus-data
volumes:
- name: nexus-data
persistentVolumeClaim:
claimName: nexus-pvc
[root@k8s01 nexus]# kubectl apply -f nexus.yaml
persistentvolumeclaim/nexus-pvc created
service/nexus created
deployment.apps/nexus created
获取nexus密码
Nexus3 创建完成后,会创建默认管理员用户"admin",且生成一个随机密码存储在持久化目录 admin.password 文件中,通过以下密码获取
[root@k8s01 ~]# kubectl exec -it -n tools-env nexus-5bc994c5ff-b8pts cat /nexus-data/admin.password
4060b6f5-f608-43a7-8c7f-4fc474fbdb27
访问Nexus
输入IP:30881访问nexus
版权声明:
本站所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自
爱吃可爱多!
喜欢就支持一下吧
打赏
微信
支付宝