k8s 部署 nexus3 详解

创建命名空间

nexus3-namespace.yaml

复制代码
apiVersion: v1
kind: Namespace
metadata:
  name: nexus-ns

创建pv&pvc

nexus3-pv-pvc.yaml

复制代码
apiVersion: v1
kind: PersistentVolume
metadata:
  name: nfs-pv
  namespace: nexus-ns
spec:
  capacity:
    storage: 3Gi
  accessModes:
    - ReadWriteMany
  nfs:
    server: 10.0.2.11
    path: "/root/share"

---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: nexus-data-pvc
  namespace: nexus-ns
spec:
  accessModes:
    - ReadWriteMany
  #storageClassName: "standard"
  resources:
    requests:
      storage: 2Gi

创建Deployment

nexus3-deployment.yml

复制代码
apiVersion: apps/v1
kind: Deployment
metadata:
  namespace: nexus-ns
  name: nexus3
  labels:
    app: nexus3
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nexus3
  template:
    metadata:
      labels:
        app: nexus3
    spec:
      containers:
      - name: nexus3
        image: swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/sonatype/nexus3:3.72.0
        imagePullPolicy: IfNotPresent
        ports:
          - containerPort: 8081
            name: web
            protocol: TCP
        livenessProbe:
          httpGet:
            path: /
            port: 8081
          initialDelaySeconds: 100
          periodSeconds: 30
          failureThreshold: 6
        readinessProbe:
          httpGet:
            path: /
            port: 8081
          initialDelaySeconds: 100
          periodSeconds: 30
          failureThreshold: 6
        resources:
          limits:
            cpu: 1000m
            memory: 2Gi
          requests:
            cpu: 500m
            memory: 2Gi
        volumeMounts:
        - name: nexus-data
          mountPath: /nexus-data
      volumes:
        - name: nexus-data
          persistentVolumeClaim:
            claimName: nexus-data-pvc

创建Service

nexus3-service.yml

复制代码
apiVersion: v1
kind: Service
metadata:
  name: nexus3
  namespace: nexus-ns
  labels:
    app: nexus3
spec:
  selector:
    app: nexus3
  type: NodePort
  ports:
    - name: web
      protocol: TCP
      port: 8081
      targetPort: 8081
      nodePort: 31081

参考

复制代码
https://segmentfault.com/a/1190000040446848?utm_source=sf-similar-article
相关推荐
gwjcloud2 小时前
Kubernetes从入门到精通(高级篇)04
云原生·容器·kubernetes
阿里云云原生2 小时前
阿里云微服务引擎 MSE 及 API 网关 2026 年 4 月产品动态
微服务·云原生
张文君3 小时前
上古世纪服务端编译安装AAEmu docker编译安装
运维·docker·容器
阿里云云原生4 小时前
从“对话式编程”到“规格驱动”:民生银行企业级AI研发范式重构实践
云原生
苍煜4 小时前
现代生产级微服务+容器治理完整技术栈与架构方案详解(国内主流完整云原生微服务闭环架构)
微服务·云原生·架构
小猿姐4 小时前
GitLab on Kubernetes:使用 KubeBlocks 部署生产级高可用 PostgreSQL 和 Redis
redis·postgresql·kubernetes
Stackflowed5 小时前
Docker安装Oracle
docker·oracle·容器
邵奈一5 小时前
OrbStack 环境下 Dify 启动报错完整解决方案教程:validating docker-compose.yaml
docker·容器·eureka
一只小bit6 小时前
Docker 镜像制作:包含自定义镜像及常用命令
运维·docker·容器