ansible-collections / community.kubernetes

Kubernetes Collection for Ansible
https://galaxy.ansible.com/community/kubernetes
GNU General Public License v3.0
265 stars 106 forks source link

How to install a storageClass using this collection? #381

Closed spotlesscoder closed 3 years ago

spotlesscoder commented 3 years ago
SUMMARY

After deploying a new cluster with kubespray, it has no storageClasses at all and I want to use ansible to provision a default storageClass.

ISSUE TYPE
COMPONENT NAME
ANSIBLE VERSION
ansible 2.9.17
  config file = /home/user/Code/github.com/codingspiderfox/nas-config/hp-microserver-gen10-plus-ip-192-168-3-103/ansible/3rdparty/kubespray/ansible.cfg
  configured module search path = ['/home/user/Code/github.com/codingspiderfox/nas-config/hp-microserver-gen10-plus-ip-192-168-3-103/ansible/3rdparty/kubespray/library']
  ansible python module location = /usr/local/lib/python3.6/dist-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 3.6.9 (default, Oct  8 2020, 12:12:24) [GCC 8.4.0]
CONFIGURATION
should not be relevant here
OS / ENVIRONMENT

Ubuntu 20.04

STEPS TO REPRODUCE

See kubespray documentation for setting up kubespray

EXPECTED RESULTS

StorageClass is available in cluster

ACTUAL RESULTS

I can find nothing in the collection that would allow me to do that

geerlingguy commented 3 years ago

@CodingSpiderFox - Typically you'd do that by deploying a StorageClass object / manifest using the module. The way a specific StorageClass is configured is very vendor/provider-specific. But in general, it is deployed using k8s just like any other resource in Kubernetes.

Akasurde commented 3 years ago

@CodingSpiderFox Like @geerlingguy said -

---
- hosts: localhost
  tasks:
    - name: Create a storage class
      community.kubernetes.k8s:
        state: present
        definition:
          apiVersion: storage.k8s.io/v1
          kind: StorageClass
          metadata:
            name: local-storage
            namespace: default
          provisioner: kubernetes.io/no-provisioner
          volumeBindingMode: WaitForFirstConsumer

Closed as per above.

Akasurde commented 3 years ago

Feel free to open a new issue if there is any problem. Thanks.

spotlesscoder commented 3 years ago

Sorry, was very busy with other things, I will open a new issue in case there is a further problem