走心的狗 kubernetes經過私有倉庫harbor拉取鏡像(private不是publi)

若是設置爲公開,那麼久不須要配置這一步驟。只須要docker login 登陸成功以後,k8s kubectl create 就能夠拉取鏡像git

若是設置爲私有,須要docker login 登陸成功以後,k8s kubectl create 就拉取不了鏡像。並且還須要配置以下步驟github

 

首先配置私有倉庫harbor的secret:docker

# kubectl create secret docker-registry registry-secret --namespace=default \
--docker-server=https://private-registry.domain.com --docker-username=username \
--docker-password=password --docker-email=username@abcd.com

 

 

   部署時指定imagePullSecretsshell

複製代碼

kind: Deployment
apiVersion: extensions/v1beta1
metadata:
  name: service-test
  namespace: default
  labels:
    app: service-test
spec:
  replicas: 2
  template:
    metadata:
      labels:
        app: service-test
    spec:
      containers:
      - image: private-registry.domain.com/test-private/service-test:1
        name: service-test
        ports:
        - containerPort: 80
      imagePullSecrets:
      - name: registry-secret

相關腳本參考:api

https://github.com/mritd/shell_scripts/blob/master/create_imagePullSecret.shapp

相關文章
相關標籤/搜索