使用 kind 搭建私有仓库
·83 字·1 分钟·
0
·
0
·
开发笔记
docker
k8s
-
创建一个
config.yaml文件,内容如下:kind: Cluster apiVersion: kind.x-k8s.io/v1alpha4 nodes: - role: control-plane kubeadmConfigPatches: - | kind: InitConfiguration nodeRegistration: kubeletExtraArgs: node-labels: "ingress-ready=true" - | kind: ClusterConfiguration apiServer: extraArgs: service-node-port-range: 80-65535 containerdConfigPatches: - |- [plugins."io.containerd.grpc.v1.cri".registry.mirrors."your-registry:5000"] endpoint = ["http://your-registry:5000"]其中
your-registry替换为你的私有仓库的域名或 IP。 -
运行以下命令创建一个名为
kubeflow的 Kubernetes 集群,并加载config.yaml中的配置:kind create cluster --name kubeflow --config config.yaml -
验证集群中的节点是否已成功添加私有仓库镜像:
kubectl get nodes -o wide在输出中找到对应的节点,并检查其
CONTAINERD_ENDPOINT环境变量是否包含私有仓库的地址,例如:CONTAINERD_ENDPOINT=unix:///run/containerd/containerd.sock;containerd://kind-worker/kind-d18fb8e2b6f9 [plugins."io.containerd.grpc.v1.cri".registry.mirrors."your-registry:5000".endpoint=["http://your-registry:5000"]] -
部署应用程序时,在
Deployment或Pod的 YAML 文件中添加以下内容来指定使用私有仓库的镜像:spec: containers: - name: my-app image: your-registry:5000/my-image:latest其中
your-registry替换为你的私有仓库的域名或 IP,my-image替换为要使用的镜像名称。