Kubernetes私人登记处不起作用

时间:2017-03-30 12:56:23

标签: docker kubernetes docker-registry

我使用这些配置:https://github.com/kubernetes/kubernetes/tree/master/cluster/addons/registry

registry.yml:

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: :5050
        - name: REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY
          value: /var/lib/registry
        volumeMounts:
        - name: image-store
          mountPath: /var/lib/registry
        ports:
        - containerPort: 5050
          name: registry
          protocol: TCP
      volumes:
      - name: image-store
        emptyDir: {}

注册表-service.yml:

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: 5050
    protocol: TCP

注册表-expose.yml:

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: "5050"
    - name: FORWARD_PORT
      value: "5050"
    ports:
    - name: registry
      containerPort: 5050
      hostPort: 5050

状态:

$ kubectl get pods
NAME                     READY     STATUS    RESTARTS   AGE
kube-registry-proxy      1/1       Running   0          33m
kube-registry-v0-m57gk   1/1       Running   1          33m

$ kubectl get services
NAME            CLUSTER-IP      EXTERNAL-IP   PORT(S)    AGE
kube-registry   10.98.134.140   <none>        5050/TCP   34m
kubernetes      10.96.0.1       <none>        443/TCP    2h

$ kubectl get componentstatuses
NAME                 STATUS    MESSAGE              ERROR
scheduler            Healthy   ok                   
controller-manager   Healthy   ok                   
etcd-0               Healthy   {"health": "true"} 

无法看到发生了什么:

$ kubectl exec -it kube-registry-v0-m57gk -- bash
rpc error: code = 2 desc = containerd: container not started

主机上没有打开5050端口,但我不确定它是否是预期的结果。从kube-registry-proxy内部可以ping一些其他容器,但是没有足够的工具可以清楚地看到。

如何使本地注册表有效?

3 个答案:

答案 0 :(得分:0)

运行kubectl describe pod kube-registry-v0-m57gk并检查播放状态?好像kube-registry-v0-m57gk中的容器无法正常启动。

答案 1 :(得分:0)

只有发生过这种情况的注册表容器或其他标记符?

如果它发生在其他人身上,那是因为你没有网络插件,为此你可以使用编织的插件。

Kubectl apply -f https://git.io/weave-kube

答案 2 :(得分:0)

你可以在那个节点上docker version取悦。这是docker 1.11.2的主要问题,并在1.12.x

中得到修复