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
相关推荐
丶213633 分钟前
【云原生】云原生后端:监控与观察性
后端·云原生·架构
pyliumy41 分钟前
docker的安装配置与基本简单命令
运维·docker·容器
winkee1 小时前
Skopeo 工具介绍
docker·容器·devops
CopyLower1 小时前
ZooKeeper的应用场景:深入探讨分布式系统中的多样化应用
分布式·zookeeper·云原生
test12803 小时前
局域网 docker pull 使用代理拉取镜像
docker·容器·代理·docker pull·http_proxy
天幕繁星3 小时前
docker占用磁盘过多问题
docker·容器
bala55694 小时前
Docker-在Centos中部署Shell脚本获取镜像并构建容器
linux·阿里云·docker·容器·centos·maven
水w8 小时前
docker怎么实现资源隔离的?
运维·开发语言·后端·docker·容器
MetaverseMan9 小时前
k8s 查看 Secrets 的内容和详细信息
云原生·容器·kubernetes
確定饿的猫10 小时前
k8s 二进制部署安装(三)
kubernetes