【问题标题】:Installing database in Kubernetes在 Kubernetes 中安装数据库
【发布时间】:2021-04-13 17:23:03
【问题描述】:

我正在尝试使用 Rancher 安装 CockroachDB,但遇到了一些问题,显示:

FailedBinding (5)   14 sec ago  no persistent volumes available for this claim and no storage class is set

如何解决?

这是我本地机器上的配置:

PersistentVolumeClaim:datadir-cockroachdb-0

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  creationTimestamp: "2021-01-07T23:50:42Z"
  finalizers:
  - kubernetes.io/pvc-protection
  labels:
    app.kubernetes.io/component: cockroachdb
    app.kubernetes.io/instance: cockroachdb
    app.kubernetes.io/name: cockroachdb
  managedFields:
  - apiVersion: v1
    fieldsType: FieldsV1
    fieldsV1:
      f:metadata:
        f:labels:
          .: {}
          f:app.kubernetes.io/component: {}
          f:app.kubernetes.io/instance: {}
          f:app.kubernetes.io/name: {}
      f:spec:
        f:accessModes: {}
        f:resources:
          f:requests:
            .: {}
            f:storage: {}
        f:volumeMode: {}
      f:status:
        f:phase: {}
    manager: k3s
    operation: Update
    time: "2021-01-07T23:50:41Z"
  name: datadir-cockroachdb-0
  namespace: default
  resourceVersion: "188922"
  selfLink: /api/v1/namespaces/default/persistentvolumeclaims/datadir-cockroachdb-0
  uid: ef83d3c7-0309-44a8-b379-0134835d97a9
spec:
  accessModes:
  - ReadWriteOnce
  resources:
    requests:
      storage: 100Gi
  volumeMode: Filesystem
status:
  phase: Pending

CockroachDB

clusterDomain: cluster.local
conf:
  attrs: []
  cache: 25%
  cluster-name: ''
  disable-cluster-name-verification: false
  http-port: 8080
  join: []
  locality: ''
  logtostderr: INFO
  max-disk-temp-storage: 0
  max-offset: 500ms
  max-sql-memory: 25%
  port: 26257
  single-node: false
  sql-audit-dir: ''
image:
  credentials: {}
  pullPolicy: IfNotPresent
  repository: cockroachdb/cockroach
  tag: v20.1.3
ingress:
  annotations: {}
  enabled: false
  hosts: []
  labels: {}
  paths:
    - /
  tls: []
init:
  affinity: {}
  annotations: {}
  labels:
    app.kubernetes.io/component: init
  nodeSelector: {}
  resources: {}
  tolerations: []
labels: {}
networkPolicy:
  enabled: false
  ingress:
    grpc: []
    http: []
service:
  discovery:
    annotations: {}
    labels:
      app.kubernetes.io/component: cockroachdb
  ports:
    grpc:
      external:
        name: grpc
        port: 26257
      internal:
        name: grpc-internal
        port: 26257
    http:
      name: http
      port: 8080
  public:
    annotations: {}
    labels:
      app.kubernetes.io/component: cockroachdb
    type: ClusterIP
statefulset:
  annotations: {}
  args: []
  budget:
    maxUnavailable: 1
  env: []
  labels:
    app.kubernetes.io/component: cockroachdb
  nodeAffinity: {}
  nodeSelector: {}
  podAffinity: {}
  podAntiAffinity:
    type: soft
    weight: 100
  podManagementPolicy: Parallel
  priorityClassName: ''
  replicas: 3
  resources: {}
  secretMounts: []
  tolerations: []
  updateStrategy:
    type: RollingUpdate
storage:
  hostPath: ''
  persistentVolume: volume1
    annotations: {}
    enabled: true
    labels: {}
    size: 1Gi
    storageClass: local-storage ''
tls:
  certs:
    clientRootSecret: cockroachdb-root
    nodeSecret: cockroachdb-node
    provided: false
    tlsSecret: false
  enabled: false
  init:
    image:
      credentials: {}
      pullPolicy: IfNotPresent
      repository: cockroachdb/cockroach-k8s-request-cert
      tag: '0.4'
  serviceAccount:
    create: true
    name: ''
Storage: 1Gi

持久卷

apiVersion: v1
kind: PersistentVolume
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: '{"apiVersion":"v1","kind":"PersistentVolume","metadata":{"annotations":{},"labels":{"type":"local"},"name":"volume1"},"spec":{"accessModes":["ReadWriteOnce"],"capacity":{"storage":"10Gi"},"hostPath":{"path":"/data/volume1"}}}'
  creationTimestamp: "2021-01-07T23:11:43Z"
  finalizers:
  - kubernetes.io/pv-protection
  labels:
    type: local
  managedFields:
  - apiVersion: v1
    fieldsType: FieldsV1
    fieldsV1:
      f:status:
        f:phase: {}
    manager: k3s
    operation: Update
    time: "2021-01-07T23:11:43Z"
  - apiVersion: v1
    fieldsType: FieldsV1
    fieldsV1:
      f:metadata:
        f:annotations: {}
        f:labels:
          .: {}
          f:type: {}
      f:spec:
        f:accessModes: {}
        f:capacity: {}
        f:hostPath:
          .: {}
          f:path: {}
          f:type: {}
        f:persistentVolumeReclaimPolicy: {}
        f:volumeMode: {}
    manager: kubectl
    operation: Update
    time: "2021-01-07T23:11:43Z"
  - apiVersion: v1
    fieldsType: FieldsV1
    fieldsV1:
      f:metadata:
        f:annotations:
          f:kubectl.kubernetes.io/last-applied-configuration: {}
      f:spec:
        f:capacity:
          f:storage: {}
    manager: Go-http-client
    operation: Update
    time: "2021-01-07T23:12:11Z"
  name: volume1
  resourceVersion: "173783"
  selfLink: /api/v1/persistentvolumes/volume1
  uid: 6e76984c-22cd-4219-9ff6-ba7f67c1ca72
spec:
  accessModes:
  - ReadWriteOnce
  capacity:
    storage: 4Gi
  hostPath:
    path: /data/volume1
    type: ""
  persistentVolumeReclaimPolicy: Retain
  volumeMode: Filesystem
status:
  phase: Available

存储类

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  creationTimestamp: "2021-01-07T23:29:17Z"
  managedFields:
  - apiVersion: storage.k8s.io/v1
    fieldsType: FieldsV1
    fieldsV1:
      f:provisioner: {}
      f:reclaimPolicy: {}
      f:volumeBindingMode: {}
    manager: rancher
    operation: Update
    time: "2021-01-07T23:29:17Z"
  name: local-storage
  resourceVersion: "180190"
  selfLink: /apis/storage.k8s.io/v1/storageclasses/local-storage
  uid: 0a5f8b75-7fb5-4965-91ee-91b0a087339a
provisioner: kubernetes.io/no-provisioner
reclaimPolicy: Delete
volumeBindingMode: WaitForFirstConsumer

【问题讨论】:

    标签: kubernetes rancher cockroachdb


    【解决方案1】:

    看来这次是 Rancher 的问题(感谢@Harsh Manvar 的回答)。如果您对 CockroachDB 有更多疑问,还可以加入 CockroachDB 社区 slack 频道,在这里您会找到大量专家,他们可以及时回答您的问题。 (并且一定要加入#community 频道来获得一些乐趣!):) https://go.crdb.dev/p/slack

    【讨论】:

      【解决方案2】:

      根据提供的详细信息,您的存储类似乎在 Rancher 上丢失了。

      如果没有存储类,则不会创建相应的 PVC,因此会出错。存储类别可能会随着云提供商以及磁盘 SSD、HDD 类型的要求而改变。

      你可以得到更多的想法:https://rancher.com/docs/rancher/v2.x/en/cluster-admin/volumes-and-storage/provisioning-new-storage/

      首先检查您的 PV 是否可用,然后检查存储类和 PVC。

      【讨论】:

      • @quarks rancher 在裸机或哪个云提供商上运行?
      • storageclass local-path Provisioner,这使得能够使用相应节点上的本地存储开箱即用地创建持久卷声明,但如果有任何云提供商,它不会创建任何磁盘。
      • 您可以看到所有存储类配置的列表可能因本地部署和任何云提供商部署或裸机而不同。 rancher.com/docs/rancher/v2.x/en/cluster-admin/…
      • 您的 pvc 为 100 GB,因此可能动态配置它会自动创建它。尝试删除相应的 pvc 和 pv 或更改不同的名称。
      • 另外,我试过这个:kubectl apply -f https://raw.githubusercontent.com/rancher/local-path-provisioner/master/deploy/local-path-storage.yaml 但它等待了很长时间bash kubectl -n local-path-storage get pod NAME READY STATUS RESTARTS AGE local-path-provisioner-5b577f66ff-qp79p 0/1 Pending 0 10m
      猜你喜欢
      • 2016-10-26
      • 1970-01-01
      • 2020-01-10
      • 2022-01-17
      • 2015-09-25
      • 2022-01-09
      • 2015-11-27
      • 1970-01-01
      • 2020-02-17
      相关资源
      最近更新 更多