当前位置:  开发笔记 > 编程语言 > 正文

kubernete私人注册表不起作用

如何解决《kubernete私人注册表不起作用》经验,为你挑选了0个好方法。

我按照以下链接配置kubernete私有注册表:https: //github.com/kubernetes/kubernetes/tree/master/cluster/addons/registry,唯一的区别是从kube-system到default的命名空间更改.

Docker注册表

apiVersion: v1
kind: ReplicationController
metadata:
  name: kube-registry-v0
  namespace: default
  labels:
    k8s-app: kube-registry
    version: v0
    kubernetes.io/cluster-service: "true"
spec:
  replicas: 1
  selector:
    k8s-app: kube-registry
    version: v0
  template:
    metadata:
      labels:
        k8s-app: kube-registry
        version: v0
        kubernetes.io/cluster-service: "true"
    spec:
      containers:
      - name: registry
        image: registry:2
        resources:
          limits:
            cpu: 100m
            memory: 100Mi
        env:
        - name: REGISTRY_HTTP_ADDR
          value: :5000
        - name: REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY
          value: /var/lib/registry
        volumeMounts:
        - name: image-store
          mountPath: /var/lib/registry
        ports:
        - containerPort: 5000
          name: registry
          protocol: TCP
      volumes:
      - name: image-store
        nfs:
        # Use real NFS server address here.
          server: 172.19.180.4
        # Use real NFS server export directory.
          path: "/nfs/www"

注册表服务yaml文件:

apiVersion: v1
kind: Service
metadata:
  name: kube-registry
  namespace: default
  labels:
    k8s-app: kube-registry
    kubernetes.io/cluster-service: "true"
    kubernetes.io/name: "KubeRegistry"
spec:
  selector:
    k8s-app: kube-registry
  ports:
  - name: registry
    port: 5000
    protocol: TCP`

Expose the registry on each node

`apiVersion: v1
kind: Pod
metadata:
  name: kube-registry-proxy
  namespace: default
spec:
  containers:
  - name: kube-registry-proxy
    image: gcr.io/google_containers/kube-registry-proxy:0.3
    resources:
      limits:
        cpu: 100m
        memory: 50Mi
    env:
    - name: REGISTRY_HOST
      value: kube-registry.kube-system.svc.cluster.local
    - name: REGISTRY_PORT
      value: "5000"
    - name: FORWARD_PORT
      value: "5000"
    ports:
    - name: registry
      containerPort: 5000
      hostPort: 5000`

以下是与之对应的结果

root@fed-master ~]# kubectl get services
NAME            CLUSTER_IP     EXTERNAL_IP   PORT(S)         SELECTOR                AGE
dns-backend     10.18.110.23           8000/TCP        name=dns-backend        6d
kube-dns        10.18.0.10             53/UDP,53/TCP   k8s-app=kube-dns        3d
kube-registry   10.18.85.239           5000/TCP        k8s-app=kube-registry   2d
kubernetes      10.18.0.1              443/TCP                           26d
[root@fed-master ~]# kubectl get rc
CONTROLLER         CONTAINER(S)   IMAGE(S)                                         SELECTOR                           REPLICAS   AGE
kube-dns-v9        etcd           gcr.io/google_containers/etcd:2.0.9              k8s-app=kube-dns,version=v9        1          3d
                   kube2sky       gcr.io/google_containers/kube2sky:1.11                                              
                   skydns         gcr.io/google_containers/skydns:2015-03-11-001                                      
                   healthz        gcr.io/google_containers/exechealthz:1.0                                            
kube-registry-v0   registry       registry:2                                       k8s-app=kube-registry,version=v0   1         2d
[root@fed-master ~]# kubectl get pod
NAME                             READY     STATUS    RESTARTS   AGE
kube-dns-v9-uuee0                4/4       Running   0          3d
kube-registry-proxy-fed-master   1/1       Running   0          1d
kube-registry-proxy-fed-node     1/1       Running   0          1d
kube-registry-proxy-fed-node2    1/1       Running   0          1d
kube-registry-v0-slqx3           1/1       Running   0          2d

但测试结果不是我所期望的卷曲localhost:5000卷曲:(56)Recv失败:连接由同行重置

如何解决它以及如何使用本地私有注册表?预先感谢

推荐阅读
sx-March23
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有