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
相关推荐
摸鱼也很难1 小时前
Docker 镜像加速和配置的分享 && 云服务器搭建beef-xss
运维·docker·容器
鸠摩智首席音效师4 小时前
Docker 中如何限制CPU和内存的使用 ?
docker·容器
Michaelwubo5 小时前
Docker dockerfile镜像编码 centos7
运维·docker·容器
好像是个likun5 小时前
使用docker拉取镜像很慢或者总是超时的问题
运维·docker·容器
暴富的Tdy7 小时前
【快速上手Docker 简单配置方法】
docker·容器·eureka
魏 无羡8 小时前
linux CentOS系统上卸载docker
linux·kubernetes·centos
Karoku0668 小时前
【k8s集群应用】kubeadm1.20高可用部署(3master)
运维·docker·云原生·容器·kubernetes
豆豆豆豆变8 小时前
docker之compose篇
docker·容器·自动化运维
凌虚10 小时前
Kubernetes APF(API 优先级和公平调度)简介
后端·程序员·kubernetes
saynaihe10 小时前
安全地使用 Docker 和 Systemctl 部署 Kafka 的综合指南
运维·安全·docker·容器·kafka