deploy_k8s_services.yml 7.0 KB

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