我有一个流程需要每天在Docker容器中运行,将一些数据从存储桶同步到外部卷(Google Cloud永久磁盘)。到目前为止,我设法通过创建单节点容器集群来启动该过程。
由于该过程在几个小时内完成,我想在完成后删除VM资源(当然除了持久性磁盘)。启动/删除单个计算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
的内容:
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
cloudinit.yaml
的内容:
#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 :(得分:0)
我目前没有使用kubernetes,但我正在备份到云存储桶。
我的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