From f77f5b98329576c327f6ca7a8a3f602340136c18 Mon Sep 17 00:00:00 2001 From: dragon Date: Fri, 17 Dec 2021 08:29:52 +0800 Subject: [PATCH] add use secret --- devops/move2alirepositories.md | 71 ++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/devops/move2alirepositories.md b/devops/move2alirepositories.md index e1cc198..b83953a 100644 --- a/devops/move2alirepositories.md +++ b/devops/move2alirepositories.md @@ -83,3 +83,74 @@ docker push registry.cn-hangzhou.aliyuncs.com/fs-cloud/anxinyun-api:$IMAGE_VERSI + + + + +# 如何在项目中使用 + + + +由于现在镜像仓库设置成私有的,默认是无法拉取的, + +## 创建 secret + +```shell +kubectl create secret docker-registry -n <命名空间> \ + --docker-server=<你的镜像仓库服务器> \ + --docker-username=<你的用户名> \ + --docker-password=<你的密码> \ + --docker-email=<你的邮箱地址> +``` + + + +```shell +kubectl create secret docker-registry registry-anxinyun-secret -n anxinyun \ + --docker-server='registry.cn-hangzhou.aliyuncs.com' \ + --docker-username='hi50040201@aliyun.com' \ + --docker-password='V9rtCnt$f' +``` + + + +## 在yaml 文件中使用secret + + + +```yaml +kind: Deployment +apiVersion: apps/v1 +metadata: + name: api-anxincloud + namespace: anxincloud + labels: + app: api-anxincloud +spec: + replicas: 3 + selector: + matchLabels: + app: api-anxincloud + template: + metadata: + labels: + app: api-anxincloud + spec: + containers: + - name: api-anxincloud + image: registry.cn-hangzhou.aliyuncs.com/fs-cloud/anxinyun-web.api:179.21-12-15 + command: + - node + - server.js + ports: + - name: http-8080 + containerPort: 8080 + protocol: TCP + ... + ... + imagePullSecrets: + - name: registry-anxinyun-secret +``` + + +