main.yml 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. # Copyright 2020 Dell Inc. or its subsidiaries. All Rights Reserved.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. ---
  15. - name: Wait for CoreDNS to restart
  16. command: kubectl rollout status deployment/coredns -n kube-system
  17. changed_when: false
  18. ignore_errors: True
  19. tags: init
  20. - name: Get K8s pods
  21. command: kubectl get pods --all-namespaces
  22. changed_when: false
  23. register: k8s_pods
  24. tags: init
  25. - name: Deploy MetalLB
  26. command: "kubectl apply -f '{{ metallb_yaml_url }}'"
  27. changed_when: true
  28. when: "'metallb' not in k8s_pods.stdout"
  29. tags: init
  30. - name: Create MetalLB Setup Config Files
  31. copy:
  32. src: metal-config.yaml
  33. dest: "{{ metallb_config_file_dest }}"
  34. owner: root
  35. group: root
  36. mode: "{{ metallb_config_file_mode }}"
  37. tags: init
  38. - name: Create MetalLB Setup Deployment Files
  39. copy:
  40. src: metallb.yaml
  41. dest: "{{ metallb_deployment_file_dest }}"
  42. owner: root
  43. group: root
  44. mode: "{{ metallb_deployment_file_mode }}"
  45. tags: init
  46. - name: Deploy MetalLB
  47. command: "kubectl apply -f '{{ metallb_deployment_file_dest }}'"
  48. changed_when: true
  49. when: "'metallb' not in k8s_pods.stdout"
  50. tags: init
  51. - name: Create default setup for MetalLB
  52. command: "kubectl apply -f '{{ metallb_config_file_dest }}'"
  53. changed_when: true
  54. when: "'metallb' not in k8s_pods.stdout"
  55. tags: init
  56. - name: Start k8s dashboard
  57. command: "kubectl create -f '{{ k8s_dashboard_yaml_url }}'"
  58. changed_when: true
  59. when: "'kubernetes-dashboard' not in k8s_pods.stdout"
  60. tags: init
  61. - name: Copy k8s_dashboard_admin.yml file
  62. copy:
  63. src: k8s_dashboard_admin.yaml
  64. dest: "{{ k8s_dashboard_admin_file_dest }}"
  65. owner: root
  66. group: root
  67. mode: "{{ k8s_dashboard_admin_file_mode }}"
  68. - name: Create admin user for K8s dashboard
  69. command: "kubectl apply -f {{ k8s_dashboard_admin_file_dest }}"
  70. changed_when: true
  71. - name: Helm - add stable repo
  72. command: "helm repo add stable '{{ helm_stable_repo_url }}'"
  73. changed_when: true
  74. tags: init
  75. - name: Helm - add Nvidia k8s-device-plugin (nvdp) repo
  76. command: "helm repo add nvdp '{{ nvidia_k8s_device_plugin_repo_url }}'"
  77. changed_when: true
  78. tags: init
  79. - name: Helm - add Nvidia GPU discovery (nvgfd) repo
  80. command: "helm repo add nvgfd '{{ nvidia_gpu_discovery_repo_url }}'"
  81. changed_when: true
  82. tags: init
  83. - name: Helm - update repo
  84. command: helm repo update
  85. changed_when: true
  86. tags: init
  87. - name: Start NFS Client Provisioner
  88. command: "helm install stable/nfs-client-provisioner --set nfs.server='{{ nfs_server }}' --set nfs.path='{{ nfs_path }}' --generate-name"
  89. changed_when: true
  90. when: "'nfs-client-provisioner' not in k8s_pods.stdout"
  91. tags: init
  92. - name: Set NFS-Client Provisioner as DEFAULT StorageClass
  93. shell: >
  94. kubectl patch storageclasses.storage.k8s.io nfs-client \
  95. -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'
  96. changed_when: true
  97. tags: init
  98. - name: Check if prometheus is installed on the host
  99. stat:
  100. path: "{{ prometheus_path_on_host }}"
  101. register: prometheus_status
  102. changed_when: False
  103. ignore_errors: yes
  104. tags: init
  105. - name: Delete prometheus installed on host if it exists
  106. file:
  107. path: "{{ prometheus_path_on_host }}"
  108. state: absent
  109. when: prometheus_status.stat.exists
  110. tags: init
  111. - name: Copy the slurm exporter config file
  112. copy:
  113. src: "{{ slurm_exporter_config_file }}"
  114. dest: "{{ slurm_exporter_config_file_path }}"
  115. owner: root
  116. group: root
  117. mode: "{{ slurm_exporter_file_mode }}"
  118. tags: init
  119. - name: Fetch the public IP of the host
  120. shell: >
  121. set -o pipefail && \
  122. ip route get 8.8.8.8 | awk '{print $7}'
  123. register: public_ip
  124. changed_when: False
  125. tags: init
  126. - name: Add the host IP to config file
  127. replace:
  128. path: "{{ slurm_exporter_config_file_path }}{{ slurm_exporter_config_file }}"
  129. regexp: "localhost"
  130. replace: "{{ public_ip.stdout }}"
  131. tags: init
  132. - name: Prometheus deployment
  133. command: >
  134. helm install stable/prometheus \
  135. --set-file extraScrapeConfigs="{{ slurm_exporter_config_file_path }}{{ slurm_exporter_config_file }}" \
  136. --set alertmanager.persistentVolume.storageClass=nfs-client,server.persistentVolume.storageClass=nfs-client,server.service.type=LoadBalancer \
  137. --generate-name
  138. changed_when: true
  139. when: "'prometheus' not in k8s_pods.stdout"
  140. tags: init
  141. - name: Install MPI Operator
  142. command: "kubectl create -f '{{ mpi_operator_yaml_url }}'"
  143. changed_when: true
  144. when: "'mpi-operator' not in k8s_pods.stdout"
  145. tags: init
  146. - name: Install nvidia-device-plugin
  147. command: "helm install --version='{{ nvidia_device_plugin_version }}' --generate-name --set migStrategy='{{ mig_strategy }}' nvdp/nvidia-device-plugin"
  148. changed_when: true
  149. when: "'nvidia-device-plugin' not in k8s_pods.stdout"
  150. tags: init
  151. - name: Install GPU Feature Discovery
  152. command: "helm install --version='{{ gpu_feature_discovery_version }}' --generate-name --set migStrategy='{{ mig_strategy }}' nvgfd/gpu-feature-discovery"
  153. changed_when: true
  154. when: "'node-feature-discovery' not in k8s_pods.stdout"
  155. tags: init
  156. - name: Deploy Xilinx Device plugin
  157. command: "kubectl create -f '{{ fpga_device_plugin_yaml_url }}'"
  158. changed_when: true
  159. register: fpga_enable
  160. when: "'fpga-device-plugin' not in k8s_pods.stdout"
  161. tags: init
  162. - name: Deploy ROCm Device plugin
  163. command: "kubectl create -f '{{ rocm_device_plugin_yaml_url }}'"
  164. changed_when: true
  165. register: amd_gpu_enable
  166. when: "'amdgpu-device-plugin' not in k8s_pods.stdout"
  167. tags: init
  168. - name: Install Spark Operator
  169. command: "helm repo add spark-operator '{{ spark_operator_repo }}'"
  170. changed_when: true
  171. tags: init
  172. - name: Install Spark Operator Namespace
  173. command: "helm install my-release spark-operator/spark-operator --namespace spark-operator --create-namespace"
  174. changed_when: true
  175. when: "'spark-operator' not in k8s_pods.stdout"
  176. tags: init
  177. - name: Deploy Volcano Scheduling
  178. command: "kubectl apply -f '{{ volcano_scheduling_yaml_url }}'"
  179. changed_when: true
  180. when: "'volcano-system' not in k8s_pods.stdout"
  181. tags: init