我正在尝试使用 gcs 存储桶作为 gke pod 中的卷 [英] I am trying to use gcs bucket as the volume in gke pod
本文介绍了我正在尝试使用 gcs 存储桶作为 gke pod 中的卷的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我收到错误:
验证mysql.yaml"时出错:验证数据时出错:ValidationError(Deployment.spec.template.spec.volumes[0]):未知io.k8s.kubernetes.pkg.api.v1.Volume 中的路径"字段;)
error validating "mysql.yaml": error validating data: ValidationError(Deployment.spec.template.spec.volumes[0]): unknown field "path" in io.k8s.kubernetes.pkg.api.v1.Volume; )
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: mysql
labels:
app: mysql
spec:
replicas: 1
selector:
matchLabels:
app: mysql
template:
metadata:
labels:
app: mysql
spec:
containers:
- image: mysql:5.6
name: mysql
env:
- name: MYSQL_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: mysql
key: password
ports:
- containerPort: 3306
name: mysql
volumeMounts:
- name: mapping-sandbox-test
mountPath: /var/lib/mysql
volumes:
- name: mapping-sandbox-test
path: gs://<bucket-name>
推荐答案
使用名称和路径作为键,您的部署对象看起来是正确的.您可以在此处查看如何在 kubernetes 上挂载 GCS 存储桶的示例
Your Deployment object looks correct using name and path as keys. You can see an example on how to mount a GCS bucket on kubernetes here
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: gcsfuse-test
spec:
replicas: 1
template:
metadata:
labels:
app: gcsfuse-test
spec:
containers:
- name: gcsfuse-test
image: gcr.io/some-repo/gcs-fuse:latest
securityContext:
privileged: true
capabilities:
add:
- SYS_ADMIN
lifecycle:
postStart:
exec:
command: ["gcsfuse", "-o", "nonempty", "some-bucket", "/mnt/some-bucket"]
preStop:
exec:
command: ["fusermount", "-u", "/mnt/some-bucket"]
这篇关于我正在尝试使用 gcs 存储桶作为 gke pod 中的卷的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文