掛接外部磁碟區
本主題說明如何將額外磁區掛載至透過「遷移至容器」遷移的工作負載。如果工作負載依賴未複製至永久磁碟區的外部磁碟區,您可能需要執行這項操作。
如要將外部磁碟區新增至 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 工作負載部署至目標叢集。