当前位置:网站首页>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
边栏推荐
- Idea is configured to connect to the remote database mysql, or Navicat fails to connect to the remote database (solved)
- Applet in wechat and app get current ()
- BK3633 规格书
- 使用flask和h5搭建网站/应用的简要步骤
- Concave hull acquisition method based on convex hull of point cloud
- 2021 Li Hongyi's adaptive learning rate of machine learning
- STM32 uses Hal library. The overall structure and function principle are introduced
- 数字政府建设中政务中台中的技术创新点
- Experimental report on analysis of overflow vulnerability of assembly language and reverse engineering stack
- 资源打包关系依赖树
猜你喜欢

cadence的工艺角仿真、蒙特卡洛仿真、PSRR

After a circle, I sorted out this set of interview questions..

The K neighbors of each sample are obtained by packet switching

Valgrind et kcachegrind utilisent l'analyse d'exécution

Multi view depth estimation by fusing single view depth probability with multi view geometry

K210 learning notes (II) serial communication between k210 and stm32

L2-024 部落 (25 分)(并查集)

Introduction to matlab

Share the office and improve the settled experience

idea打包 jar文件
随机推荐
是否完全二叉搜索树 (30 分)
dataBinding中使用include
Notes d'apprentissage oneflow: de functor à opexprinterpreter
Introduction to matlab
论文阅读《Multi-View Depth Estimation by Fusing Single-View Depth Probability with Multi-View Geometry》
Valgrind and kcache grind use run analysis
使用flask和h5搭建网站/应用的简要步骤
Arbre de dépendance de l'emballage des ressources
扣缴义务人
Stm32f103zet6 [development of standard library functions] - Introduction to library functions
求简单类型的矩阵和
Use include in databinding
Flash project cross domain interception and DBM database learning [Baotou cultural and creative website development]
2021 Li Hongyi's adaptive learning rate of machine learning
Pctp test experience sharing
Star Trek's strong attack opens the dream linkage between metacosmic virtual reality
增强现实技术是什么?能用在哪些地方?
【IndexOf】【lastIndexOf】【split】【substring】用法详解
MATLAB 画五星红旗
Please arrange star trek in advance to break through the new playing method of chain tour, and the market heat continues to rise