kubernete私人注册表不起作用

时间:2016-03-22 07:13:22

标签: docker kubernetes

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

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   <none>        8000/TCP        name=dns-backend        6d
kube-dns        10.18.0.10     <none>        53/UDP,53/TCP   k8s-app=kube-dns        3d
kube-registry   10.18.85.239   <none>        5000/TCP        k8s-app=kube-registry   2d
kubernetes      10.18.0.1      <none>        443/TCP         <none>                  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

但测试结果不是我的预期  curl localhost:5000 curl:(56)Recv failure:由peer重置连接

如何解决它以及如何使用本地私有注册表? 提前谢谢

0 个答案:

没有答案