正如您在下面的 yml 配置文件中看到的那样,我已经在我的 kubernetes 集群中部署了一个 Mongodb 分片集群,并且工作正常。我按照这个文档/文章进行了设置。现在的问题是我必须增加我的 Mongodb 存储的大小,但我遇到了一些错误。非常感谢任何帮助。谢谢。
apiVersion: kubedb.com/v1alpha1
kind: MongoDB
metadata:
name: mongo-sh
namespace: mongo
spec:
version: 4.1.7
shardTopology:
configServer:
replicas: 3
storage:
resources:
requests:
storage: 1Gi #I tried to change this to 2Gi
storageClassName: fast
mongos:
replicas: 2
strategy:
type: RollingUpdate
shard:
replicas: 3
shards: 3
storage:
resources:
requests:
storage: 1Gi #I tried to change this to 2Gi
storageClassName: fast
monitor:
agent: prometheus.io/builtin
在上面的 yaml Kubedb Mongodb 部署文件中,我将存储从 1 Gi 更改为 2 Gi 并尝试再次重新应用它:kubectl apply -f kubedb-mongodb-deployment.yaml
但我收到此错误:
Error from server (BadRequest): error when applying patch:
{"metadata":{"annotations":{"kubectl.kubernetes.io/last-applied-configuration":"{\"apiVersion\":\"kubedb.com/v1alpha1\",\"kind\":\"MongoDB\",\"metadata\":{\"annotations\":{},\"name\":\"mongo-sh\",\"namespace\":\"mongo\"},\"spec\":{\"monitor\":{\"agent\":\"prometheus.io/builtin\"},\"shardTopology\":{\"configServer\":{\"replicas\":3,\"storage\":{\"resources\":{\"requests\":{\"storage\":\"2Gi\"}},\"storageClassName\":\"fast\"}},\"mongos\":{\"replicas\":2,\"strategy\":{\"type\":\"RollingUpdate\"}},\"shard\":{\"replicas\":3,\"shards\":3,\"storage\":{\"resources\":{\"requests\":{\"storage\":\"2Gi\"}},\"storageClassName\":\"fast\"}}},\"version\":\"4.1.7\"}}\n"}},"spec":{"shardTopology":{"configServer":{"storage":{"resources":{"requests":{"storage":"2Gi"}}}},"shard":{"storage":{"resources":{"requests":{"storage":"2Gi"}}}}}}}
to:
Resource: "kubedb.com/v1alpha1, Resource=mongodbs", GroupVersionKind: "kubedb.com/v1alpha1, Kind=MongoDB"
Name: "mongo-sh", Namespace: "mongo"
Object: &{map["apiVersion":"kubedb.com/v1alpha1" "kind":"MongoDB" "metadata":map["annotations":map["kubectl.kubernetes.io/last-applied-configuration":"{\"apiVersion\":\"kubedb.com/v1alpha1\",\"kind\":\"MongoDB\",\"metadata\":{\"annotations\":{},\"name\":\"mongo-sh\",\"namespace\":\"mongo\"},\"spec\":{\"monitor\":{\"agent\":\"prometheus.io/builtin\"},\"shardTopology\":{\"configServer\":{\"replicas\":3,\"storage\":{\"resources\":{\"requests\":{\"storage\":\"1Gi\"}},\"storageClassName\":\"fast\"}},\"mongos\":{\"replicas\":2,\"strategy\":{\"type\":\"RollingUpdate\"}},\"shard\":{\"replicas\":3,\"shards\":3,\"storage\":{\"resources\":{\"requests\":{\"storage\":\"1Gi\"}},\"storageClassName\":\"fast\"}}},\"version\":\"4.1.7\"}}\n"] "creationTimestamp":"2020-01-31T09:14:24Z" "finalizers":["kubedb.com"] "generation":'\x05' "name":"mongo-sh" "namespace":"mongo" "resourceVersion":"200611174" "selfLink":"/apis/kubedb.com/v1alpha1/namespaces/mongo/mongodbs/mongo-sh" "uid":"12f07f14-440a-11ea-92d9-42010a9c0fd3"] "spec":map["certificateSecret":map["secretName":"mongo-sh-keyfile"] "databaseSecret":map["secretName":"mongo-sh-auth"] "monitor":map["agent":"prometheus.io/builtin" "prometheus":map["port":'\ufffd'] "resources":map[]] "serviceTemplate":map["metadata":map[] "spec":map[]] "shardTopology":map["configServer":map["podTemplate":map["controller":map[] "metadata":map[] "spec":map["livenessProbe":map["exec":map["command":["mongo" "--eval" "db.adminCommand('ping')"]] "failureThreshold":'\x03' "periodSeconds":'\n' "successThreshold":'\x01' "timeoutSeconds":'\x05'] "readinessProbe":map["exec":map["command":["mongo" "--eval" "db.adminCommand('ping')"]] "failureThreshold":'\x03' "periodSeconds":'\n' "successThreshold":'\x01' "timeoutSeconds":'\x01'] "resources":map[] "securityContext":map["fsGroup":'\u03e7' "runAsNonRoot":%!q(bool=true) "runAsUser":'\u03e7']]] "replicas":'\x03' "storage":map["dataSource":<nil> "resources":map["requests":map["storage":"1Gi"]] "storageClassName":"fast"]] "mongos":map["podTemplate":map["controller":map[] "metadata":map[] "spec":map["livenessProbe":map["exec":map["command":["mongo" "--eval" "db.adminCommand('ping')"]] "failureThreshold":'\x03' "periodSeconds":'\n' "successThreshold":'\x01' "timeoutSeconds":'\x05'] "readinessProbe":map["exec":map["command":["mongo" "--eval" "db.adminCommand('ping')"]] "failureThreshold":'\x03' "periodSeconds":'\n' "successThreshold":'\x01' "timeoutSeconds":'\x01'] "resources":map[] "securityContext":map["fsGroup":'\u03e7' "runAsNonRoot":%!q(bool=true) "runAsUser":'\u03e7']]] "replicas":'\x02' "strategy":map["type":"RollingUpdate"]] "shard":map["podTemplate":map["controller":map[] "metadata":map[] "spec":map["livenessProbe":map["exec":map["command":["mongo" "--eval" "db.adminCommand('ping')"]] "failureThreshold":'\x03' "periodSeconds":'\n' "successThreshold":'\x01' "timeoutSeconds":'\x05'] "readinessProbe":map["exec":map["command":["mongo" "--eval" "db.adminCommand('ping')"]] "failureThreshold":'\x03' "periodSeconds":'\n' "successThreshold":'\x01' "timeoutSeconds":'\x01'] "resources":map[] "securityContext":map["fsGroup":'\u03e7' "runAsNonRoot":%!q(bool=true) "runAsUser":'\u03e7']]] "replicas":'\x03' "shards":'\x03' "storage":map["dataSource":<nil> "resources":map["requests":map["storage":"1Gi"]] "storageClassName":"fast"]]] "storageType":"Durable" "terminationPolicy":"Pause" "updateStrategy":map["type":"RollingUpdate"] "version":"4.1.7"] "status":map["observedGeneration":"4$6211945921239001045" "phase":"Running"]]}
for: "mongodb.yaml": admission webhook "mongodb.validators.kubedb.com" denied the request: precondition failed for: map[metadata:map[annotations:map[kubectl.kubernetes.io/last-applied-configuration:{"apiVersion":"kubedb.com/v1alpha1","kind":"MongoDB","metadata":{"annotations":{},"name":"mongo-sh","namespace":"mongo"},"spec":{"monitor":{"agent":"prometheus.io/builtin"},"shardTopology":{"configServer":{"replicas":3,"storage":{"resources":{"requests":{"storage":"2Gi"}},"storageClassName":"fast"}},"mongos":{"replicas":2,"strategy":{"type":"RollingUpdate"}},"shard":{"replicas":3,"shards":3,"storage":{"resources":{"requests":{"storage":"2Gi"}},"storageClassName":"fast"}}},"version":"4.1.7"}}
] generation:6] spec:map[shardTopology:map[configServer:map[storage:map[resources:map[requests:map[storage:2Gi]]]] shard:map[storage:map[resources:map[requests:map[storage:2Gi]]]]]]].At least one of the following was changed:
apiVersion
kind
name
namespace
spec.storageType
spec.storage
spec.databaseSecret
spec.certificateSecret
spec.init
spec.replicaSet.name
spec.shardTopology.*.storage
spec.shardTopology.*.prefix