56 lines
1.3 KiB
YAML
56 lines
1.3 KiB
YAML
- name: Ensure local path dir
|
|
file:
|
|
path: "{{ local_path_dir }}"
|
|
state: directory
|
|
mode: '0777'
|
|
|
|
- name: StorageClass local-ssd-hetzner
|
|
copy:
|
|
dest: /root/local-sc.yaml
|
|
content: |
|
|
apiVersion: storage.k8s.io/v1
|
|
kind: StorageClass
|
|
metadata:
|
|
name: {{ local_sc_name }}
|
|
provisioner: kubernetes.io/no-provisioner
|
|
volumeBindingMode: WaitForFirstConsumer
|
|
when: inventory_hostname in groups['k8s_control_plane']
|
|
|
|
- name: Apply SC
|
|
command: kubectl apply -f /root/local-sc.yaml
|
|
environment:
|
|
KUBECONFIG: /etc/kubernetes/admin.conf
|
|
when: inventory_hostname in groups['k8s_control_plane']
|
|
|
|
- name: Create local-path directory
|
|
file:
|
|
path: /mnt/local-ssd
|
|
state: directory
|
|
mode: '0755'
|
|
|
|
- name: Create subdirectories for each PV
|
|
file:
|
|
path: "/mnt/local-ssd/{{ item }}"
|
|
state: directory
|
|
mode: '0755'
|
|
loop:
|
|
- postgres
|
|
- prometheus
|
|
- elasticsearch
|
|
- grafana
|
|
|
|
- name: Copy PV manifest
|
|
template:
|
|
src: local-ssd-pv.yaml
|
|
dest: /tmp/local-ssd-pv.yaml
|
|
|
|
- name: Apply PV
|
|
command: kubectl apply -f /tmp/local-ssd-pv.yaml
|
|
run_once: true
|
|
delegate_to: "{{ groups['k8s_control_plane'][0] }}"
|
|
|
|
- name: Apply SC
|
|
command: kubectl apply -f /tmp/local-ssd-sc.yaml
|
|
run_once: true
|
|
delegate_to: "{{ groups['k8s_control_plane'][0] }}"
|