deploy_k8s_services.yml 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. # Copyright 2022 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: Include common variables
  16. include_vars: ../../slurm_exporter/vars/main.yml
  17. - name: Include k8s_nfs_server_setup variables
  18. include_vars: ../../k8s_nfs_server_setup/vars/main.yml
  19. - name: Include powervault_me4_nfs variables
  20. include_vars: ../../powervault_me4_nfs/vars/main.yml
  21. - name: Wait for CoreDNS to restart
  22. command: kubectl rollout status deployment/coredns -n kube-system --timeout=5m
  23. changed_when: false
  24. failed_when: false
  25. tags: init
  26. - name: Get K8s pods
  27. command: kubectl get pods --all-namespaces
  28. changed_when: false
  29. register: k8s_pods
  30. tags: init
  31. - name: Get metallb repo
  32. command: "helm repo add metallb '{{ metallb_helm_url }}'"
  33. changed_when: false
  34. tags: init
  35. - name: Create MetalLB Setup Config Files
  36. copy:
  37. src: metal-config.yaml
  38. dest: "{{ metallb_config_file_dest }}"
  39. owner: root
  40. group: root
  41. mode: "{{ metallb_config_file_mode }}"
  42. tags: init
  43. - name: Create MetalLB Setup Deployment Files
  44. copy:
  45. src: metallb.yaml
  46. dest: "{{ metallb_deployment_file_dest }}"
  47. owner: root
  48. group: root
  49. mode: "{{ metallb_deployment_file_mode }}"
  50. tags: init
  51. - name: Deploy Metallb
  52. command: "helm install metallb metallb/metallb -f '{{ metallb_config_file_dest }}'"
  53. changed_when: false
  54. tags: init
  55. - name: Start k8s dashboard
  56. command: "kubectl create -f '{{ k8s_dashboard_yaml_url }}'"
  57. changed_when: true
  58. when: "'kubernetes-dashboard' not in k8s_pods.stdout"
  59. tags: init
  60. - name: Copy k8s_dashboard_admin.yml file
  61. copy:
  62. src: k8s_dashboard_admin.yaml
  63. dest: "{{ k8s_dashboard_admin_file_dest }}"
  64. owner: root
  65. group: root
  66. mode: "{{ k8s_dashboard_admin_file_mode }}"
  67. - name: Create admin user for K8s dashboard
  68. command: "kubectl apply -f {{ k8s_dashboard_admin_file_dest }}"
  69. changed_when: true
  70. - name: Helm - add stable repo
  71. command: "helm repo add stable '{{ helm_stable_repo_url }}'"
  72. changed_when: true
  73. tags: init
  74. - name: Helm - add Nvidia k8s-device-plugin (nvdp) repo
  75. command: "helm repo add nvdp '{{ nvidia_k8s_device_plugin_repo_url }}'"
  76. changed_when: true
  77. when: ansible_local.inventory.nvidia_gpu > 0
  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. when: ansible_local.inventory.nvidia_gpu > 0
  83. tags: init
  84. - name: Helm - update repo
  85. command: helm repo update
  86. changed_when: true
  87. tags: init
  88. - name: Start NFS Client Provisioner using NFS on manager node
  89. command: "helm install nfs-omnia stable/nfs-client-provisioner --set nfs.server='{{ nfs_server_manager_node }}' --set nfs.path='{{ nfs_share_dir }}'"
  90. changed_when: true
  91. when:
  92. - "'nfs-client-provisioner' not in k8s_pods.stdout"
  93. - not hostvars['127.0.0.1']['powervault_status']
  94. tags: init
  95. - name: Start NFS Client Provisioner using NFS on NFS Node
  96. command: "helm install nfs-omnia stable/nfs-client-provisioner --set nfs.server='{{ nfs_server_nfs_node }}' --set nfs.path='{{ me4_nfs_share_k8s }}'"
  97. changed_when: true
  98. when:
  99. - "'nfs-client-provisioner' not in k8s_pods.stdout"
  100. - hostvars['127.0.0.1']['powervault_status']
  101. tags: init
  102. - name: Set NFS-Client Provisioner as DEFAULT StorageClass
  103. shell: >
  104. kubectl patch storageclasses.storage.k8s.io nfs-client \
  105. -p '{ "metadata": { "annotations":{ "storageclass.kubernetes.io/is-default-class":"true" }}}'
  106. changed_when: true
  107. tags: init
  108. - name: Check if prometheus is installed on the host
  109. stat:
  110. path: "{{ prometheus_path_on_host }}"
  111. register: prometheus_status
  112. changed_when: False
  113. ignore_errors: yes
  114. tags: init
  115. - name: Delete prometheus installed on host if it exists
  116. file:
  117. path: "{{ prometheus_path_on_host }}"
  118. state: absent
  119. when: prometheus_status.stat.exists
  120. tags: init
  121. - name: Copy the slurm exporter config file
  122. copy:
  123. src: "{{ slurm_exporter_config_file }}"
  124. dest: "{{ slurm_exporter_config_file_path }}"
  125. owner: root
  126. group: root
  127. mode: "{{ slurm_exporter_file_mode }}"
  128. tags: init
  129. - name: Fetch the public IP of the host
  130. shell: >
  131. set -o pipefail && \
  132. ip route get 8.8.8.8 | awk '{print $7}'
  133. register: public_ip
  134. changed_when: False
  135. tags: init
  136. - name: Add the host IP to config file
  137. replace:
  138. path: "{{ slurm_exporter_config_file_path }}{{ slurm_exporter_config_file }}"
  139. regexp: "localhost:8080"
  140. replace: "{{ public_ip.stdout }}:{{ slurm_exporter_port }}"
  141. tags: init
  142. - name: Prometheus deployment
  143. command: >
  144. helm install stable/prometheus \
  145. --set-file extraScrapeConfigs="{{ slurm_exporter_config_file_path }}{{ slurm_exporter_config_file }}" \
  146. --set alertmanager.persistentVolume.storageClass=nfs-client,server.persistentVolume.storageClass=nfs-client,server.service.type=LoadBalancer \
  147. --generate-name
  148. changed_when: true
  149. when: "'prometheus' not in k8s_pods.stdout"
  150. tags: init
  151. - name: Install MPI Operator
  152. command: "kubectl create -f '{{ mpi_operator_yaml_url }}'"
  153. changed_when: true
  154. when: "'mpi-operator' not in k8s_pods.stdout"
  155. tags: init
  156. - name: Install nvidia-device-plugin
  157. command: "helm install --version='{{ nvidia_device_plugin_version }}' --generate-name --set migStrategy='{{ mig_strategy }}' nvdp/nvidia-device-plugin"
  158. changed_when: true
  159. when:
  160. - "'nvidia-device-plugin' not in k8s_pods.stdout"
  161. - ansible_local.inventory.nvidia_gpu > 0
  162. tags: init
  163. - name: Install GPU Feature Discovery
  164. command: "helm install --version='{{ gpu_feature_discovery_version }}' --generate-name --set migStrategy='{{ mig_strategy }}' nvgfd/gpu-feature-discovery"
  165. changed_when: true
  166. when:
  167. - "'node-feature-discovery' not in k8s_pods.stdout"
  168. - ansible_local.inventory.nvidia_gpu > 0
  169. tags: init
  170. - name: Deploy Xilinx Device plugin
  171. command: "kubectl create -f '{{ fpga_device_plugin_yaml_url }}'"
  172. changed_when: true
  173. register: fpga_enable
  174. when: "'fpga-device-plugin' not in k8s_pods.stdout"
  175. tags: init
  176. - name: Deploy ROCm Device plugin
  177. command: "kubectl create -f '{{ rocm_device_plugin_yaml_url }}'"
  178. changed_when: true
  179. register: amd_gpu_enable
  180. when: "'amdgpu-device-plugin' not in k8s_pods.stdout"
  181. tags: init
  182. - name: Deploy Volcano Scheduling
  183. command: "kubectl apply -f '{{ volcano_scheduling_yaml_url }}'"
  184. changed_when: true
  185. when: "'volcano-system' not in k8s_pods.stdout"
  186. tags: init
  187. - name: Install Spark Operator
  188. command: "helm repo add spark-operator '{{ spark_operator_repo }}'"
  189. changed_when: true
  190. tags: init
  191. - name: Install Spark Operator Namespace
  192. command: helm install my-release spark-operator/spark-operator --set image.tag={{ operator_image_tag }} --namespace spark-operator --create-namespace
  193. changed_when: true
  194. when: "'spark-operator' not in k8s_pods.stdout"
  195. tags: init