chemtech
@chemtech
Линуксойд, DevOps

Как заставить использовать приложение storageclass local-storage?

Добрый день!
Делаю по статье
https://scalablesystem.design/ds101/kubernetes-ins...

Версия Kubernetes - 1.12
git clone https://github.com/kubernetes-incubator/kubespray.git
cd kubespray
cp -rfp inventory/sample inventory/mycluster
cd inventory/mycluster/
declare -a IPS=(10.233.60.232 10.233.60.226 10.233.60.240)
CONFIG_FILE=inventory/mycluster/hosts.ini python3 contrib/inventory_builder/inventory.py ${IPS[@]}
pip install -r requirements.txt

Добавляем в конец файла inventory/mycluster/group_vars/k8s-cluster.yml
helm_version: "v2.9.1"
helm_enabled: true
docker_dns_servers_strict: no
kubeconfig_localhost: true
local_volume_provisioner_enabled: true
local_volume_provisioner_base_dir: /mnt/disks
local_volume_provisioner_mount_dir: /mnt/disks
local_volume_provisioner_storage_class: local-storage

ansible-playbook -u apatsev -i inventory/mycluster/hosts.ini cluster.yml -b
Проверяем наличие StorageClass
kubectl --kubeconfig inventory/mycluster/artifacts/admin.conf get storageclass
NAME            PROVISIONER                    AGE
local-storage   kubernetes.io/no-provisioner   2m

Перехожу на уровень выше
cd ..

Создадим тестовый pod с диском:
cat << EOF > test_pod.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: claim1
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi
---
apiVersion: v1
kind: Pod
metadata:
  name: test-pod-with-pvc
spec:
  volumes:
    - name: test-pvc-storage
      persistentVolumeClaim:
        claimName: claim1
  containers:
    - name: test-container
      image: kubernetes/pause
      volumeMounts:
       - name: test-pvc-storage
         mountPath: /var/lib/www/html
EOF
kubectl --kubeconfig kubespray/inventory/mycluster/artifacts/admin.conf  create -f test_pod.yaml


получаем вот такой вывод
persistentvolumeclaim/claim1 created
pod/test-pod-with-pvc created


Смотрим статус пода

kubectl --kubeconfig kubespray/inventory/mycluster/artifacts/admin.conf describe pod test-pod-with-pvc
Name:               test-pod-with-pvc
Namespace:          default
Priority:           0
PriorityClassName:  <none>
Node:               <none>
Labels:             <none>
Annotations:        <none>
Status:             Pending
IP:                 
Containers:
  test-container:
    Image:        kubernetes/pause
    Port:         <none>
    Host Port:    <none>
    Environment:  <none>
    Mounts:
      /var/lib/www/html from test-pvc-storage (rw)
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-jm8rk (ro)
Conditions:
  Type           Status
  PodScheduled   False 
Volumes:
  test-pvc-storage:
    Type:       PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
    ClaimName:  claim1
    ReadOnly:   false
  default-token-jm8rk:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-jm8rk
    Optional:    false
QoS Class:       BestEffort
Node-Selectors:  <none>
Tolerations:     node.kubernetes.io/not-ready:NoExecute for 300s
                 node.kubernetes.io/unreachable:NoExecute for 300s
Events:
  Type     Reason            Age               From               Message
  ----     ------            ----              ----               -------
  Warning  FailedScheduling  2m (x25 over 4m)  default-scheduler  pod has unbound immediate PersistentVolumeClaims (repeated 3 times)


kubectl --kubeconfig kubespray/inventory/mycluster/artifacts/admin.conf get pvc
NAME      STATUS    VOLUME    CAPACITY   ACCESS MODES   STORAGECLASS   AGE
claim1    Pending                                                      116m


Как заставить использовать приложение storageclass local-storage ?
  • Вопрос задан
  • 3299 просмотров
Решения вопроса 1
chemtech
@chemtech Автор вопроса
Линуксойд, DevOps
Делаем по этой статье
https://kubernetes.io/docs/tasks/configure-pod-con...
Но везде storageClassName меняем на нужный - в данном случае local-storage
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы