創(chuàng)建ImagePullSecret
一、登錄鏡像倉庫囊颅,成功之后會生成如下/root/.docker/config.json文件
{
"auths": {
"docker.registry": {
"auth": "YWRtaW4******lRlY2g="
}
},
"HttpHeaders": {
"User-Agent": "Docker-Client/***"
}
}
說明:
-docker.registry:鏡像倉庫地址
二、執(zhí)行如下命令創(chuàng)建ImagePullSecret
kubectl create secret generic harbor-admin-secret --from-file=.dockerconfigjson=/root/.docker/config.json --type=kubernetes.io/dockerconfigjson --namespace hnbcao-mixing-ore
說明:
-harbor-admin-secret: ImagePullSecret名字
-type: 指定secret類型為kubernetes.io/dockerconfigjson
-namespace:secret命名空間
三潮模、為項目添加ImagePullSecret
Deployment
在配置項的spec.template.spec.imagePullSecrets下添加secret:harbor-admin-secret腾誉。例如蛉签,Deployment的配置如下:
kind: Deployment
apiVersion: apps/v1
metadata:
name: app-test
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/instance: app-test
app.kubernetes.io/name: hnbcao
template:
metadata:
labels:
app.kubernetes.io/instance: app-test
app.kubernetes.io/name: hnbcao
spec:
containers:
- name: hnbcao
image: nginx
imagePullSecrets:
- name: harbor-admin-secret
四装盯、友情鏈接
官網(wǎng)教程地址:https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/