简体   繁体   English

Google Cloud实例上的独立kubelet永久磁盘装载

[英]Standalone kubelet persistent disk mount on Google Cloud instance

I have a process that needs to run daily in a Docker container, syncing some data from a storage bucket to an external volume (Google Cloud persistent disk). 我有一个流程需要每天在Docker容器中运行,将一些数据从存储桶同步到外部卷(Google Cloud持久磁盘)。 So far, I managed to launch the process by creating a single-node container cluster. 到目前为止,我设法通过创建单节点容器集群来启动该过程。

Since the process completes in a couple of hours, I want to delete VM resources (except the persistent disk of course) once complete. 由于该过程在几个小时内完成,我想在完成后删除VM资源(当然除了持久性磁盘)。 Launching/deleting a single compute-VM (without the kubernetes cluster setup) seems simpler, so I was trying to get a single kubelet running on a container-optimized cloud instance. 启动/删除单个计算VM(没有kubernetes集群设置)似乎更简单,因此我试图在容器优化的云实例上运行单个kubelet Persistent disk mounting is where this fails. 永久磁盘安装是失败的地方。

My launch command: 我的启动命令:

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

Contents of container.yaml : container.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

Contents of cloudinit.yaml : cloudinit.yaml内容:

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

While the --cloud-provider=gce option fixes the "Failed to get GCE Cloud Provider" error per this question , there is still some problem mounting the disk. 虽然--cloud-provider=gce选项修复了每个问题的“无法获得GCE云提供程序”错误,但仍然存在安装磁盘的问题。

A potentially relevant line from the container OS log says: 容器操作系统日志中可能相关的行说:

EXT4-fs (dm-0): couldn't mount as ext3 due to feature incompatibilities EXT4-fs(dm-0):由于功能不兼容而无法挂载为ext3

Any way to make this work on a single compute instance (without the kubernetes cluster)? 有没有办法让这个工作在一个计算实例上(没有kubernetes集群)? Where else should I be looking for more informative error logs? 我还应该在哪里寻找更多信息错误日志?

I'm not using kubernetes at the moment, but I am backing up to a cloud storage bucket. 我目前不使用kubernetes,但我正在备份到云存储桶。

I have something like this in my cloud-config: 我的cloud-config中有类似的东西:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM