成功最有效的方法就是向有经验的人学习!

K8S 安装 nexus 私服

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: nexus-ingress
  namespace: devops
  annotations:
    kubernetes.io/ingress.class: "nginx"
spec:
  rules:
  - host: nexus.zm.com
    http:
      paths:
      - path: /
        backend:
          serviceName: nexus
          servicePort: 8081
---
apiVersion: v1
kind: Service
metadata:
  name: nexus
  namespace: devops
  labels:
    app: nexus
spec:
  ports:
  - name: nexus
    port: 8081
    targetPort: 8081
    protocol: TCP
  selector:
    app: nexus
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nexus
  namespace: devops
  labels:
    app: nexus
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nexus
  template:
    metadata:
      labels:
        app: nexus
    spec:
      securityContext:
        runAsUser: 0
      nodeSelector:
        kubernetes.io/hostname: k12-k8s-node-03
      containers:
      - name: nexus
        image: sonatype/nexus3
        imagePullPolicy: IfNotPresent
        ports:
        - name: server
          containerPort: 8081
        livenessProbe:          #存活探针
          httpGet:
            path: /
            port: 8081
          initialDelaySeconds: 30
          periodSeconds: 30
          failureThreshold: 6
        readinessProbe:         #就绪探针
          httpGet:
            path: /
            port: 8081
          initialDelaySeconds: 30
          periodSeconds: 30
          failureThreshold: 6
        env:
        - name: INSTALL4J_ADD_VM_PARAMS  #设置分配资源大小,一定要等于或小于resources设置的值
          value: "
                  -Xms1200M 
                  -Xmx1200M 
                  -XX:MaxDirectMemorySize=2G 
                  -XX:+UnlockExperimentalVMOptions 
                  -XX:+UseCGroupMemoryLimitForHeap
                 "
        resources:
          limits:
            cpu: 1000m  #推荐设置为4000m以上cpu,由于资源有限,所以都是设置的最小值
            memory: 2048Mi   
          requests:
            cpu: 500m
            memory: 1024Mi
        volumeMounts:
        - name: nexus-data
          mountPath: /nexus-data
      volumes:
      - name: nexus-data
        hostPath:
          path: /data/nexus

数据存储直接使用的 hostPath,并通过 nodeSelector固定节点,实际使用时修改

赞(0) 打赏
未经允许不得转载:竹影清风阁 » K8S 安装 nexus 私服
分享到

大佬们的评论 抢沙发

全新“一站式”建站,高质量、高售后的一条龙服务

微信 抖音 支付宝 百度 头条 快手全平台打通信息流

橙子建站.极速智能建站8折购买虚拟主机

觉得文章有用就打赏一下文章作者

非常感谢你的打赏,我们将继续给力更多优质内容,让我们一起创建更加美好的网络世界!

支付宝扫一扫

微信扫一扫

登录

找回密码

注册