This repository has been archived by the owner on Nov 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
setup_k8s_specific.yml
93 lines (82 loc) · 2.86 KB
/
setup_k8s_specific.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2021-2022, Intel Corporation
#
---
- hosts: utility[0]
pre_tasks:
- name: "setup_k8s | Load playbook variables"
include_vars: "vars/vars.yml"
tasks:
- name: "setup_k8s | Add bitami charts repository"
kubernetes.core.helm_repository:
name: bitnami
repo_url: https://charts.bitnami.com/bitnami
- set_fact:
nodes_in_group_count: "{{ (redis_nodes_count / 2) | int }}"
- name: "setup_k8s | Get nodes with first-group label"
kubernetes.core.k8s_info:
kind: Node
label_selectors:
- computes-group=first-group
register: first_nodes_raw_info
- set_fact:
first_nodes_info: "{{ first_nodes_info | default([]) + [ item.metadata['name'] ] }}"
with_items: "{{ first_nodes_raw_info['resources'] }}"
no_log: true
- name: "setup_k8s | Remove old first-group labels"
kubernetes.core.k8s:
definition:
apiVersion: v1
kind: Node
metadata:
name: "{{ item }}"
labels:
computes-group: null
state: patched
with_items: "{{ first_nodes_info }}"
when: first_nodes_info is defined
- name: "setup_k8s | Get nodes with second-group label"
kubernetes.core.k8s_info:
kind: Node
label_selectors:
- computes-group=second-group
register: second_nodes_raw_info
- set_fact:
second_nodes_info: "{{ second_nodes_info | default([]) + [ item.metadata['name'] ] }}"
with_items: "{{ second_nodes_raw_info['resources'] }}"
no_log: true
- name: "setup_k8s | Remove old second-group labels"
kubernetes.core.k8s:
definition:
apiVersion: v1
kind: Node
metadata:
name: "{{ item }}"
labels:
computes-group: null
state: patched
with_items: "{{ second_nodes_info }}"
when: second_nodes_info is defined
- name: "setup_k8s | Label first-group compute nodes for balanced multiple-clusters testcase"
kubernetes.core.k8s:
definition:
apiVersion: v1
kind: Node
metadata:
labels:
computes-group: first-group
name: "{{ groups['computes'][item | int - 1] }}"
state: patched
with_sequence: start=1 end="{{ nodes_in_group_count | int }}"
- name: "setup_k8s | Label second-group compute nodes for balanced multiple-clusters testcase"
kubernetes.core.k8s:
definition:
apiVersion: v1
kind: Node
metadata:
labels:
computes-group: second-group
name: "{{ groups['computes'][item | int - 1] }}"
state: patched
with_sequence: start="{{ nodes_in_group_count | int + 1 }}" end="{{ redis_nodes_count | int }}"
# vi:et:sw=2 ts=2 sts=2 ft=ansible