首页 > 其他分享 >containerd推送+kaniko build配置简述

containerd推送+kaniko build配置简述

时间:2022-10-10 16:14:14浏览次数:79  
标签:name -- containerd 192.168 kaniko registry build

前置条件
设置清华yum源
https://mirrors.tuna.tsinghua.edu.cn/help/centos/
安装一些工具
yum -y install wget jq psmisc vim net-tools nfs-utils telnet yum-utils device-mapper-persistent-data lvm2 git network-scripts tar curl -y
部署containerd
设置containerd配置文件中的下述部分
    [plugins."io.containerd.grpc.v1.cri".registry]
      config_path = ""
      [plugins."io.containerd.grpc.v1.cri".registry.mirrors]
        [plugins."io.containerd.grpc.v1.cri".registry.mirrors."docker.io"]
          endpoint = ["http://registry-1.docker.io"]
        [plugins."io.containerd.grpc.v1.cri".registry.mirrors."192.168.42.132"]
          endpoint = ["http://192.168.42.132"]
      [plugins."io.containerd.grpc.v1.cri".registry.configs]
        [plugins."io.containerd.grpc.v1.cri".registry.configs."192.168.42.132".tls]
          insecure_skip_verify = true
        [plugins."io.containerd.grpc.v1.cri".registry.configs."192.168.42.132".auths]
          username="admin"
          password="Harbor12345"

重启
systemctl restart containerd

部署完k8s系统
部署完Harbor仓库或者docker registry仓库
这里仓库是http协议未使用https
工作目录:/root/kaniko

为k8s添加镜像仓库认证
kubectl create secret docker-registry myregistrykey --docker-server=192.168.42.132 --docker-username=admin --docker-password=Harbor12345
查看
kubectl get secret

写文件
vim Dockerfile
FROM alpine 
RUN echo "created from standard input"

设置为pod资源类型的
写文件
vim kaniko.yaml
apiVersion: v1
kind: Pod
metadata:
  name: kaniko
spec:
  containers:
  - name: kaniko
    image: 192.168.42.132/wxg/kaniko-project-executor:latest
    args: [ "--dockerfile=Dockerfile",
            "--context=/root/kaniko",
            "--destination=192.168.42.132/k8s/kaniko-project-executor:v12"]
    volumeMounts:
      - name: kaniko-secret
        mountPath: /root/.docker
      - name: project-volume
        mountPath: /root/kaniko
  restartPolicy: Never
  volumes:
    - name: kaniko-secret
      secret:
        secretName: myregistrykey
        items:
          - key: .dockerconfigjson
            path: config.json
    - name: project-volume
      hostPath:
        path: /root/kaniko

设置为Job资源类型,100s后销毁Pod
apiVersion: batch/v1
kind: Job
metadata:
  name: kaniko
spec:
  ttlSecondsAfterFinished: 100
  template:
    spec:
      containers:
      - name: kaniko
        image: 192.168.42.132/wxg/kaniko-project-executor:latest
        args: [ "--dockerfile=Dockerfile",
                "--context=/tmp",
                "--destination=192.168.42.132/k8s/kaniko-project-executor:v14"]
        volumeMounts:
          - name: kaniko-secret
            mountPath: /root/.docker/
          - name: project-volume
            mountPath: /tmp
      restartPolicy: Never
      volumes:
        - name: kaniko-secret
          secret:
            secretName: myregistrykey
            items:
              - key: .dockerconfigjson
                path: config.json
        - name: project-volume
          hostPath:
            path: /tmp

标签:name,--,containerd,192.168,kaniko,registry,build
From: https://www.cnblogs.com/virmpre/p/16776049.html

相关文章