k8s使用Harbor私有镜像
创建Secrets

Harbor创建只读账号readonly 创建Secrets

docker login https://harbor.test.com
[root@103 harbor.test.com]# cat ~/.docker/config.json 
{
    "auths": {
        "harbor.test.com": {
            "auth": "cmVhZG9ubHk6UmVhZG9ubHkxMjMh"
        }
    },
    "HttpHeaders": {
        "User-Agent": "Docker-Client/18.06.3-ce (linux)"
    }
[root@103 ~]# cat ~/.docker/config.json |base64 -w 0
ewoJImF1dGhzIjogewoJCSJoYXJib3IudGVzdC5jb20iOiB7CgkJCSJhdXRoIjogImNtVmhaRzl1YkhrNlVtVmhaRzl1YkhreE1qTWgiCgkJfQoJfSwKCSJIdHRwSGVhZGVycyI6IHsKCQkiVXNlci1BZ2VudCI6ICJEb2NrZXItQ2xpZW50LzE4LjA2LjMtY2UgKGxpbnV4KSIKCX0KfQ==
使用

harbor-key.yaml

apiVersion: v1
data:
  .dockerconfigjson: ewoJImF1dGhzIjogewoJCSJoYXJib3IudGVzdC5jb20iOiB7CgkJCSJhdXRoIjogImNtVmhaRzl1YkhrNlVtVmhaRzl1YkhreE1qTWgiCgkJfQoJfSwKCSJIdHRwSGVhZGVycyI6IHsKCQkiVXNlci1BZ2VudCI6ICJEb2NrZXItQ2xpZW50LzE4LjA2LjMtY2UgKGxpbnV4KSIKCX0KfQ==
kind: Secret
metadata:
  name: harbor-key
  namespace: dev
type: kubernetes.io/dockerconfigjson
#创建查询
[root@101 ~]# kubectl apply -f harbor-key.yaml 
secret/harbor-key created
[root@101 ~]# kubectl get secrets -n dev
NAME                  TYPE                                  DATA   AGE
default-token-dt9wb   kubernetes.io/service-account-token   3      145m
harbor-key            kubernetes.io/dockerconfigjson        1      11s

拉取镜像
harbor-nginx.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-test
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nginx-test
  template:
    metadata:
      labels:  
        app: nginx-test
    spec:
      containers:
      - name: nginx-test
        image: harbor.test.com/nginx-test:latest # 使用 Harbor 上的镜像
        imagePullPolicy: Always
        ports:
        - containerPort: 80 
      imagePullSecrets:
      - name: harbor-key # 使用刚刚创建的 Harbor Secrets
查看
[root@101 ~]# kubectl get pods -n dev -o wide
NAME                          READY   STATUS    RESTARTS   AGE   IP            NODE   NOMINATED NODE   READINESS GATES
nginx-test-658bcfd6cd-8fcmx   1/1     Running   0          24s   10.244.1.80   102    <none>           <none>
[root@101 ~]# curl 10.244.1.80
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
html { color-scheme: light dark; }
body { width: 35em; margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif; }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>
<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>
<p><em>Thank you for using nginx.</em></p>
</body>
</html>
暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇