kubernetes容器镜像仓库之nexus

kubernetes的容器镜像仓库有几种,cncf官网上有这几种容器镜像仓库的项目,虽然这里面没有nexus在这里插入图片描述
但是我们可以从nexus提供丰富的仓库列表里面看到,docker镜像赫然在列。而且还提供helm chart的存储,基本上nexus在通用性上是无敌了。
在这里插入图片描述

首先我们来创建nexus,这里我们直接使用hostpath进行存储,再添加节点亲和性进行存储目录的固定。
svc端口则与我们后面要建立docker仓库的端口相对应。

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nexus
  namespace: default
  labels:
    app: nexus
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nexus
  template:
    metadata:
      labels:
        app: nexus
    spec:
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
            - matchExpressions:
              - key: ip
                operator: In
                values:
                - 172.16.12.100
      containers:
      - name: nexus
        image: registry.cn-shenzhen.aliyuncs.com/liweilun/nexus:latest
#        image: sonatype/nexus3
        imagePullPolicy: IfNotPresent
#        imagePullPolicy: Always
        volumeMounts:
        - mountPath: /nexus-data
          name: nexusdata
      volumes:
      - name: nexusdata
        hostPath:
          path: /opt/nexus
          type: Directory
      dnsPolicy: ClusterFirst
      restartPolicy: Always
 ---
apiVersion: v1
kind: Service
metadata:
  name: nexus
  labels:
    app: nexus
spec:
#  type: NodePort
  ports:
  - name: nexus
    port: 8081
    targetPort: 8081
  - name: dockergroup
    port: 2000
    targetPort: 2000
  - name: dockerproxy
    port: 2001
    targetPort: 2001
  - name: dockerhost
    port: 2002
    targetPort: 2002
#    nodePort: 32000
  - name: dockerhost2
    port: 2003
    targetPort: 2003
#    nodePort: 32000
  selector:
    app: nexus

首先我们创建一个dockerhost仓库。我们利用ingress进行ssl卸载,然后禁止匿名用户pull,禁用docker v1 api,然后允许deploy
在这里插入图片描述
然后我们再来创建一个dockerproxy仓库。dockerproxy仓库主要利用阿里云等加速地址,缓存docker镜像,避免再次拉取。remote storage填写加速地址,docker index选择 use docker hub,foreign layer caching就是是否运行缓存docker镜像,填入*星号就是缓存所有地址的dockerhub镜像
在这里插入图片描述

最后再介绍下docker仓库有两种定时任务,一种是删除未完成上传的blob,另一种是删除未使用的mainfests和images。后一种主要针对频繁更新同一个tag的docker镜像在这里插入图片描述
定时任务可以设置手动、一次、每小时、每天、每周、每月或者cron定时执行
在这里插入图片描述

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值