Skip to content

DO NOT MERGE: Kubernetes secret hostvars for compute-init #606

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 89 additions & 0 deletions ansible/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
---

- hosts: compute
become: yes
gather_facts: yes
tasks:
####### to be part of k3s role run at build time
- name: Install pip
dnf:
name: python3-pip
delegate_to: "{{ groups['control'] | first }}"
run_once: true

- name: Install pip dependencies for k8s ansible module
ansible.builtin.pip:
name:
- kubernetes==30.1.0
delegate_to: "{{ groups['control'] | first }}"
run_once: true
#######
- name: Create Slurm Namespace
kubernetes.core.k8s:
name: slurm
api_version: v1
kind: Namespace
state: present
delegate_to: "{{ groups['control'] | first }}"
run_once: true

- name: Create Kubernetes Secret for each compute node hostvars
kubernetes.core.k8s:
state: present
definition:
apiVersion: v1
kind: Secret
metadata:
name: "{{ inventory_hostname }}-hostvars"
namespace: slurm
type: Opaque
data:
hostvars.yml: "{{ lookup('ansible.builtin.template', 'roles/compute_init/templates/hostvars.yml.j2') | b64encode }}"
delegate_to: "{{ groups['control'] | first }}"

- name: Deploy Slurm Config Push DaemonSet
kubernetes.core.k8s:
state: present
definition:
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: "slurm-hostvars-writer-{{ inventory_hostname }}"
namespace: slurm
spec:
selector:
matchLabels:
name: slurm-hostvars-writer
template:
metadata:
labels:
name: slurm-hostvars-writer
spec:
securityContext:
runAsUser: 0
runAsGroup: 0
fsGroup: 0
containers:
- name: pause
image: registry.k8s.io/pause
initContainers:
- name: copy-hostvars
image: busybox:1.37
command: ['sh', '-c', 'mkdir -p /etc/compute-init/hostvars && cat /mnt/hostvars/hostvars.yml > /etc/compute-init/hostvars/{{ inventory_hostname }}.yml && chmod 0400 /etc/compute-init/hostvars/{{ inventory_hostname }}.yml']
volumeMounts:
- name: hostvars-dir
mountPath: /etc/
- name: hostvars-secret
mountPath: /mnt/hostvars
readOnly: true
volumes:
- name: hostvars-dir
hostPath:
path: /etc/
type: Directory
- name: hostvars-secret
projected:
sources:
- secret:
name: "{{ inventory_hostname }}-hostvars"
delegate_to: "{{ groups['control'] | first }}"
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ cookiecutter
selinux # this is a shim to avoid having to use --system-site-packages, you still need sudo yum install libselinux-python3
netaddr
matplotlib
kubernetes==31.0.0
pulp-cli==0.23.2
2 changes: 2 additions & 0 deletions requirements.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ collections:
- name: https://github.com/azimuth-cloud/ansible-collection-image-utils
type: git
version: 0.4.0
- name: kubernetes.core
version: 2.4.2
# stackhpc.pulp has pulp.squeezer as dependency, any version, but latest
# requires newer ansible than can install
- name: pulp.squeezer
Expand Down