Kubernetes使用Harbor仓库

1.创建Secret:

kubectl create secret docker-registry SECRET_NAME –namespace=NAME_SPACE \
–docker-server=DOCKER_REGISTRY_SERVER –docker-username=DOCKER_USER \
–docker-password=DOCKER_PASSWORD –docker-email=DOCKER_EMAIL

其中,
docker-server 为通过docker login登陆时输入的地址
docker-username 为登陆时的账号
docker-password 为登陆时的密码
docker-email 为注册的账号时的邮箱地址

查看secret的内容:
kubectl get secret harbor –namespace=common -o yaml

2.在RC中引用:
root@kubernetes1:~/test# cat frontend-controller.yaml
apiVersion: v1
kind: ReplicationController
metadata:
  name: frontend
  namespace: common
  labels:
    name: frontend
spec:
  replicas: 3
  selector:
    name: frontend
  template:
    metadata:
      namespace: common
      labels:
        name: frontend
    spec:
      containers:
      - name: frontend
        image: server.com/test/guestbook-php-frontend
        env:
        - name: GET_HOSTS_FROM
          value: env
        ports:
        - containerPort: 80
      imagePullSecrets:
      - name: harbor

kubectl create -f frontend-controller.yaml

3.查看Pods状态及日志:

kubectl get pods –namespace=common
kubectl describe pod frontend-cwfsm –namespace=common

遇到的问题:

1.FailedSync Error syncing pod, skipping: failed to “StartContainer” for “frontend” with ErrImagePull: “Error response from daemon: {\”message\”:\”Get https://server.com/v1/_ping: dial tcp: lookup harbor.itopka.com on 10.16.40.3:53: no such host\”}”

解决:在公网解析了域名的私网IP地址。

2.FailedSync Error syncing pod, skipping: failed to “StartContainer” for “frontend” with ErrImagePull: “Error response from daemon: {\”message\”:\”Get https://server.com/v1/_ping: dial tcp 192.168.1.132:443: getsockopt: connection refused\”}”

解决:在/etc/default/docker中添加:
DOCKER_OPTS=”- -insecure-registry server.com”

ubuntu 15\16:
vim /lib/systemd/system/docker.service
ExecStart=/usr/bin/docker daemon -H fd:// –insecure-registry harbor.itopka.com



另外通过创建serviceAccount并引用的方式没有将pod运行起来,好不知道原因。提示:
Failed to pull image “server.com/test/guestbook-php-frontend”: image pull failed for server.com/test/guestbook-php-frontend:latest, this may be because there are no credentials on this request. details: (Error: image test/guestbook-php-frontend:latest not found)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值