2016-10-01 51 views
1

我有谷歌雲容器引擎設置。我想用外部音量旋轉mysql的pod。無法使用外部卷在kubernetes中運行mysql pod

ReplicationController:

apiVersion: v1 
kind: ReplicationController 
metadata: 
    labels: 
    name: mysql 
    name: mysql-controller 
spec: 
    replicas: 1 
    template: 
    metadata: 
     labels: 
     name: mysql 
    spec: 
     containers: 
     - image: mysql 
      name: mysql 
      ports: 
      - name: mysql 
      containerPort: 3306 
      hostPort: 3306 
      volumeMounts: 
      - name: mysql-persistent-storage 
       mountPath: /var/lib/mysql 
     volumes: 
     - name: mysql-persistent-storage 
      gcePersistentDisk: 
      pdName: mysql-1-disk 
      fsType: ext4 

當我運行RC without外部卷,MySQL的正常工作。它下面的錯誤打破了,當我嘗試將音量

Kubernetes POD錯誤:

Warning FailedSyncError syncing pod, skipping: failed to "StartContainer" for "mysql" with CrashLoopBackOff: "Back-off 20s restarting failed container=mysql pod=mysql-controller-4hhqs_default(eb34ff46-8784-11e6-8f12-42010af00162)" 

盤(外部音量): mysql-1-disk是谷歌雲盤。我試圖用blank diskimage - ubuntu創建磁盤。兩者都失敗了同樣的錯誤。

+0

你解決了這個問題嗎?在GCE上運行mysql時,我的結果完全相同 – VsMaX

回答

0

從我的角度來看,掛載永久磁盤上的錯誤消息實際上並不具有描述性。根據您的配置文件使用空白磁盤。

有些事情要檢查:

  • 是在pdName完全一樣,在你的CGE環境
  • 是在同一個可用性區域的磁盤(如歐洲west1-C)爲您的集羣,否則無法安裝。

希望這會有所幫助。

0

您面臨的問題可能是由於使用RC而不是Pod與Persistent Disk交互引起的。

由於它在documentation提及真實:

A feature of PD is that they can be mounted as read-only by multiple consumers simultaneously. This means that you can pre-populate a PD with your dataset and then serve it in parallel from as many pods as you need. Unfortunately, PDs can only be mounted by a single consumer in read-write mode - no simultaneous writers allowed. Using a PD on a pod controlled by a ReplicationController will fail unless the PD is read-only or the replica count is 0 or 1.

在這種情況下,我建議你與永久磁盤定義在波德配置文件的磁盤連接運行MySQL。您可能會發現示例配置here

+0

他使用的複製數爲1的RC,所以他使用RC很好。我一直比較喜歡RC上面的一個RC,因爲RC下來時重新啓動,而pod不是。 –