使用Kubernetes持续卷声明与Amazon EBS的难度

时间:2016-02-09 03:36:44

标签: amazon-web-services kubernetes

我尝试按照https://github.com/kubernetes/kubernetes/tree/master/cluster/addons/registry上的说明向Kubernetes添加私有泊坞广告注册表,但由rc创建的广告托管无法安装持久量声明。

首先,我在EBS上创建一个卷,如下所示:

aws ec2 create-volume --region us-west-1 --availability-zone us-west-1a --size 32 --volume-type gp2

us-west-1a也是我所有的kube奴才运行的可用区。)

然后我像这样创建一个持久卷:

kind: PersistentVolume
apiVersion: v1
metadata:
  name: kube-system-kube-registry-pv
  labels:
    kubernetes.io/cluster-service: "true"
spec:
  capacity:
    storage: 30Gi
  accessModes:
    - ReadWriteOnce
  awsElasticBlockStore:
    volumeID: vol-XXXXXXXX
    fsType: ext4

对持久性卷的声明如下:

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: kube-registry-pvc
  namespace: kube-system
  labels:
    kubernetes.io/cluster-service: "true"
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 30Gi

复制控制器的指定如下:

apiVersion: v1
kind: ReplicationController
metadata:
  name: kube-registry-v0
  namespace: kube-system
  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
        persistentVolumeClaim:
          claimName: kube-registry-pvc

当我创建rc时,它成功启动了一个pod,但是pod无法安装该卷:

$ kubectl describe po kube-registry --namespace=kube-system
...
Events:
  FirstSeen     LastSeen        Count   From                                                    SubobjectPath   Reason          Message
  ─────────     ────────        ─────   ────                                                    ─────────────   ──────          ───────
  1m            1m              1       {scheduler }                                                            Scheduled       Successfully assigned kube-registry-v0-3jobf to XXXXXXXXXXXXXXX.us-west-1.compute.internal
  22s           22s             1       {kubelet XXXXXXXXXXXXXXX.us-west-1.compute.internal}                    FailedMount     Unable to mount volumes for pod "kube-registry-v0-3jobf_kube-system": Timeout waiting for volume state
  22s           22s             1       {kubelet XXXXXXXXXXXXXXX.us-west-1.compute.internal}                    FailedSync      Error syncing pod, skipping: Timeout waiting for volume state

如果我不使用持久卷和持久量声明,我能够成功安装EBS卷。以下工作无误,例如:

apiVersion: v1
kind: Pod
metadata:
  name: test-ebs
spec:
  containers:
  - image: gcr.io/google_containers/test-webserver
    name: test-container
    volumeMounts:
    - mountPath: /test-ebs
      name: test-volume
  volumes:
  - name: test-volume
    awsElasticBlockStore:
      volumeID: vol-XXXXXXXX
      fsType: ext4

我的两个问题是:

  • 有谁知道可能出现的问题以及如何解决?
  • 一般来说,我在哪里可以查找有关这些错误的更多详细信息?我无法在任何地方找到更详细的日志消息,并且"无法安装卷...超时等待卷状态"并非特别有帮助。

1 个答案:

答案 0 :(得分:2)

我想我可能会遇到https://github.com/kubernetes/kubernetes/issues/15073。 (如果我创建一个新的EBS卷,我首先得到一个不同的失败,然后在pod尝试重新创建rc之后被杀死我得到了我在问题中提到的失败。)

此外,对于其他想知道在哪里查找日志的人来说,我最终需要查看kubelet上的/var/log/syslog/var/log/containers/XXX