Quellcode durchsuchen

Issue #839: K8s_common role changes for omnia.yml

Signed-off-by: Lakshmi-Patneedi <Lakshmi_Patneedi@Dellteam.com>
Lakshmi-Patneedi vor 3 Jahren
Ursprung
Commit
3a2de4b21d

+ 1 - 1
control_plane/roles/webui_grafana/tasks/plugins.yml

@@ -17,7 +17,7 @@
   ansible.builtin.git:
     repo: "{{ grafana_plugins_github_repo }}"
     dest: "{{ mount_location + grafana_plugins_folder_name }}"
-    version: main
+    version: "{{ grafana_plugins_stable_commit }}"
 
 - name: Wait for grafana pod to come to ready state
   command: kubectl wait --for=condition=ready --timeout="{{ grafana_pod_timeout }}" -n "{{ grafana_namespace }}" pod -l app="{{ grafana_k8s }}"

+ 1 - 0
control_plane/roles/webui_grafana/vars/main.yml

@@ -44,3 +44,4 @@ plugins_name:
   - stream-net.zip
 grafana_plugins_folder_name: github-grafana-plugins/
 grafana_plugins_github_repo: https://github.com/nsfcac/grafana-plugin.git
+grafana_plugins_stable_commit: "947da4f"

+ 120 - 28
roles/k8s_common/tasks/main.yml

@@ -1,4 +1,4 @@
-#  Copyright 2020 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.
@@ -13,19 +13,6 @@
 #  limitations under the License.
 ---
 
-- name: Add kubernetes repo
-  yum_repository:
-    name: kubernetes
-    description: kubernetes
-    baseurl: https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
-    enabled: yes
-    gpgcheck: no
-    repo_gpgcheck: no
-    gpgkey:
-      - https://packages.cloud.google.com/yum/doc/yum-key.gpg
-      - https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
-  tags: install
-
 - name: Update sysctl to handle incorrectly routed traffic when iptables is bypassed
   copy:
     src: k8s.conf
@@ -40,20 +27,125 @@
   changed_when: true
   tags: install
 
-- name: Install k8s packages
-  package:
-    name: "{{ k8s_packages }}"
-    state: present
-  tags: install
+- block:
+    - name: Add kubernetes repo
+      yum_repository:
+        name: kubernetes
+        description: kubernetes
+        baseurl: https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
+        enabled: yes
+        gpgcheck: no
+        repo_gpgcheck: no
+        gpgkey:
+          - https://packages.cloud.google.com/yum/doc/yum-key.gpg
+          - https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
+      tags: install
 
-- name: Versionlock kubernetes
-  command: "yum versionlock '{{ item }}'"
-  args:
-    warn: false
-  with_items:
-    - "{{ k8s_packages }}"
-  changed_when: true
-  tags: install
+    - name: Install k8s packages
+      package:
+        name: "{{ k8s_packages }}"
+        state: present
+      tags: install
+
+    - name: Versionlock kubernetes
+      command: "yum versionlock '{{ item }}'"
+      args:
+        warn: false
+      with_items:
+        - "{{ k8s_packages }}"
+      changed_when: true
+      tags: install
+  when: os_supported_leap not in compute_os
+
+- block:
+    - name: Add kubernetes repo
+      zypper_repository:
+        name: google-k8s
+        repo: "{{ k8s_repo_leap }}"
+        state: present
+        autorefresh: yes
+        disable_gpg_check: yes
+      tags: install
+
+    - name: Import rpm-package key for installing kubernetes
+      rpm_key:
+        key: "{{ rpm_pkg_leap }}"
+        state: present
+      tags: install
+
+    - name: Import yum key for installing kubernetes
+      rpm_key:
+        key: "{{ yum_key_leap }}"
+        state: present
+      tags: install
+
+    - name: Import gpg-pubkey key for installing kubernetes
+      command: "{{ gpg_pubkey_leap }}"
+      args:
+        warn: false
+      changed_when: false
+      tags: install
+
+    - name: Refresh repositories and installing conntrack-tools
+      package:
+        name: conntrack-tools
+        state: present
+      tags: install
+
+    - name: Install Kubeadm
+      ansible.builtin.expect:
+        command: zypper install --oldpackage "{{ kubeadm_version }}"
+        responses:
+            (.*) [1/2/c/d/?](.): '2'
+            (.*)(y): 'y'
+      register: kubeadm_status
+      until: kubeadm_status is not failed
+      retries: "{{ max_retries }}"
+      tags: install
+
+    - name: Install Kubelet
+      ansible.builtin.expect:
+        command: zypper install --oldpackage "{{ kubelet_version }}"
+        responses:
+            (.*) [1/2/c/d/?](.): '2'
+            (.*)(y): 'y'
+      register: kubelet_status
+      until: kubelet_status is not failed
+      retries: "{{ max_retries }}"
+      tags: install
+
+    - name: Install Kubectl
+      zypper:
+        name: "{{ kubectl_version }}"
+        state: present
+        oldpackage: yes
+        force: yes
+      register: kubectl_status
+      until: kubectl_status is not failed
+      retries: "{{ max_retries }}"
+      tags: install
+
+    - name: Versionlocking kubeadm
+      command: zypper addlock "{{ kubeadm_version }}"
+      args:
+        warn: false
+      changed_when: false
+      tags: install
+
+    - name: Versionlocking kubectl
+      command: zypper addlock "{{ kubelet_version }}"
+      args:
+        warn: false
+      changed_when: false
+      tags: install
+
+    - name: Versionlocking kubelet
+      command: zypper addlock "{{ kubectl_version }}"
+      args:
+        warn: false
+      changed_when: false
+      tags: install
+  when: ( os_supported_leap in compute_os ) and ( ansible_distribution_version >= os_supported_leap_version )
 
 - name: Start and enable docker service
   service:
@@ -66,4 +158,4 @@
   service:
     name: kubelet
     state: restarted
-    enabled: yes
+    enabled: yes

+ 14 - 2
roles/k8s_common/vars/main.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.
@@ -12,6 +12,18 @@
 #  See the License for the specific language governing permissions and
 #  limitations under the License.
 ---
+k8s_repo_leap: https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
+rpm_pkg_leap: https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
+yum_key_leap:  https://packages.cloud.google.com/yum/doc/yum-key.gpg
+gpg_pubkey_leap: "rpm -q gpg-pubkey --qf '%{name}-%{version}-%{release} --> %{summary}'"
+docker_repo_url_leap: https://download.docker.com/linux/sles/docker-ce.repo
+docker_repo_dest_leap: /etc/YaST2/docker-ce.repo
+os_supported_leap: "leap"
+os_supported_leap_version: "15.3"
+kubeadm_version: "kubeadm-{{ hostvars['127.0.0.1']['k8s_version'] }}"
+kubelet_version: "kubelet-{{ hostvars['127.0.0.1']['k8s_version'] }}"
+kubectl_version: "kubectl-{{ hostvars['127.0.0.1']['k8s_version'] }}"
+max_retries: 20
 
 k8s_packages:
   - "kubelet-{{ hostvars['127.0.0.1']['k8s_version'] }}"
@@ -24,4 +36,4 @@ k8s_conf_dest: /etc/sysctl.d/
 
 k8s_repo_file_mode: 0644
 
-k8s_conf_file_mode: 0644
+k8s_conf_file_mode: 0644

+ 3 - 3
roles/k8s_start_manager/tasks/main.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.
@@ -69,7 +69,7 @@
 - name: Initialize kubeadm (This process may take 5-10min)
   block:
     - name: Initialize kubeadm (This process may take 5-10min)
-      command: "/bin/kubeadm init --pod-network-cidr='{{ hostvars['127.0.0.1']['k8s_pod_network_cidr'] }}' \
+      command: "kubeadm init --pod-network-cidr='{{ hostvars['127.0.0.1']['k8s_pod_network_cidr'] }}' \
         --apiserver-advertise-address='{{ ansible_default_ipv4.address }}'"
       changed_when: true
       register: init_output
@@ -80,7 +80,7 @@
       changed_when: true
 
     - name: Initialize kubeadm (This process may take 5-10min)
-      command: "/bin/kubeadm init --pod-network-cidr='{{ hostvars['127.0.0.1']['k8s_pod_network_cidr'] }}' \
+      command: "kubeadm init --pod-network-cidr='{{ hostvars['127.0.0.1']['k8s_pod_network_cidr'] }}' \
         --apiserver-advertise-address='{{ ansible_default_ipv4.address }}'"
       changed_when: true
       register: init_output

+ 1 - 1
telemetry/input_params/base_vars.yml

@@ -15,7 +15,7 @@
 
 # At this location all telemetry related files will be stored and
 # both timescale and mysql databases will be mounted.
-mount_location: /mnt/omnia/
+mount_location: /opt/omnia/
 
 # This variable is used to enable iDRAC telemetry support and visualizations
 # Accepted values:  "true" or "false"

+ 2 - 2
telemetry/roles/grafana_config/files/parallel-coordinate.json

@@ -314,8 +314,8 @@
   },
   "timepicker": {},
   "timezone": "",
-  "title": "iDRAC-and-Slurm-Telemetry",
+  "title": "Parallel-Coordinate",
   "uid": "pArBHUtnk",
   "version": 6,
   "weekStart": ""
-}
+}

+ 24 - 0
telemetry/roles/grafana_config/tasks/add_dashboards.yml

@@ -0,0 +1,24 @@
+# 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.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+---
+
+- name: Import dashboards for visualizations
+  community.grafana.grafana_dashboard:
+    grafana_url: "http://{{ grafana_svc_ip.stdout }}:{{ grafana_svc_port.stdout }}"
+    grafana_user: "{{ grafana_username }}"
+    grafana_password: "{{ grafana_password }}"
+    state: present
+    overwrite: yes
+    path: "{{ playbook_dir }}/roles/grafana_config/files/{{ dashboards }}"
+  no_log: true

+ 5 - 4
telemetry/roles/grafana_config/tasks/add_datasource.yml

@@ -24,12 +24,12 @@
   register: grafana_svc_port
 
 - name: Get timescaleDB svc IP
-  command: kubectl get svc -n "{{ namespace }}" -o=jsonpath='{.items[0].spec.clusterIP}'
+  command: kubectl get svc "{{ timescaledb_k8s_name }}" -n "{{ namespace }}" -o=jsonpath='{.spec.clusterIP}'
   changed_when: false
   register: timescale_svc_ip
 
 - name: Get timescaleDB svc port
-  command: kubectl get svc -n "{{ namespace }}" -o=jsonpath='{.items[0].spec.ports[0].port}'
+  command: kubectl get svc "{{ timescaledb_k8s_name }}" -n "{{ namespace }}" -o=jsonpath='{.spec.ports[0].port}'
   changed_when: false
   register: timescale_svc_port
 
@@ -44,11 +44,12 @@
     grafana_user: "{{ grafana_username }}"
     grafana_password: "{{ grafana_password }}"
     ds_type: "postgres"
-    ds_url: "http://{{ timescale_svc_ip.stdout }}:{{ timescale_svc_port.stdout }}"
+    database: "{{ timescaledb_name }}"
+    ds_url: "{{ timescale_svc_ip.stdout }}:{{ timescale_svc_port.stdout }}"
     user: "{{ timescaledb_user }}"
     sslmode: "disable"
     additional_json_data:
-      postgresVersion: 12
+      postgresVersion: 12+
       timescaledb: true
     additional_secure_json_data:
       password: "{{ timescaledb_password }}"

+ 7 - 4
telemetry/roles/grafana_config/tasks/main.yml

@@ -13,8 +13,11 @@
 # limitations under the License.
 ---
 
-- name: Add telemetry datasource on grafana
-  include_tasks: add_datasource.yml
+- name: Configure grafana for telemetry
+  block:
+  - name: Add telemetry datasource on grafana
+    include_tasks: add_datasource.yml
 
-#- name: Add dashboards on grafana
-#  include_tasks: add_dashboards.yml
+  - name: Add dashboards on grafana
+    include_tasks: add_dashboards.yml
+  when: idrac_telemetry_support is true

+ 1 - 0
telemetry/roles/grafana_config/vars/main.yml

@@ -15,3 +15,4 @@
 
 grafana_k8s: grafana
 grafana_namespace: grafana
+dashboards: parallel-coordinate.json

+ 5 - 4
telemetry/roles/idrac_telemetry/tasks/initiate_telemetry.yml

@@ -38,7 +38,7 @@
       tower_config_file: "{{ playbook_dir }}/../control_plane/roles/webui_awx/files/.tower_cli.cfg"
       tower_vault_file: "{{ playbook_dir }}/../control_plane/roles/webui_awx/files/.tower_vault_key"
       idrac_telemetry_scripting_repo: "https://github.com/dell/iDRAC-Telemetry-Scripting.git"
-      idrac_telemetry_scripting_branch: master
+      idrac_telemetry_scripting_stable_commit: "1f4bb26"
       idrac_telemetry_scripting_folder: iDRAC-Telemetry-Scripting
       idrac_login_input_filename: "{{ playbook_dir }}/../control_plane/input_params/login_vars.yml"
       idrac_login_vault_filename: "{{ playbook_dir }}/../control_plane/input_params/.login_vault_key"
@@ -213,7 +213,7 @@
       ansible.builtin.git:
         repo: "{{ idrac_telemetry_scripting_repo }}"
         dest: "{{ mount_location + idrac_telemetry_scripting_folder }}"
-        version: "{{ idrac_telemetry_scripting_branch }}"
+        version: "{{ idrac_telemetry_scripting_stable_commit }}"
       register: telemetry_collection
 
     - name: Enable telemetry collection on iDRACs
@@ -221,12 +221,13 @@
       args:
         chdir: "{{ mount_location + idrac_telemetry_scripting_folder }}"
       with_items: "{{ telemetry_idrac }}"
+      changed_when: false
       no_log: true
     when: telemetry_idrac is defined and (telemetry_idrac |length>0)
     rescue:
       - name: Show failure msg
-        fail:
-          msg: "Enabling telemetry on iDRAC failed"
+        debug:
+          msg: "Enabling telemetry on an iDRAC failed"
 
   - name: Add iDRAC details in mysqldb
     block:

+ 1 - 1
telemetry/roles/timescaledb/tasks/main.yml

@@ -23,7 +23,7 @@
   ansible.builtin.git:
     repo: "{{ idrac_telemetry_github }}"
     dest: "{{ mount_location + idrac_telemetry_folder_name }}"
-    version: master
+    version: "{{ reference_tools_stable_commit }}"
 
 - name: Create timescaledb pod
   include_tasks: timescaledb_pod.yml

+ 1 - 0
telemetry/roles/timescaledb/vars/main.yml

@@ -23,3 +23,4 @@ timescaledb_k8s_name: timescaledb
 timescaledb_container_port: 5432
 retries: 10
 delay: 10
+reference_tools_stable_commit: "0016fcb"