使用构造功能启用Kubernetes功能门

时间:2018-11-28 09:06:13

标签: kubernetes tectonic-coreos

我必须为客户端部署一个tectonic的kubernetes集群,并且我需要启用kuberenetes功能门,这可能吗?

所需功能门:https://kubernetes.io/blog/2018/04/13/local-persistent-volumes-beta/

需要https://www.arangodb.com/2018/03/arangodb-operator-kubernetes-stateful-cluster-deployments/

Kubernetes版本:1.9.6(由1.9.6-tectonic.1提供)

1 个答案:

答案 0 :(得分:1)

在kubernetes 1.10之后,您无需启用功能门即可在kubernetes集群中使用本地存储。

您可以与其他任何存储类一样直接使用local-storage

请查看我以下的回答,如何在kubernetes中设置local-storage PV,PVC。

编辑:在使用kubernetes 1.9时,您可以通过以下方式做到这一点:

使用kubeadm init --config=config.yamlapiservercontroller-managerscheduler启动集群时,需要提供功能门。请参考以下配置:

 apiVersion: kubeadm.k8s.io/v1alpha1
 kind: MasterConfiguration
 apiServerExtraArgs:
   service-node-port-range: 80-32767
   feature-gates: "PersistentLocalVolumes=true,VolumeScheduling=true,MountPropagation=true"
 controllerManagerExtraArgs:
   feature-gates: "PersistentLocalVolumes=true,VolumeScheduling=true,MountPropagation=true"
 schedulerExtraArgs:
   feature-gates: "PersistentLocalVolumes=true,VolumeScheduling=true,MountPropagation=true"

然后,由于不存在本地存储类,因此您需要创建自己的存储类。因此,创建您自己的类,如下所示:

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: local-storage-data
provisioner: kubernetes.io/no-provisioner
volumeBindingMode: WaitForFirstConsumer

现在您可以通过以下方式创建PV和PVC:

PV定义:

apiVersion: v1
kind: PersistentVolume
metadata:
  name: mysql-mariadb-0
  labels:
    pod-name: mariadb-0
  annotations:
    "volume.alpha.kubernetes.io/node-affinity": '{
      "requiredDuringSchedulingIgnoredDuringExecution": {
        "nodeSelectorTerms": [
          { "matchExpressions": [
              { "key": "kubernetes.io/hostname",
                "operator": "In",
                "values": ["prod-mysql-0"]
              }
          ]}
        ]}}'
spec:
  capacity:
    storage: 2Gi
  accessModes:
  - ReadWriteOnce
  persistentVolumeReclaimPolicy: Retain
  storageClassName: local-storage-data
  local:
    path: /mnt/local-storage/mysql-data-0

PVC的定义:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  labels:
    app: mariadb
  name: mysql-mariadb-0
  namespace: mysql
spec:
  accessModes:
  - ReadWriteOnce
  resources:
    requests:
      storage: 2Gi
  storageClassName: local-storage-data
  selector:
    matchLabels:
      pod-name: mariadb-0
  

Is it possible to mount different pods to the same portion of a local persistent volume?

希望这会有所帮助