使用 helm 部署 mysql 发布

使用 helm 部署 mysql 发布

你好,我是 k8s 和 helm 生态系统的新手。

我使用 kubespray 和 EC2 构建了我自己的 k8s 集群(我可以使用 EKS,但目的是为了练习),下一步是使用 helm。

我正在尝试将 mysql 图表部署到我的 k8s 集群。

我的环境

# storage class manifest
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: local-storage
provisioner: kubernetes.io/no-provisioner
#volumeBindingMode: WaitForFirstConsumer
# values.yaml from mysql chart
## Persist data to a persistent volume
persistence:
  enabled: true
  ## database data Persistent Volume Storage Class
  ## If defined, storageClassName: <storageClass>
  ## If set to "-", storageClassName: "", which disables dynamic provisioning
  ## If undefined (the default) or set to null, no storageClassName spec is
  ##   set, choosing the default provisioner.  (gp2 on AWS, standard on
  ##   GKE, AWS & OpenStack)
  ##
  storageClass: "local-storage"  # <-- Changed this to use my own storage class
  accessMode: ReadWriteOnce
  size: 1Gi                      # <-- Changed this since only 2.5GB is available on each node
  annotations: {}
...

问题

pvc 出现错误。以下是相关日志。

ubuntu@nodec1:~/charts/stable/mysql$ kubectl describe pvc/mysqlserver
Name:          mysqlserver
Namespace:     default
StorageClass:  local-storage
Status:        Pending
Volume:
Labels:        app=mysqlserver
               app.kubernetes.io/managed-by=Helm
               chart=mysql-1.6.9
               heritage=Helm
               release=mysqlserver
Annotations:   meta.helm.sh/release-name: mysqlserver
               meta.helm.sh/release-namespace: default
Finalizers:    [kubernetes.io/pvc-protection]
Capacity:
Access Modes:
VolumeMode:    Filesystem
Mounted By:    mysqlserver-5d5cfcd5f8-922k4
Events:
  Type     Reason              Age               From                         Message
  ----     ------              ----              ----                         -------
  Warning  ProvisioningFailed  6s (x3 over 21s)  persistentvolume-controller  no volume plugin matched name: kubernetes.io/no-provisioner

我不知道为什么 pvc 不能使用kubernetes.io/no-provisioner我自己的local-storage存储类中的插件。有人能帮忙解决这个问题吗?

答案1

此错误意味着由于您没有使用动态卷配置器(它会自动为您创建卷),因此您需要自己创建此卷

查看 k8s 文档以获取如何操作的示例: https://kubernetes.io/docs/concepts/storage/volumes/#local

为了快速测试并检查这是否是问题,您可以应用以下 yaml:

apiVersion: v1
kind: PersistentVolume
metadata:
  name: example-pv
spec:
  capacity:
    storage: 10Gi
  volumeMode: Filesystem
  accessModes:
  - ReadWriteOnce
  persistentVolumeReclaimPolicy: Delete
  storageClassName: local-storage
  local:
    path: /mnt/asd
  nodeAffinity:
    required:
      nodeSelectorTerms:
      - matchExpressions:
        - key: kubernetes.io/hostname
          operator: Exist

相关内容