配置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
posted @ 2020-09-30 08:47  张冠胜  阅读(2534)  评论(0编辑  收藏  举报