1

我有一個需要每天在Docker容器中運行的進程,將存儲桶中的一些數據同步到外部卷(Google Cloud永久磁盤)。到目前爲止,我設法通過創建單節點容器集羣來啓動該過程。Google Cloud實例上的獨立kubelet永久磁盤安裝

由於該過程在幾個小時內完成,因此一旦完成,我想刪除VM資源(當然,永久磁盤除外)。啓動/刪除單個計算虛擬機(不使用kubernetes集羣設置)似乎更簡單,因此我試圖在容器優化的雲實例上運行single kubelet永久性磁盤安裝是失敗的地方。

我發佈命令:

gcloud compute instances create cvm-name-0 \ 
    --image-family=cos-stable \ 
    --image-project=cos-cloud \ 
    --boot-disk-type pd-ssd \ 
    --boot-disk-size 10GB \ 
    --metadata-from-file \ 
    "google-container-manifest=containers.yaml,user-data=cloudinit.yaml" \ 
    --zone "$gzone" \ 
    --scopes default,storage-rw \ 
    --machine-type n1-highcpu-4 

內容的container.yaml:中cloudinit.yaml

apiVersion: v1 
kind: Pod 
metadata: 
    name: container-name 
spec: 
    containers: 
    - name: container-name 
     image: gcr.io/project-name/container-name 
     imagePullPolicy: Always 
     volumeMounts: 
     - name: persistent-disk-name 
      mountPath: /home/someuser/somedir 
    volumes: 
    - name: persistent-disk-name 
     gcePersistentDisk: 
     pdName: persistent-disk-name 
     fsType: ext4 

內容:

#cloud-config 
bootcmd: 
- echo "KUBELET_OPTS=\"--cloud-provider=gce\"" > /etc/default/kubelet 
runcmd: 
- systemctl start kubelet.service 

雖然--cloud-provider=gce選項修復了「無法取得GCE雲供應商「錯誤每this question,安裝磁盤仍然存在一些問題。

從容器操作系統日誌中潛在的相關行說:

EXT4-FS(DM-0):由於功能不兼容性

什麼辦法,使無法掛載爲ext3這項工作在單個計算實例上(沒有kubernetes集羣)?我應該在哪裏尋找更多信息錯誤日誌?

回答

0

我目前沒有使用kubernetes,但我備份到雲存儲存儲桶。

我在雲的配置是這樣的:

users: 
- name: dockerrunner 
    uid: 2000 
    groups: docker 
write_files: 
- path: /home/dockerrunner/backup-hourly.sh 
    permissions: 0755 
    owner: dockerrunner 
    content: | 
    #!/bin/sh 
    export HOME=/home/dockerrunner 
    export USER=root 
    toolbox --bind /mnt/disks/nfs:/mnt/disks/nfs \ 
     /google-cloud-sdk/bin/gsutil -m \ 
     rsync -r /mnt/disks/nfs gs://<bucket-name>/hourly 
- path: /etc/systemd/system/files-backup-hourly.service 
    permissions: 0644 
    owner: root 
    content: | 
    [Unit] 
    Description=Shared Files Backup upload script - hourly 

    [Service] 
    Type=oneshot 
    ExecStart=/bin/sh /home/dockerrunner/backup-hourly.sh 

- path: /etc/systemd/system/files-backup-hourly.timer 
    permissions: 0644 
    owner: root 
    content: | 
    [Unit] 
    Description=Run Shared Files Backup create script every hour 

    [Timer] 
    OnCalendar=*-*-* *:00:00 

    [Install] 
    WantedBy=timers.target 
runcmd: 
- systemctl daemon-reload 
- systemctl start files-backup-hourly.service 
- systemctl start files-backup-hourly.timer 
+0

這是'的gsutil rsync',得益於一個有用的例子。但是,我的具體問題是安裝GCE持久磁盤。 – Pavel