In diesem Thema wird erläutert, wie Sie zusätzliche Volumes für eine mit Migrate for Anthos migrierte Arbeitslast bereitstellen. Dies kann sinnvoll sein, wenn die Arbeitslast von einem externen Volume abhängt, das nicht in ein nichtflüchtiges Volume kopiert wird.
So fügen Sie einer Migrate for Anthos-Arbeitslast externe Volumes hinzu:
- Fügen Sie das Volume dem
StatefulSet
inspec.containers.volumeMounts
hinzu. Weitere Informationen finden Sie unter Kubernetes-Volumes. - Stellen Sie das Volume am gewünschten Bereitstellungspunkt im Container bereit. Dieser variiert je nach Betriebssystem des Containers.
Im folgenden Beispiel wird das Volume emptydir
in /tmp
bereitgestellt.
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