装载外部卷
本主题说明如何将其他卷装载到使用 Migrate to Containers 迁移的工作负载。如果您的工作负载依赖于未复制到永久性卷的外部卷,则可能需要执行此操作。
如需将外部卷添加到 Migrate to Containers 工作负载,请执行以下操作:
- 将卷添加到
spec.containers.volumeMounts
中的StatefulSet
。如需了解详情,请参阅 Kubernetes 卷。 - 将容器中的卷装载到您所需的装载点。这取决于容器的操作系统。
以下示例将卷 emptydir
装载到 /tmp
。
apiVersion: apps/v1
kind: StatefulSet
metadata:
creationTimestamp: null
labels:
app: app-my-vm-instance-1
migrate-for-anthos-type: workload
name: app-my-vm-instance-1
spec:
replicas: 1
selector:
matchLabels:
app: app-my-vm-instance-1
migrate-for-anthos-type: workload
serviceName: app-my-vm-instance-1
template:
metadata:
creationTimestamp: null
labels:
app: app-my-vm-instance-1
migrate-for-anthos-type: workload
spec:
containers:
- image: gcr.io/my-project/my-vm-instance-1:v1.0.0
name: app-my-vm-instance-1
readinessProbe:
exec:
command:
- /code/ready.sh
resources: {}
securityContext:
privileged: true
volumeMounts:
- name: emptydir
mountPath: /tmp
- mountPath: /sys/fs/cgroup
name: cgroups
- mountPath: /code/config/logs/
name: logs-config
- mountPath: /<folder>
name: pvc-my-vm-instance-1
subPath: <folder>
volumes:
- name: emptydir
emptyDir: {}
- hostPath:
path: /sys/fs/cgroup
type: Directory
name: cgroups
- configMap:
name: app-my-vm-instance-1
name: logs-config
- name: pvc-my-vm-instance-1
persistentVolumeClaim:
claimName: pvc-my-vm-instance-1
updateStrategy: {}
status:
replicas: 0
后续步骤
- 了解如何将 Linux 工作负载部署到目标集群。