加载中...

Nexus本地mavan仓库搭建


一 简介

Nexus 是Maven仓库管理器,如果你使用Maven,你可以从Maven中央仓库 下载所需要的构件(artifact),但这通常不是一个好的做法,你应该在本地架设一个Maven仓库服务器,在代理远程仓库的同时维护本地仓库,以节省带宽和时间,Nexus就可以满足这样的需要。此外,他还提供了强大的仓库管理功能,构件搜索功能,它基于REST,友好的UI是一个extjs的REST客户端,它占用较少的内存,基于简单文件系统而非数据库。这些优点使其日趋成为最流行的Maven仓库管理器


二 安装配置

2.1 环境准备

需要有默认存储 我这边使用的是sc

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: nexus-data-pvc
  namespace: nexus
  annotations:
    kubesphere.io/creator: admin
    pv.kubernetes.io/bind-completed: 'yes'
    pv.kubernetes.io/bound-by-controller: 'yes'
    volume.beta.kubernetes.io/storage-provisioner: nfs-provisioner-k8s
  finalizers:
    - kubernetes.io/pvc-protection
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 10Gi
  volumeName: pvc-8ac315a8-fdac-460d-9c95-41d0a7bc7e7e
  storageClassName: nfs-k8s
  volumeMode: Filesystem

2.2 配置deploy

kind: Deployment
apiVersion: apps/v1
metadata:
  name: nexus
  namespace: nexus
  labels:
    k8s-app: nexus
  annotations:
    deployment.kubernetes.io/revision: '5'
    kubesphere.io/creator: admin
spec:
  replicas: 1
  selector:
    matchLabels:
      k8s-app: nexus
  template:
    metadata:
      name: nexus
      namespace: nexus
      creationTimestamp: null
      labels:
        k8s-app: nexus
      annotations:
    spec:
      volumes:
        - name: nexus-data
          persistentVolumeClaim:
            claimName: nexus-data-pvc
      initContainers:
        - name: adddirperm
          image: harbor.huhuhahei.cn/huhuhahei/busybox
          command:
            - /bin/sh
            - '-c'
            - 'chown -R ${USER_ID}:${USER_ID} ${DATA_DIR}'
          env:
            - name: DATA_DIR
              value: /nexus-data
            - name: USER_ID
              value: '200'
          resources: {}
          volumeMounts:
            - name: nexus-data
              mountPath: /nexus-data
          terminationMessagePath: /dev/termination-log
          terminationMessagePolicy: File
          imagePullPolicy: Always
      containers:
        - name: nexus
          image: harbor.huhuhahei.cn/huhuhahei/nexus3:3.20.1
          ports:
            - name: web
              containerPort: 8081
              protocol: TCP
          resources:
            requests:
              cpu: 500m
              memory: 512Mi
          volumeMounts:
            - name: nexus-data
              mountPath: /nexus-data
          terminationMessagePath: /dev/termination-log
          terminationMessagePolicy: File
          imagePullPolicy: IfNotPresent
      restartPolicy: Always
      terminationGracePeriodSeconds: 30
      dnsPolicy: ClusterFirst
      securityContext: {}
      schedulerName: default-scheduler
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 25%
      maxSurge: 25%
  revisionHistoryLimit: 10
  progressDeadlineSeconds: 600

2.3 配置svc

kind: Service
apiVersion: v1
metadata:
  name: nexus
  namespace: nexus
  labels:
    app: nexus
spec:
  ports:
    - name: http-neuxs
      protocol: TCP
      port: 8081
      targetPort: 8081
  selector:
    k8s-app: nexus
  type: NodePort
  sessionAffinity: None
  externalTrafficPolicy: Cluster

三 访问测试


文章作者: huhuhahei
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 huhuhahei !
评论
  目录