当前位置:网站首页>How does kubernetes use harbor to pull private images
How does kubernetes use harbor to pull private images
2022-04-23 08:55:00 【MyySophia】
7. harbor coordination kubernetes Use
7.1 k8s The way to pull the image
Always: When the container fails , from Kubelet Restart the container automatically .RestartPolicy The default value of .
OnFailure: When the container stops running and the exit code is not 0 When by Kubelet restart .
Never: In any case ,Kubelet Will not restart the container .
Be careful , Restart here refers to Pod Where Node Local restart above , It will not be dispatched to other Node Up .
7.2 Use the private image warehouse to pull the image
7.2.1 k8s-node Node add validation
take harbor The following three files on the server are distributed to kubernetes Clustered node node /etc/docker/certs.d/10.50.10.185/
This catalog
- Server certificate (10.50.10.185.cert
)
secret key (10.50.10.185.key
)- CA file (
ca.crt
)
7.2.2 Pull out the mirror image
stay node Node execution
docker pull 10.50.10.185/harbortest/nginx:latest
If you can successfully pull the representative node The certificate of the node is valid
7.2.3 Create a docker registry secret
Use private warehouses
kubectl create secret docker-registry regsecret --docker-server=https://10.50.10.185 --docker-username=admin --docker-password=Harb2323 --docker-email=[email protected]
Use Azure Container Registry(ACR): https://kubernetes.feisky.xyz/concepts/objects/pod
ACR_NAME=dregistry
SERVICE_PRINCIPAL_NAME=acr-service-principal
# Populate the ACR login server and resource id.
ACR_LOGIN_SERVER=$(az acr show --name $ACR_NAME --query loginServer --output tsv)
ACR_REGISTRY_ID=$(az acr show --name $ACR_NAME --query id --output tsv)
# Create a contributor role assignment with a scope of the ACR resource.
SP_PASSWD=$(az ad sp create-for-rbac --name $SERVICE_PRINCIPAL_NAME --role Reader --scopes $ACR_REGISTRY_ID --query password --output tsv)
# Get the service principle client id.
CLIENT_ID=$(az ad sp show --id http://$SERVICE_PRINCIPAL_NAME --query appId --output tsv)
# Create secret
kubectl create secret docker-registry acr-auth --docker-server $ACR_LOGIN_SERVER --docker-username $CLIENT_ID --docker-password $SP_PASSWD --docker-email [email protected]
7.2.4 quote docker registry secret Two ways
Directly in pod I quote
apiVersion: v1
kind: Pod
metadata:
name: harbor-test
spec:
containers:
- name: harbor-test
image: 10.50.10.185/harbortest/nginx:latest
imagePullSecrets:
- name: regsecret
secret Add to service account in s And pass ervice account quote
Obviously, if secret Add to sa in , There is another layer of abstraction , Not in each pod perhaps deployment Each of the container Write it all down imagePullSecrets. And it shields the details from the user . Users don't need to care
kubectl patch serviceaccount default -p '{"imagePullSecrets": [{"name": "regsecret"}]}'
/opt/k8s]#kubectl get sa -oyaml
apiVersion: v1
items:
- apiVersion: v1
imagePullSecrets:
- name: regsecret
kind: ServiceAccount
metadata:
creationTimestamp: "2022-03-18T12:31:44Z"
name: default
namespace: default
resourceVersion: "4202955"
uid: a9b88295-630e-4121-94e1-ab53a17f4f49
secrets:
- name: default-token-qvnrc
kind: List
metadata:
resourceVersion: ""
selfLink: ""
actual combat
Use deployment Deploy nginx
apiVersion: apps/v1
kind: Deployment
metadata:
name: harbor-test
labels:
app: nginx
spec:
replicas: 10
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
#image: nginx:latest
image: 10.50.10.185/harbortest/nginx:latest
ports:
- containerPort: 80
image The field must be written harbor The full path , Otherwise, the default source will be used to pull the image
版权声明
本文为[MyySophia]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230811520496.html
边栏推荐
- Solidity 问题汇总
- Failed to prepare device for development
- OneFlow學習筆記:從Functor到OpExprInterpreter
- RCC introduction of Hal Library
- idea打包 jar文件
- Use include in databinding
- Yangtao electronic STM32 Internet of things entry 30 step notes II. Cube ide download, installation, sinicization and setting
- 使用flask和h5搭建网站/应用的简要步骤
- Multi view depth estimation by fusing single view depth probability with multi view geometry
- GUI编程简介 swing
猜你喜欢
Please arrange star trek in advance to break through the new playing method of chain tour, and the market heat continues to rise
Yangtao electronic STM32 Internet of things entry 30 step notes II. Cube ide download, installation, sinicization and setting
php基于哈希算法出现的强弱比较漏洞
LeetCode_DFS_中等_1254. 统计封闭岛屿的数目
Star Trek's strong attack opens the dream linkage between metacosmic virtual reality
1099 establish binary search tree (30 points)
The K neighbors of each sample are obtained by packet switching
Summary of solid problems
Flash project cross domain interception and DBM database learning [Baotou cultural and creative website development]
2022-04-22 openebs cloud native storage
随机推荐
Arbre de dépendance de l'emballage des ressources
Flink reads MySQL and PgSQL at the same time, and the program will get stuck without logs
mycat配置
Single chip microcomputer nixie tube stopwatch
MySQL小练习(仅适合初学者,非初学者勿进)
是否同一棵二叉搜索树 (25 分)
Notes d'apprentissage oneflow: de functor à opexprinterpreter
Chris LATTNER, father of llvm: the golden age of compilers
Go语言自学系列 | golang嵌套结构体
【IndexOf】【lastIndexOf】【split】【substring】用法详解
Concave hull acquisition method based on convex hull of point cloud
Summary of solid problems
Please arrange star trek in advance to break through the new playing method of chain tour, and the market heat continues to rise
使用flask和h5搭建网站/应用的简要步骤
L2-023 graph coloring problem (25 points) (graph traversal)
关于cin,scanf和getline,getchar,cin.getline的混合使用
Initial experience of talent plan learning camp: communication + adhering to the only way to learn open source collaborative courses
PLC point table (register address and point table definition) cracking detection scheme -- convenient for industrial Internet data acquisition
Get the absolute path of the class according to the bytecode
K210 learning notes (II) serial communication between k210 and stm32