K8S部署nexus

罗小黑
2023-01-13 / 0 评论 / 40 阅读 / 正在检测是否收录...
广告
温馨提示:
本文最后更新于2023年01月13日,已超过19天没有更新,若内容或图片失效,请留言反馈。

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: nexus-pvc # 自定义
  namespace: nexus # 自定义,与本文前后所有命名空间保持一致
  labels:
    pvc: nexus-pvc # 自定义
spec:
  storageClassName: nfs-client # 创建的StorageClass的名字
  accessModes:
  - ReadWriteOnce
  resources:
    requests:
      storage: 20Gi
---
kind: Deployment
apiVersion: apps/v1
metadata:
  name: nexus3 # 自定义
  labels:
    app: nexus3 # 自定义
  namespace: nexus # 自定义,与本文前后所有命名空间保持一致
spec:
  replicas: 1 # 副本的数量
  selector:
    matchLabels:
      app: nexus3
  template:
    metadata:
      labels:
        app: nexus3
    spec:
      containers:
        - name: nexus3
          image: sonatype/nexus3:3.42.0
          ports:
            - name: nexus3-8081
              containerPort: 8081 # 容器端口
              protocol: TCP
          resources:
            limits:
              memory: 6G
              cpu: 1000m
          imagePullPolicy: IfNotPresent
          volumeMounts:
          - name: data
            mountPath: /nexus-data # 数据路径挂载出来
      restartPolicy: Always
      volumes:
        - name: data
          persistentVolumeClaim:
            claimName: nexus-pvc # PVC的名字
            readOnly: false
      #volumes:
      #  - name: nexus-data
      #    nfs:
      #      path: /data/nfs/graph/nexus-data
      #      server: 192.168.58.106

---
kind: Service
apiVersion: v1
metadata:
  name: nexus3
  namespace: nexus
  labels:
    app: nexus3
spec:
  type: NodePort
  ports:
    - port: 8081
      targetPort: 8081
      nodePort: 30520 # 对外开发的端口,自定义
  selector:
    app: nexus3
0

打赏


评论 (0)

取消