首页 > 其他分享 >k8s 1.28.2 集群部署 docker registry 接入 MinIO 存储

k8s 1.28.2 集群部署 docker registry 接入 MinIO 存储

时间:2024-11-14 19:08:03浏览次数:1  
标签:http MinIO kubernetes 1.28 registry io docker name

目录


docker registry dockerfile

docker registry 配置文件

S3 storage driver

registry:2.8.3 Image hierarchy

docker registry 部署

生成 htpasswd 文件

<username> <password> 改成自己想配置的,如果密码有特殊字符,要用单引号包起来

docker run --rm \
  docker.m.daocloud.io/httpd:latest \
  htpasswd -Bbn <username> <password> > htpasswd

生成 secret 文件

kubectl create secret generic docker-registry-auth \
  -n registry \
  --from-file=htpasswd

生成 registry 配置文件

因为涉及到 MinIO 的 accesskeysecretkey,这里采用 secret 的方式来生成配置文件

---
apiVersion: v1
kind: Secret
metadata:
  name: docker-registry-cm
  namespace: registry
stringData:
  config.yml: |-
    version: 0.1
    log:
      level: info
      fields:
        service: registry
    storage:
      delete:
        enabled: true
      cache:
          blobdescriptor: inmemory
      s3:
        accesskey: wJpkHB8rznvZBRLfKmBz
        secretkey: ZHIyklv5tktYvGR0iFqBiL9NKh7JKbhyDR9SNAYp
        region: default
        regionendpoint: http://minio.api.devops.icu
        forcepathstyle: true
        accelerate: false
        bucket: docker-registry
        encrypt: false
        secure: false
        v4auth: true
        chunksize: 5242880
        multipartcopymaxconcurrency: 10
    http:
      addr: :5000
      debug:
        addr: :5001
        prometheus:
            enabled: true
            path: /metrics
      headers:
        X-Content-Type-Options: [nosniff]
    health:
      storagedriver:
        enabled: true
        interval: 10s
        threshold: 3
    auth:
      htpasswd:
        realm: basic-realm
        path: /auth/htpasswd
type: Opaque

创建 service

---
apiVersion: v1
kind: Service
metadata:
  labels:
    app.kubernetes.io/name: docker-registry
  name: docker-registry-svc
  namespace: registry
spec:
  ports:
  - name: http
    port: 5000
    targetPort: http
  - name: http-metrics
    port: 5001
    targetPort: http-metrics
  selector:
    app.kubernetes.io/name: docker-registry
  type: ClusterIP

创建 statefulset

---
apiVersion: apps/v1
kind: StatefulSet
metadata:
  labels:
    app.kubernetes.io/name: docker-registry
  name: docker-registry
  namespace: registry
spec:
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/name: docker-registry
  serviceName: docker-registry-svc
  template:
    metadata:
      labels:
        app.kubernetes.io/name: docker-registry
    spec:
      affinity:
        podAntiAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
          - podAffinityTerm:
              labelSelector:
                matchLabels:
                  app.kubernetes.io/name: docker-registry
              topologyKey: kubernetes.io/hostname
            weight: 1
      containers:
      - image: docker.m.daocloud.io/registry:2.8.3
        livenessProbe:
          failureThreshold: 60
          initialDelaySeconds: 5
          periodSeconds: 10
          successThreshold: 1
          tcpSocket:
            port: http
          timeoutSeconds: 1
        name: docker-registry
        ports:
        - containerPort: 5000
          name: http
        - containerPort: 5001
          name: http-metrics
        readinessProbe:
          failureThreshold: 60
          initialDelaySeconds: 5
          periodSeconds: 10
          successThreshold: 1
          tcpSocket:
            port: http
          timeoutSeconds: 1
        resources:
          limits:
            cpu: 2000m
            memory: 2.5Gi
          requests:
            cpu: 100m
            memory: 100Mi
        startupProbe:
          failureThreshold: 60
          initialDelaySeconds: 5
          periodSeconds: 10
          successThreshold: 1
          tcpSocket:
            port: http
          timeoutSeconds: 1
        volumeMounts:
        - mountPath: /etc/docker/registry
          name: config
        - mountPath: /auth
          name: auth
      terminationGracePeriodSeconds: 30
      volumes:
      - name: config
        secret:
          secretName: docker-registry-cm
      - name: auth
        secret:
          secretName: docker-registry-auth

创建 ingress

没有 ingress 可以开 nodeport 来实现

---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations:
    nginx.ingress.kubernetes.io/proxy-body-size: 5G
  name: docker-registry
  namespace: registry
spec:
  ingressClassName: nginx
  rules:
  - host: registry.devops.icu
    http:
      paths:
      - backend:
          service:
            name: docker-registry-svc
            port:
              number: 5000
        path: /
        pathType: Prefix

验证 docker registry

/etc/docker/daemon.json 增加 registry 地址

"insecure-registries": ["ip:端口"]
# 或者
"insecure-registries": ["域名"]

登录 docker registry

docker login http://registry.devops.icu

修改 tag

docker tag docker.m.daocloud.io/registry:2.8.3 registry.devops.icu/registry:2.8.3

上传镜像

docker push registry.devops.icu/registry:2.8.3

docker registry 监控

grafana id:9621

prometheus 配置文件参考

    - job_name: docker-registry
      kubernetes_sd_configs:
      - role: endpoints
      relabel_configs:
      - source_labels: [__meta_kubernetes_namespace, __meta_kubernetes_service_name]
        regex: registry;docker-registry-svc
        action: keep
      - source_labels: [__meta_kubernetes_pod_ip]
        regex: (.+)
        target_label: __address__
        replacement: ${1}:5001
      - source_labels: [__meta_kubernetes_endpoints_name]
        action: replace
        target_label: endpoint
      - source_labels: [__meta_kubernetes_pod_name]
        action: replace
        target_label: pod
      - source_labels: [__meta_kubernetes_service_name]
        action: replace
        target_label: service
      - source_labels: [__meta_kubernetes_namespace]
        action: replace
        target_label: namespace

docker registry ui

Github 项目地址:Joxit/docker-registry-ui-2.5.7

相关的变量和参数详见:available-options

---
apiVersion: v1
kind: Service
metadata:
  labels:
    app.kubernetes.io/name: docker-registry-ui
  name: docker-registry-ui-svc
  namespace: registry
spec:
  ports:
  - name: http
    port: 8080
    protocol: TCP
    targetPort: 8080
  selector:
    app.kubernetes.io/name: docker-registry-ui
  type: ClusterIP
---
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app.kubernetes.io/name: docker-registry-ui
  name: docker-registry-ui
  namespace: registry
spec:
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/name: docker-registry-ui
  template:
    metadata:
      labels:
        app.kubernetes.io/name: docker-registry-ui
    spec:
      containers:
      - env:
        - name: SINGLE_REGISTRY
          value: "true"
        - name: SHOW_CATALOG_NB_TAGS
          value: "true"
        - name: REGISTRY_SECURED
          value: "true"
        - name: NGINX_PROXY_PASS_URL
          value: http://docker-registry-svc.registry.svc.cluster.local:5000
        - name: NGINX_PROXY_HEADER_Authorization
          value: $http_authorization
        image: joxit/docker-registry-ui:2.5.7
        imagePullPolicy: IfNotPresent
        name: docker-registry-ui
      securityContext:
        fsGroup: 101
        runAsUser: 101
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: docker-registry-ui
  namespace: registry
spec:
  ingressClassName: nginx
  rules:
  - host: registry.ui.devops.icu
    http:
      paths:
      - backend:
          service:
            name: docker-registry-ui-svc
            port:
              number: 8080
        path: /
        pathType: Prefix

标签:http,MinIO,kubernetes,1.28,registry,io,docker,name
From: https://www.cnblogs.com/chen2ha/p/18546602

相关文章

  • nginx代理minio的websocket问题,求解决!!!
    1.问题描述nginx代理minio集群,web控制台浏览buckets下的列表一直在loading...,不使用nginx代理地址,通过minio集群直接访问是没有问题的从报错来看是websocket连接失败问题,按照官方文档以及其他博主的方式都配置了,仍未解决!!!!!  2.minio镜像版本:minio/minio:RELEASE.2024-11......
  • SpringBoot:SpringBoot集成Minio+KkFileView实现所有文档格式预览功能
    前言博主做项目时,存储文件使用的是Minio,各类格式文件都有(图片,pdf,word,excel等等),因为项目需求这些文档能进行预览,全部交给前端实现需要各种组件支撑,这无疑会加大前端的开发量,所以博主在网上搜索大量解决方法,最终找到这种可以实现方案。具体的kkFileView的介绍和部署可以看我的另一......
  • openEuler搭建k8s(1.28.2版本)
    目录k8s搭建(1.28.2版本)1.安装containerd1.1下载tar包1.2编写服务单元文件2.安装runc3.安装cni插件3.1下载文件3.2设置crictl运行端点4.配置containerd5.主机配置5.1编辑hosts文件(可选)5.2开启流量转发5.3关闭防火墙以及selinux5.4关闭swap6.搭建k8s6.1配置yum源......
  • Ubuntu 22.04.1 LTS 安装 MinIO
    1. 创建数据目录#数据存储目录mkdir-p/mnt/c/aipc/minio#日志存储目录cd/mnt/c/aipc/miniomkdir-plogsconfdatachmod-R777/mnt/c/aipc/minio2.安装wgethttps://dl.min.io/server/minio/release/linux-amd64/minio#将下载所得minio文件拷贝到指定文件夹......
  • nginx二级目录代理minio指定桶
    nginx二级目录代理minio指定桶nginx提供了外网地址,通过二级目录可以代理内网minio的具体桶,将图片展示。配置如下:server{listen8443ssl;server_nameyourdomain.com;ssl_certificate/path/to/your/certificate.crt;ssl_certificate_key/path/to/your......
  • 基于Centos7.X部署MinIO分布式集群
    1、规划4台虚拟机说明:一个N节点的分布式MinIO集群中,只要有N/2节点在线,数据就是安全的,同时,为了确保能够创建新的对象,需要至少有N/2+1个节点,因此对于一个4节点集群,即使有两个节点宕机,集群仍然是可以读的,但需要有3个节点才能写数据。所以,至少需要四台节点构建集群。2、为每台虚......
  • 【docker】拉取镜像环境报错解决#ERROR: Get https://registry-1.docker.io/v2/
    系统环境是ubuntu24.04创建daemon.json文件,设置国内加速地址。之前尝试使用了阿里,网易,百度的都不行。最后网上随便找了一粘进去,{"registry-mirrors":["https://docker.registry.cyou","https://docker-cf.registry.cyou","https://dockercf.jsdelivr.fyi","https://do......
  • Minio
    Minio部署MinIO在server01部署MinIO,安装方式采用rpm离线安装,具体步骤可参考官方文档。获取MinIO安装包下载地址如下:https://dl.min.io/server/minio/release/linux-amd64/archive/minio-20230809233022.0.0.x86_64.rpm,通过以下命令可直接将安装包下载至服务器wgethttps://......
  • Docker仓库之Registry私有镜像仓库的搭建与使用
    本章将和大家分享Docker仓库之Registry私有镜像仓库的搭建与使用。废话不多说,下面我们直接进入主题。一、官方标配:Registry私有镜像仓库DockerHub作为Docker默认官方公共镜像仓库,如果想要自己搭建私有镜像仓库,官方也提供了Registry镜像,使得我们搭建私有仓库变得非常简单。所谓......
  • 解决docker安装minio容器时,minio容器启动几秒后自动退出的一种方法
    笔者在部署minio容器时,遇到了以上问题。起初以为是我端口被占用或存储空间不足,经过检测排除了以上问题。以下是最初的安装命令:dockerrun-d--nameminio--restart=always-p9000:9000-e"MINIO_ACCESS_KEY=minio"-e"MINIO_SECRET_KEY=minio123"-v/home/data:/data-v/......