k8s 摆设 nexus3 详解

[复制链接]
发表于 2026-1-5 23:51:55 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
创建定名空间

nexus3-namespace.yaml
  1. apiVersion: v1
  2. kind: Namespace
  3. metadata:
  4.   name: nexus-ns
复制代码
创建pv&pvc

nexus3-pv-pvc.yaml
  1. apiVersion: v1
  2. kind: PersistentVolume
  3. metadata:
  4.   name: nfs-pv
  5.   namespace: nexus-ns
  6. spec:
  7.   capacity:
  8.     storage: 3Gi
  9.   accessModes:
  10.     - ReadWriteMany
  11.   nfs:
  12.     server: 10.0.2.11
  13.     path: "/root/share"
  14. ---
  15. apiVersion: v1
  16. kind: PersistentVolumeClaim
  17. metadata:
  18.   name: nexus-data-pvc
  19.   namespace: nexus-ns
  20. spec:
  21.   accessModes:
  22.     - ReadWriteMany
  23.   #storageClassName: "standard"
  24.   resources:
  25.     requests:
  26.       storage: 2Gi
复制代码
创建Deployment

nexus3-deployment.yml
  1. apiVersion: apps/v1
  2. kind: Deployment
  3. metadata:
  4.   namespace: nexus-ns
  5.   name: nexus3
  6.   labels:
  7.     app: nexus3
  8. spec:
  9.   replicas: 1
  10.   selector:
  11.     matchLabels:
  12.       app: nexus3
  13.   template:
  14.     metadata:
  15.       labels:
  16.         app: nexus3
  17.     spec:
  18.       containers:
  19.       - name: nexus3
  20.         image: swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/sonatype/nexus3:3.72.0
  21.         imagePullPolicy: IfNotPresent
  22.         ports:
  23.           - containerPort: 8081
  24.             name: web
  25.             protocol: TCP
  26.         livenessProbe:
  27.           httpGet:
  28.             path: /
  29.             port: 8081
  30.           initialDelaySeconds: 100
  31.           periodSeconds: 30
  32.           failureThreshold: 6
  33.         readinessProbe:
  34.           httpGet:
  35.             path: /
  36.             port: 8081
  37.           initialDelaySeconds: 100
  38.           periodSeconds: 30
  39.           failureThreshold: 6
  40.         resources:
  41.           limits:
  42.             cpu: 1000m
  43.             memory: 2Gi
  44.           requests:
  45.             cpu: 500m
  46.             memory: 2Gi
  47.         volumeMounts:
  48.         - name: nexus-data
  49.           mountPath: /nexus-data
  50.       volumes:
  51.         - name: nexus-data
  52.           persistentVolumeClaim:
  53.             claimName: nexus-data-pvc
复制代码
创建Service

nexus3-service.yml
  1. apiVersion: v1
  2. kind: Service
  3. metadata:
  4.   name: nexus3
  5.   namespace: nexus-ns
  6.   labels:
  7.     app: nexus3
  8. spec:
  9.   selector:
  10.     app: nexus3
  11.   type: NodePort
  12.   ports:
  13.     - name: web
  14.       protocol: TCP
  15.       port: 8081
  16.       targetPort: 8081
  17.       nodePort: 31081
复制代码
参考
  1. https://segmentfault.com/a/1190000040446848?utm_source=sf-similar-article
复制代码
回复

使用道具 举报

登录后关闭弹窗

登录参与点评抽奖  加入IT实名职场社区
去登录
快速回复 返回顶部 返回列表