配置k8s拉取Harbor鏡像


創建Secret

# 認證名稱為:docker-harbor-registry
kubectl create secret docker-registry docker-harbor-registry \
--docker-server=10.170.128.9:83/ \
--docker-username=jexcins \
--docker-password='TTnbdfi002'

將 secret 添加到 ServiceAccount

# 認證名稱為:docker-harbor-registry
kubectl patch serviceaccount default -p '{"imagePullSecrets": [{"name": "docker-harbor-registry"}]}'

在Deployment文件中添加認證

apiVersion: apps/v1
kind: Deployment
metadata:
  name: testapi-prod-node
spec:
  replicas: 1
  selector:
    matchLabels:
      app: testapi-prod
  template:
    metadata:
      labels:
        app: testapi-prod
    spec:
      containers:
        - name: testapi-prod-instance
          image: {IMAGE-URL}
          command: [ "dotnet", "DotNetCore.API.dll" ]
          ports:
          - containerPort: 5000
      imagePullSecrets:
        - name: docker-harbor-registry


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM