Kubernetes Nexus3

Posted by Vito on February 3, 2024

PVC

1
2
3
4
5
6
7
8
9
10
11
12
13
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: nexus3
  namespace: devops
spec:
  accessModes:
    - ReadWriteMany 
  volumeMode: Filesystem 
  resources:
    requests:
      storage: 2Gi
  #storageClassName: "managed-nfs-storage"

Install

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nexus3
  namespace: devops
  labels:
    app: nexus3
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nexus3
  template:
    metadata:
      labels:
        app: nexus3
    spec:
      affinity:
        podAntiAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
          - weight: 100
            podAffinityTerm:
              labelSelector:
                matchExpressions:
                - key: app
                  operator: In
                  values:
                  - nexus3
              topologyKey: kubernetes.io/hostname
      containers:
      - name: nexus3
        image: sonatype/nexus3:3.63.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: 
          requests: 
            memory: 512Mi
            cpu: 10m
          limits: 
            memory: 2048Mi
            cpu: 4000m
        volumeMounts:
        - name: nexus3
          mountPath: /nexus-data
      volumes:
        - name: nexus3
          persistentVolumeClaim:
            claimName: nexus3
---
apiVersion: v1
kind: Service 
metadata:
  name: nexus3
  namespace: devops
spec:
  selector: 
    app: nexus3
  type: ClusterIP
  ports:
  - port: 8081 
    targetPort: web
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: nexus3
  namespace: devops
spec: 
  ingressClassName: nginx
  tls:
  - hosts:
    - maven.zhch.lan
    secretName: zhch.lan
  rules:
  - host: maven.zhch.lan
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: nexus3
            port:
              number: 8081

登录

  • https://maven.zhch.lan/
    • 用户名 admin
    • 初始密码在文件 /nexus-data/admin.password中,可以进入容器中查看,或者进入挂载的 nfs 目录中查看

使用方法