Browse Source

Issue #825: Code changes for control_plane k8s

Signed-off-by: Lakshmi-Patneedi <Lakshmi_Patneedi@Dellteam.com>
Lakshmi-Patneedi 3 years ago
parent
commit
4221e13cf4

+ 29 - 7
control_plane/roles/control_plane_k8s/tasks/k8s_installation_leap.yml

@@ -1,4 +1,4 @@
-#  Copyright 2021 Dell Inc. or its subsidiaries. All Rights Reserved.
+#  Copyright 2022 Dell Inc. or its subsidiaries. All Rights Reserved.
 #
 #  Licensed under the Apache License, Version 2.0 (the "License");
 #  you may not use this file except in compliance with the License.
@@ -55,11 +55,23 @@
   changed_when: true
 
 - name: Installing cri-o
-  zypper:
+  package:
     name: cri-o
     state: present
   changed_when: true
 
+- name: Installing cri-o tools
+  package:
+    name: cri-tools
+    state: present
+  changed_when: true
+
+- name: Reloading deamon
+  command: systemctl daemon-reload
+  changed_when: true
+  args:
+    warn: false
+
 - name: Start and enable crio
   service:
     name: crio
@@ -68,13 +80,14 @@
     enabled: yes
   register: crio_repo_result
   until: crio_repo_result is not failed
-  retries: "{{ min_retries }}"
+  retries: "{{ max_retries }}"
 
 - name: Add kubernetes repo
   zypper_repository:
      name: google-k8s
      repo: "{{ k8s_repo_leap }}"
      state: present
+     disable_gpg_check: yes
      autorefresh: yes
 
 - name: Import rpm-package key for installing kubernetes
@@ -94,7 +107,7 @@
   changed_when: false
 
 - name: Refresh repositories and installing conntrack-tools
-  zypper:
+  package:
     name: conntrack-tools
     state: present
     update_cache: yes
@@ -111,6 +124,9 @@
     responses:
         (.*) [1/2/c/d/?](.): '2'
         (.*)(y): 'y'
+  register: kubeadm_status
+  until: kubeadm_status is not failed
+  retries: "{{ max_retries }}"
 
 - name: Install Kubelet
   ansible.builtin.expect:
@@ -118,6 +134,9 @@
     responses:
         (.*) [1/2/c/d/?](.): '2'
         (.*)(y): 'y'
+  register: kubelet_status
+  until: kubelet_status is not failed
+  retries: "{{ max_retries }}"
 
 - name: Install Kubectl
   zypper:
@@ -125,10 +144,13 @@
      state: present
      oldpackage: yes
      force: yes
+  register: kubectl_status
+  until: kubectl_status is not failed
+  retries: "{{ max_retries }}"
 
 - name: Install common packages
   zypper:
-    name: "{{ common_pkgs_leap }}"
+    name: "{{ common_packages }}"
     state: present
 
 - name: Versionlocking kubeadm
@@ -161,7 +183,7 @@
   tags: install
 
 - name: Install docker-compose
-  zypper:
+  package:
     name: docker-compose
     state: present
   when: docker_username and docker_password
@@ -174,7 +196,7 @@
     enabled: yes
   register: crio_repo_result
   until: crio_repo_result is not failed
-  retries: "{{ min_retries }}"
+  retries: "{{ max_retries }}"
 
 - name: Start and enable kubernetes - kubelet
   service:

+ 2 - 4
control_plane/roles/control_plane_k8s/tasks/main.yml

@@ -15,9 +15,7 @@
 
 - name: Install K8s packages
   include_tasks: k8s_installation.yml
-  when:
-    - ( mgmt_os == os_supported_centos ) and ( ansible_distribution_version >= os_supported_centos_version ) or
-      ( mgmt_os == os_supported_rocky ) and ( ansible_distribution_version >= os_supported_rocky_version )
+  when: os_supported_leap not in mgmt_os
 
 - name: Install K8s packages for leap
   include_tasks: k8s_installation_leap.yml
@@ -33,4 +31,4 @@
   import_tasks: k8s_init.yml
 
 - name: Deploy K8s dashboard
-  import_tasks: k8s_services.yml
+  import_tasks: k8s_services.yml

+ 1 - 5
control_plane/roles/control_plane_k8s/vars/main.yml

@@ -25,14 +25,10 @@ docker_repo_dest_leap: /etc/YaST2/docker-ce.repo
 kubeadm_version: kubeadm-1.21.0-0.x86_64
 kubelet_version: kubelet-1.21.0-0.x86_64
 kubectl_version: kubectl-1.21.0-0.x86_64
-common_pkgs_leap:
-  - openssl
-  - bash-completion
-  - buildah
 os_supported_leap: "leap"
 os_supported_leap_version: "15.3"
 min_retries: 3
-max_retries: 3
+max_retries: 10
 min_delay: 10
 wait_time: 30
  

+ 1 - 8
roles/k8s_start_services/tasks/main.yml

@@ -21,14 +21,7 @@
 - name: Check K8s pods
   include_tasks: check_k8s_pods.yml
   tags: install
-
-- name: Install community.grafana collection
-  command: ansible-galaxy collection install community.grafana
-  changed_when: True
-  tags: install
-  delegate_to: localhost
-  when: hostvars['127.0.0.1']['control_plane_status']
-
+  
 - name: Configure Nginx/Prometheus/Grafana
   include_tasks: configure_nginx_prom_grafana.yml
   when:

+ 2 - 2
roles/k8s_start_services/vars/main.yml

@@ -99,9 +99,9 @@ nginx_conf_file_path: /etc/nginx/nginx.conf
 
 nginx_conf_file_mode: 2534
 
-grafana_svc_ip: "{{ lookup('ini', 'ip section=grafana_svc file={{ role_path }}/files/grafana_svc_details.ini') }}"
+grafana_svc_ip: "{{ lookup('ini', 'ip section=grafana_svc file={{ playbook_dir }}/roles/k8s_start_services/files/grafana_svc_details.ini') }}"
 
-grafana_svc_port: "{{ lookup('ini', 'port section=grafana_svc file={{ role_path }}/files/grafana_svc_details.ini') }}"
+grafana_svc_port: "{{ lookup('ini', 'port section=grafana_svc file={{ playbook_dir }}/roles/k8s_start_services/files/grafana_svc_details.ini') }}"
 
 opensuse_os_name: "openSUSE Leap"
 

+ 0 - 7
roles/slurm_exporter/tasks/main.yml

@@ -38,13 +38,6 @@
     - "'kubernetes' in ansible_skip_tags"
     - "'No such file' in k8s_installation_status.stderr"
 
-- name: Install community.grafana collection
-  command: ansible-galaxy collection install community.grafana
-  changed_when: True
-  tags: install
-  delegate_to: localhost
-  when: hostvars['127.0.0.1']['control_plane_status']
-
 - name: Configure grafana dashboard
   include_tasks: configure_grafana.yml
   when:

+ 1 - 0
roles/slurm_exporter/vars/main.yml

@@ -31,6 +31,7 @@ prometheus_inst_path: "/var/lib/prometheus-2.23.0.linux-amd64/"
 prometheus_exec_path: "{{ prometheus_inst_path }}/prometheus"
 system_local_path: "/usr/local/bin"
 prometheus_config_file: "{{ prometheus_inst_path }}/prometheus.yml"
+opensuse_os_name: "openSUSE Leap"
 
 #Usage: start_service.yml
 file_permission: "0755"

+ 6 - 0
telemetry/roles/slurm_telemetry/tasks/get_node_inventory.yml

@@ -18,6 +18,12 @@
     src: "{{ role_path }}/files/monster"
     dest: "{{ slurm_telemetry_code_dir }}"
     mode: "{{ slurm_telemetry_code_dir_mode }}"
+    
+- name: Install jmepath
+  pip:
+    name: jmespath
+    state: present
+    executable: pip3
 
 - name: Get AWX service IP
   command: kubectl get svc awx-ui -n {{ awx_namespace }} -o=jsonpath='{.spec.clusterIP}'