当前位置:网站首页>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
边栏推荐
- PCTP考试经验分享
- tsdf +mvs
- 调包求得每个样本的k个邻居
- Swagger document export custom V2 / API docs interception
- How much inventory recording does the intelligent system of external call system of okcc call center need?
- 错误: 找不到或无法加载主类
- php基于哈希算法出现的强弱比较漏洞
- 2022-04-22 openebs cloud native storage
- Automatic differentiation and higher order derivative in deep learning framework
- 微信:获取单个标签所有人
猜你喜欢
LLVM之父Chris Lattner:编译器的黄金时代
2021李宏毅机器学习之Adaptive Learning Rate
Strength comparison vulnerability of PHP based on hash algorithm
Introduction to GUI programming swing
2021 Li Hongyi's adaptive learning rate of machine learning
Yangtao electronic STM32 Internet of things entry 30 step notes IV. engineering compilation and download
MySQL查询两张表属性值非重复的数据
Arbre de dépendance de l'emballage des ressources
Flash project cross domain interception and DBM database learning [Baotou cultural and creative website development]
1099 建立二叉搜索树 (30 分)
随机推荐
数字政府建设中政务中台中的技术创新点
扣缴义务人
Flink reads MySQL and PgSQL at the same time, and the program will get stuck without logs
Star Trek强势来袭 开启元宇宙虚拟与现实的梦幻联动
GUI编程简介 swing
MATLAB入门资料
Star Trek's strong attack opens the dream linkage between metacosmic virtual reality
Stm32f103zet6 [development of standard library functions] - Introduction to library functions
idea打包 jar文件
Notes on 30 steps of introduction to Internet of things of yangtao electronics STM32 III. Explanation of new cubeide project and setting
Consensus Token:web3.0生态流量的超级入口
Go language self-study series | golang method
Brush classic topics
Go语言自学系列 | golang结构体作为函数参数
Reference passing 1
Go language self-study series | initialization of golang structure
Find the sum of simple types of matrices
【58】最后一个单词的长度【LeetCode】
rembg 分割mask
K210 learning notes (II) serial communication between k210 and stm32