Skip to content

Commit 614defc

Browse files
committed
test kubernetes hostvars for compute-init
1 parent e040631 commit 614defc

File tree

3 files changed

+92
-0
lines changed

3 files changed

+92
-0
lines changed

ansible/test.yml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
---
2+
3+
- hosts: compute
4+
become: yes
5+
gather_facts: yes
6+
tasks:
7+
####### to be part of k3s role run at build time
8+
- name: Install pip
9+
dnf:
10+
name: python3-pip
11+
delegate_to: "{{ groups['control'] | first }}"
12+
run_once: true
13+
14+
- name: Install pip dependencies for k8s ansible module
15+
ansible.builtin.pip:
16+
name:
17+
- kubernetes==30.1.0
18+
delegate_to: "{{ groups['control'] | first }}"
19+
run_once: true
20+
#######
21+
- name: Create Slurm Namespace
22+
kubernetes.core.k8s:
23+
name: slurm
24+
api_version: v1
25+
kind: Namespace
26+
state: present
27+
delegate_to: "{{ groups['control'] | first }}"
28+
run_once: true
29+
30+
- name: Create Kubernetes Secret for each compute node hostvars
31+
kubernetes.core.k8s:
32+
state: present
33+
definition:
34+
apiVersion: v1
35+
kind: Secret
36+
metadata:
37+
name: "{{ inventory_hostname }}-hostvars"
38+
namespace: slurm
39+
type: Opaque
40+
data:
41+
hostvars.yml: "{{ lookup('ansible.builtin.template', 'roles/compute_init/templates/hostvars.yml.j2') | b64encode }}"
42+
delegate_to: "{{ groups['control'] | first }}"
43+
44+
- name: Deploy Slurm Config Push DaemonSet
45+
kubernetes.core.k8s:
46+
state: present
47+
definition:
48+
apiVersion: apps/v1
49+
kind: DaemonSet
50+
metadata:
51+
name: "slurm-hostvars-writer-{{ inventory_hostname }}"
52+
namespace: slurm
53+
spec:
54+
selector:
55+
matchLabels:
56+
name: slurm-hostvars-writer
57+
template:
58+
metadata:
59+
labels:
60+
name: slurm-hostvars-writer
61+
spec:
62+
securityContext:
63+
runAsUser: 1000
64+
runAsGroup: 1000
65+
fsGroup: 1000
66+
containers:
67+
- name: pause
68+
image: registry.k8s.io/pause
69+
initContainers:
70+
- name: copy-hostvars
71+
image: busybox:1.37
72+
command: ['sh', '-c', 'mkdir -p /etc/compute-init/hostvars && cat /mnt/hostvars/hostvars.yml > /etc/compute-init/hostvars/{{ inventory_hostname }}.yml']
73+
volumeMounts:
74+
- name: hostvars-dir
75+
mountPath: /etc/
76+
- name: hostvars-secret
77+
mountPath: /mnt/hostvars
78+
readOnly: true
79+
volumes:
80+
- name: hostvars-dir
81+
hostPath:
82+
path: /etc/
83+
type: Directory
84+
- name: hostvars-secret
85+
projected:
86+
sources:
87+
- secret:
88+
name: "{{ inventory_hostname }}-hostvars"
89+
delegate_to: "{{ groups['control'] | first }}"

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ cookiecutter
99
selinux # this is a shim to avoid having to use --system-site-packages, you still need sudo yum install libselinux-python3
1010
netaddr
1111
matplotlib
12+
kubernetes==31.0.0
1213
pulp-cli==0.23.2

requirements.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ collections:
4848
- name: https://github.com/azimuth-cloud/ansible-collection-image-utils
4949
type: git
5050
version: 0.4.0
51+
- name: kubernetes.core
52+
version: 2.4.2
5153
# stackhpc.pulp has pulp.squeezer as dependency, any version, but latest
5254
# requires newer ansible than can install
5355
- name: pulp.squeezer

0 commit comments

Comments
 (0)