Skip to content

Commit

Permalink
fixed some states to support arm64
Browse files Browse the repository at this point in the history
k3s orchestrator
  • Loading branch information
kiemlicz committed Feb 2, 2024
1 parent 388130d commit eccb68b
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 27 deletions.
15 changes: 4 additions & 11 deletions salt/docker/map.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,12 @@

{% set os = salt['grains.get']('os') %}
{% set dist_codename = salt['grains.get']('lsb_distrib_codename') %}
{% set arch = salt['grains.get']("osarch") %}

{% set docker = salt['grains.filter_by']({
'RedHat': {
'baseurl': "https://download.docker.com/linux/fedora/$releasever/$basearch/stable",
'repo_id': "docker-ce-stable",
'gpgkey': "https://download.docker.com/linux/fedora/gpg",
'pkg_name': "docker-ce",
'service_name': "docker",
'config': '/etc/docker/daemon.json',
},
'Debian': {
'default': {
'file': '/etc/apt/sources.list.d/docker.list',
'names': ["deb [arch=amd64] https://download.docker.com/linux/" ~ os.lower() ~ " " ~ dist_codename ~ " stable"],
'names': ["deb [arch=" ~ arch ~ "] https://download.docker.com/linux/" ~ os.lower() ~ " " ~ dist_codename ~ " stable"],
'key_url': "https://download.docker.com/linux/" ~ os.lower() ~ "/gpg",
'pkg_names': ["docker-ce", "docker-ce-cli", "containerd.io"],
'required_pkgs': ["bridge-utils"],
Expand All @@ -23,6 +16,6 @@
},
}, merge=salt['grains.filter_by']({
'sid': {
'names': ["deb [arch=amd64] https://download.docker.com/linux/" ~ os.lower() ~ " stretch stable edge"],
'names': ["deb [arch=" ~ arch ~ "] https://download.docker.com/linux/" ~ os.lower() ~ " stretch stable edge"],
}
}, grain='oscodename', merge=salt['pillar.get']('docker'))) %}
48 changes: 43 additions & 5 deletions salt/kubernetes/_orchestrate/k3s.sls
Original file line number Diff line number Diff line change
@@ -1,18 +1,56 @@
{% set masters = salt.saltutil.runner('manage.up', tgt="k3sm*") %}
{% set workers = salt.saltutil.runner('manage.up', tgt="k3sw*") %}
{% set allnodes = [] %}
{% do allnodes.extend(masters) %}
{% do allnodes.extend(workers) %}

sync_modules_master:
salt.runner:
- name: saltutil.sync_all

sync_minions:
salt.function:
- tgt: "k3s*"
- name: saltutil.sync_all
- kwarg:
refresh: True

#setup_prerequisites:
# salt.state:
# - tgt: "k3s*"
# - sls:
# - os.boot
# - require:
# - salt: sync_modules_master
# - salt: sync_minions
#restart_nodes:
# salt.function:
# - tgt: {{ allnodes|tojson }}
# - tgt_type: list
# - name: cmd.run
# - arg:
# - reboot
# - require:
# - salt: setup_prerequisites
#wait_for_restart:
# salt.wait_for_event:
# - name: salt/minion/*/start
# - id_list: {{ allnodes|tojson }}
# - require:
# - salt: restart_nodes

setup_k3s_single_master:
salt.state:
- tgt: "k3sm1*"
- highstate: True
- pillar:
kubernetes:
nodes:
masters: {{ salt.saltutil.runner('manage.up', tgt="k3sm*") }}
workers: {{ salt.saltutil.runner('manage.up', tgt="k3sw*") }}
masters: {{ masters|tojson }}
workers: {{ workers|tojson }}
- require:
- salt: sync_modules_master
- salt: sync_modules_master
- salt: sync_minions

setup_k3s_workers:
salt.state:
Expand All @@ -21,7 +59,7 @@ setup_k3s_workers:
- pillar:
kubernetes:
nodes:
masters: {{ salt.saltutil.runner('manage.up', tgt="k3sm*") }}
workers: {{ salt.saltutil.runner('manage.up', tgt="k3sw*") }}
masters: {{ masters|tojson }}
workers: {{ workers|tojson }}
- require:
- salt: setup_k3s_single_master
15 changes: 15 additions & 0 deletions salt/os/boot/init.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{%- from "os/boot/map.jinja" import boot with context %}
{% for file in boot.files %}
{{ file.name }}:
file.managed:
- name: {{ file.name }}
- contents: {{ file.contents }}
{% if 'mode' in file %}
- mode: {{ file.mode }}
{% endif %}
- user: {{ file.user|default("root") }}
- group: {{ file.group|default("root") }}
- makedirs: True
- contents_newline: False
{% endfor %}
5 changes: 5 additions & 0 deletions salt/os/boot/map.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{% set boot = salt['grains.filter_by']({
'default': {
'files': [],
},
}, merge=salt['pillar.get']('boot')) %}
1 change: 1 addition & 0 deletions salt/os/init.sls
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{%- from "os/network/map.jinja" import network with context %}
include:
- os.boot
{%- if network.enabled %}
# included only upon explicit request
- os.network
Expand Down
15 changes: 4 additions & 11 deletions salt/salt/map.jinja
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{% set arch = salt['grains.get']("osarch") %}

{% set salt_installer = salt['grains.filter_by']({
'default': {
'repository': {
Expand Down Expand Up @@ -27,25 +29,16 @@
'bookworm': {
'repository': {
'names': [
"deb [arch=amd64] https://repo.saltproject.io/salt/py3/debian/12/amd64/latest bookworm main"
"deb [arch=" ~ arch ~ "] https://repo.saltproject.io/salt/py3/debian/12/amd64/latest bookworm main"
],
'key_url': "https://repo.saltproject.io/salt/py3/debian/12/arm64/SALT-PROJECT-GPG-PUBKEY-2023.gpg",
'origin': 'bookworm'
}
},
'bullseye': {
'repository': {
'names': [
"deb [arch=amd64] https://repo.saltproject.io/salt/py3/debian/11/amd64/latest bullseye main"
],
'key_url': "https://repo.saltproject.io/salt/py3/debian/11/amd64/SALT-PROJECT-GPG-PUBKEY-2023.gpg",
'origin': 'bullseye'
}
},
'focal': {
'repository': {
'names': [
"deb [arch=amd64] https://repo.saltproject.io/salt/py3/ubuntu/20.04/amd64/latest focal main"
"deb [arch=" ~ arch ~ "] https://repo.saltproject.io/salt/py3/ubuntu/20.04/amd64/latest focal main"
],
'key_url': "https://repo.saltproject.io/salt/py3/ubuntu/20.04/amd64/SALT-PROJECT-GPG-PUBKEY-2023.gpg",
'origin': 'focal'
Expand Down

0 comments on commit eccb68b

Please sign in to comment.