本地数据盘模式
把数据保存在node2和pod容器跑在node2
mkdir -p /var/nexus-datachown -R 200 /var/nexus-data
apiVersion: v1kind: PersistentVolumemetadata:name: nexus-dataspec:capacity:storage: 5GivolumeMode: FilesystemaccessModes:- ReadWriteOncepersistentVolumeReclaimPolicy: RetainstorageClassName: local-storagelocal:path: /var/nexus-datanodeAffinity:required:nodeSelectorTerms:- matchExpressions:- key: kubernetes.io/hostnameoperator: Invalues:- node2---apiVersion: v1kind: PersistentVolumeClaimmetadata:name: nexus-data-pvcspec:accessModes:- ReadWriteOncevolumeMode: Filesystemresources:requests:storage: 5GistorageClassName: local-storage---apiVersion: apps/v1kind: Deploymentmetadata:name: nexus-deploymentspec:replicas: 1selector:matchLabels:app: nexustemplate:metadata:labels:app: nexusspec:nodeSelector:kubernetes.io/hostname: "node2"containers:- name: nexusimage: sonatype/nexus3ports:- containerPort: 8081- containerPort: 8082- containerPort: 8083volumeMounts:- mountPath: /nexus-dataname: nexus-datavolumes:- name: nexus-datapersistentVolumeClaim:claimName: nexus-data-pvc---apiVersion: v1kind: Servicemetadata:name: nexus-svcspec:selector:app: nexustype: NodePortports:- name: webprotocol: TCPport: 8081targetPort: 8081nodePort: 30081- name: dockerprotocol: TCPport: 8082targetPort: 8082nodePort: 30082- name: mavenprotocol: TCPport: 8083targetPort: 8083nodePort: 30083
[root@master ~]# kubectl get all |grep nexus*pod/nexus-deployment-787578c7f6-w747l 1/1 Running 0 153mservice/nexus-svc NodePort 10.233.25.187 <none> 8081:30081/TCP,8082:30082/TCP,8083:30083/TCP 6h54mdeployment.apps/nexus-deployment 1/1 1 1 6h54mreplicaset.apps/nexus-deployment-787578c7f6 1 1 1 156m[root@master ~]#
apiVersion: extensions/v1beta1kind: Ingressmetadata:name: nexusannotations:kubernetes.io/ingress.class: "nginx"spec:rules:- host: nexus.riyimei.cnhttp:paths:- path: /pathType: ImplementationSpecificbackend:serviceName: nexus-svcservicePort: 8081- path: /pathType: ImplementationSpecificbackend:serviceName: nexus-svcservicePort: 8082- path: /pathType: ImplementationSpecificbackend:serviceName: nexus-svcservicePort: 8083
Ingress 暴露服务
apiVersion: v1kind: PersistentVolumemetadata:name: nexus-dataspec:capacity:storage: 5GivolumeMode: FilesystemaccessModes:- ReadWriteOncepersistentVolumeReclaimPolicy: RetainstorageClassName: local-storagelocal:path: /var/nexus-datanodeAffinity:required:nodeSelectorTerms:- matchExpressions:- key: kubernetes.io/hostnameoperator: Invalues:- node2#storageClassName: nfs#nfs:#path: /var/nexus-data#server: 192.168.0.250---apiVersion: v1kind: PersistentVolumeClaimmetadata:name: nexus-data-pvcspec:accessModes:- ReadWriteOncevolumeMode: Filesystemresources:requests:storage: 5GistorageClassName: local-storage---apiVersion: apps/v1kind: Deploymentmetadata:name: nexus-deploymentspec:replicas: 1selector:matchLabels:app: nexustemplate:metadata:labels:app: nexusspec:nodeSelector:kubernetes.io/hostname: "node2"containers:- name: nexusimage: sonatype/nexus3ports:- containerPort: 8081- containerPort: 8082- containerPort: 8083volumeMounts:- mountPath: /nexus-dataname: nexus-datavolumes:- name: nexus-datapersistentVolumeClaim:claimName: nexus-data-pvc---apiVersion: v1kind: Servicemetadata:name: nexus-svcspec:selector:app: nexustype: ClusterIPports:- name: webprotocol: TCPport: 8081- name: dockerprotocol: TCPport: 8082- name: mavenprotocol: TCPport: 8083---apiVersion: extensions/v1beta1kind: Ingressmetadata:name: nexusannotations:kubernetes.io/ingress.class: "nginx"spec:rules:- host: nexus.riyimei.cnhttp:paths:- path: /pathType: ImplementationSpecificbackend:serviceName: nexus-svcservicePort: 8081- path: /pathType: ImplementationSpecificbackend:serviceName: nexus-svcservicePort: 8082- path: /pathType: ImplementationSpecificbackend:serviceName: nexus-svcservicePort: 8083
[root@master ~]# kubectl get all |grep nexus*pod/nexus-deployment-787578c7f6-w747l 1/1 Running 0 172mservice/nexus-svc ClusterIP 10.233.25.187 <none> 8081/TCP,8082/TCP,8083/TCP 7h14mdeployment.apps/nexus-deployment 1/1 1 1 7h14mreplicaset.apps/nexus-deployment-787578c7f6 1 1 1 176m[root@master ~]# kubectl get ingress |grep nexus*Warning: extensions/v1beta1 Ingress is deprecated in v1.14+, unavailable in v1.22+; use networking.k8s.io/v1 Ingressnexus <none> nexus.riyimei.cn 192.168.11.151,192.168.11.152 80 15m[root@master ~]# kubectl get pvc |grep nexus*nexus-data-pvc Bound nexus-data 5Gi RWO local-storage 7h15m[root@master ~]# kubectl get pv |grep nexus*nexus-data 5Gi RWO Retain Bound default/nexus-data-pvc local-storage 7h15m[root@master ~]#
nfs共享模式
apiVersion: v1kind: PersistentVolumemetadata:name: nexus-dataspec:capacity:storage: 5GivolumeMode: FilesystemaccessModes:- ReadWriteOncepersistentVolumeReclaimPolicy: RetainstorageClassName: nfsnfs:path: /var/nfs/nexus-dataserver: 192.168.0.250---apiVersion: v1kind: PersistentVolumeClaimmetadata:name: nexus-data-pvcspec:accessModes:- ReadWriteOncevolumeMode: Filesystemresources:requests:storage: 5GistorageClassName: nfs---apiVersion: apps/v1kind: Deploymentmetadata:name: nexus-deploymentspec:replicas: 1selector:matchLabels:app: nexustemplate:metadata:labels:app: nexusspec:containers:- name: nexusimage: sonatype/nexus3ports:- containerPort: 8081- containerPort: 8082- containerPort: 8083volumeMounts:- mountPath: /nexus-dataname: nexus-datavolumes:- name: nexus-datapersistentVolumeClaim:claimName: nexus-data-pvc---apiVersion: v1kind: Servicemetadata:name: nexus-svcspec:selector:app: nexustype: NodePortports:- name: webprotocol: TCPport: 8081targetPort: 8081nodePort: 30081- name: dockerprotocol: TCPport: 8082targetPort: 8082nodePort: 30082- name: mavenprotocol: TCPport: 8083targetPort: 8083nodePort: 30083
软件初始化密码
[root@node2 ~]#
[root@node2 ~]# cd /var/nexus-data/
[root@node2 nexus-data]# ls -l
total 28
-rw-r--r-- 1 200 200 36 Jul 31 16:23 admin.password
drwxr-xr-x 3 200 200 21 Jul 31 16:23 blobs
drwxr-xr-x 331 200 200 8192 Jul 31 16:22 cache
drwxr-xr-x 6 200 200 113 Jul 31 16:23 db
drwxr-xr-x 3 200 200 19 Jul 31 16:23 elasticsearch
drwxr-xr-x 3 200 200 45 Jul 31 16:03 etc
drwxr-xr-x 2 200 200 6 Jul 31 16:02 generated-bundles
drwxr-xr-x 2 200 200 33 Jul 31 16:02 instances
drwxr-xr-x 3 200 200 19 Jul 31 16:02 javaprefs
-rw-r--r-- 1 200 200 1 Jul 31 16:22 karaf.pid
drwxr-xr-x 3 200 200 18 Jul 31 16:03 keystores
-rw-r--r-- 1 200 200 35 Jul 31 16:22 lock
drwxr-xr-x 3 200 200 112 Jul 31 16:23 log
drwxr-xr-x 2 200 200 6 Jul 31 16:03 orient
-rw-r--r-- 1 200 200 5 Jul 31 16:22 port
drwxr-xr-x 2 200 200 6 Jul 31 16:03 restore-from-backup
drwxr-xr-x 8 200 200 281 Jul 31 16:23 tmp
[root@node2 nexus-data]# cat admin.password
3218527c-1c47-497c-867c-8b72188b01d0[root@node2 nexus-data]# pwd
/var/nexus-data
[root@node2 nexus-data]#


