This commit is contained in:
jonas 2021-10-19 11:54:30 +02:00
parent be783f12ed
commit 6edffbc0fd
25 changed files with 139 additions and 89 deletions

View File

@ -1,11 +0,0 @@
apiVersion: harvesterhci.io/v1beta1
kind: VirtualMachineImage
metadata:
name: 56e5b8adb10
namespace: default
spec:
displayName: opensuse-leap-15.3-jeos.x86_64-kvm-and-xen.qcow2
pvcName: ""
pvcNamespace: ""
sourceType: download
url: http://172.18.0.1/images/openSUSE-Leap-15.3-JeOS.x86_64-kvm-and-xen.qcow2

View File

@ -1,7 +0,0 @@
apiVersion: k8s.cni.cncf.io/v1
kind: NetworkAttachmentDefinition
metadata:
name: airgap
namespace: default
spec:
config: '{"cniVersion":"0.3.1","name":"airgap","type":"bridge","bridge":"harvester-br0","promiscMode":true,"vlan":250,"ipam":{}}'

View File

@ -1,7 +0,0 @@
apiVersion: k8s.cni.cncf.io/v1
kind: NetworkAttachmentDefinition
metadata:
name: public-1
namespace: default
spec:
config: '{"cniVersion":"0.3.1","name":"public-1","type":"bridge","bridge":"harvester-br0","promiscMode":true,"vlan":100,"ipam":{}}'

View File

@ -1,7 +0,0 @@
apiVersion: k8s.cni.cncf.io/v1
kind: NetworkAttachmentDefinition
metadata:
name: public-2
namespace: default
spec:
config: '{"cniVersion":"0.3.1","name":"public-2","type":"bridge","bridge":"harvester-br0","promiscMode":true,"vlan":200,"ipam":{}}'

View File

@ -1,12 +0,0 @@
harvester:
version: 0.3.0
dns_host: harvester
password: rancher
token: ThisShouldBeConfiguredInYour_local.sls
os:
ssh_authorized_keys: []
password: rancher
install:
mgmt-interface: enp2s0f0
device: /dev/nvme0n1

View File

@ -0,0 +1,27 @@
tlu-harvester:
version: 0.3.0
dns_host: harvester
password: rancher
token: ThisShouldBeConfiguredInYour_local.sls
os:
ssh_authorized_keys: []
password: rancher
install:
mgmt-interface: enp2s0f0
device: /dev/nvme0n1
images:
opensuse:
- name: openSUSE Leap 15.3
url: https://download.opensuse.org/distribution/leap/15.3/appliances/openSUSE-Leap-15.3-JeOS.x86_64-kvm-and-xen.qcow2
checksum: da11e3ed78cdadb0c8a15e9dd82c3c2b2746ba61cb98c3c03cfb156e5b8adb10
ns: default
ubuntu:
- name: ubuntu 20.04 (Focal Fossa)
url: https://cloud-images.ubuntu.com/focal/20211015/focal-server-cloudimg-amd64-disk-kvm.img
checksum: 8ba7a402852a8379ecc305fd518d26cdf012e7809134c3d2d4029a67990c8e33
ns: default
- name: ubuntu 21.04 (Hirsute Hippo)
url: https://cloud-images.ubuntu.com/hirsute/20211017/hirsute-server-cloudimg-amd64-disk-kvm.img
checksum: 0c4113189d14f4d4d1a8933318b40f69500bbe9ebf58864703a3e333f5355065

View File

@ -10,8 +10,7 @@ base:
- wireguard - wireguard
- hostapd - hostapd
- pxe - pxe
- harvester_cluster - tlu-harvester
- images
{% if salt['pillar.file_exists']('local.sls') %} {% if salt['pillar.file_exists']('local.sls') %}
- local - local
{% endif %} {% endif %}

View File

@ -17,6 +17,9 @@ menuentry 'Continue to normal BIOS boot' --id boot-bios --class exit {
submenu "Harvester ->" { submenu "Harvester ->" {
configfile harvester.cfg configfile harvester.cfg
} }
submenu "TLU Harvester Cluster->" {
configfile tlu-harvester.cfg
}
submenu "openSUSE ->" { submenu "openSUSE ->" {

View File

@ -0,0 +1,9 @@
# Visual
GRUB_GFXMODE=1024x768x32
GRUB_GFXPAYLOAD_LINUX=keep
## Menu Colours
set menu_color_normal=white/black
set menu_color_highlight=white/green
menuentry 'Harvester 0.3.0' --class os {
}

View File

@ -2,14 +2,6 @@
set menu_color_normal=white/black set menu_color_normal=white/black
set menu_color_highlight=white/green set menu_color_highlight=white/green
{% for node in ['node1', 'node2', 'node3'] -%}
menuentry 'TLU Harvester {{ pillar['harvester']['version'] }} {{ node }}' --class os {
linux harvester-v{{ pillar['harvester']['version'] }}-vmlinuz-amd64 nomodeset initrd=harvester-v{{ pillar['harvester']['version'] }}-initrd-amd64 ip=dhcp net.ifnames=1 rd.cos.disable rd.noverifyssl console=tty1 root=live:http://{{ pillar['network']['ip'] }}/harvester/harvester-v{{ pillar['harvester']['version'] }}-rootfs-amd64.squashfs harvester.install.automatic=true harvester.install.config_url=http://{{ pillar['network']['ip'] }}/harvester/{{ node }}.yaml
initrd harvester-v{{ pillar['harvester']['version'] }}-initrd-amd64
boot
}
{% endfor %}
{% for item in pillar['pxe']['harvester'] -%} {% for item in pillar['pxe']['harvester'] -%}
menuentry 'Harvester {{ item['version'] }}' --class os { menuentry 'Harvester {{ item['version'] }}' --class os {
linux harvester-v{{ item['version'] }}-vmlinuz-amd64 nomodeset initrd=harvester-v{{ item['version'] }}-initrd-amd64 ip=dhcp net.ifnames=1 rd.cos.disable rd.noverifyssl console=tty1 root=live:http://{{ pillar['network']['ip'] }}/harvester/harvester-v{{ item['version'] }}-rootfs-amd64.squashfs iso_url=http://{{ pillar['network']['ip'] }}/harvester/harvester-v{{ item['version'] }}-amd64.iso linux harvester-v{{ item['version'] }}-vmlinuz-amd64 nomodeset initrd=harvester-v{{ item['version'] }}-initrd-amd64 ip=dhcp net.ifnames=1 rd.cos.disable rd.noverifyssl console=tty1 root=live:http://{{ pillar['network']['ip'] }}/harvester/harvester-v{{ item['version'] }}-rootfs-amd64.squashfs iso_url=http://{{ pillar['network']['ip'] }}/harvester/harvester-v{{ item['version'] }}-amd64.iso

View File

@ -45,14 +45,3 @@ Update harvester grub file:
- user: root - user: root
- group: root - group: root
- mode: "0644" - mode: "0644"
{% for node in ['node1', 'node2', 'node3'] -%}
Create tlu harvester cluster yaml for {{ node }}:
file.managed:
- name: /srv/www/htdocs/harvester/{{ node }}.yaml
- source: salt://pxe/harvester/files/{{ node }}.yaml.jinja
- template: jinja
- user: root
- group: root
- mode: "0644"
{% endfor %}

View File

@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore

View File

@ -0,0 +1,16 @@
{% for dist, items in pillar['tlu-harvester']['images'].items() -%}
{% for item in items -%}
---
apiVersion: harvesterhci.io/v1beta1
kind: VirtualMachineImage
metadata:
name: {{ item['checksum'][-10:] }}
namespace: {{ item['ns'] | default('default') }}
spec:
displayName: {{ item['name'] | default(item['url'].split('/')[-1]) }}
pvcName: ""
pvcNamespace: ""
sourceType: download
url: http://{{ pillar['network']['ip'] }}/images/{{ dist }}/{{ item['url'].split('/')[-1] }}
{% endfor -%}
{% endfor -%}

View File

@ -0,0 +1,10 @@
{% for vlan in pillar['network']['vlan'] %}
---
apiVersion: k8s.cni.cncf.io/v1
kind: NetworkAttachmentDefinition
metadata:
name: {{ vlan['zone'] }}-{{ vlan['id'] }}
namespace: default
spec:
config: '{"cniVersion":"0.3.1","name":"{{ vlan['zone'] }}-{{ vlan['id'] }}","type":"bridge","bridge":"harvester-br0","promiscMode":true,"vlan":{{ vlan['id'] }},"ipam":{}}'
{% endfor %}

View File

@ -1,11 +1,11 @@
token: {{ pillar['harvester']['token'] }} token: {{ pillar['tlu-harvester']['token'] }}
os: os:
ssh_authorized_keys: {{ pillar['harvester']['os']['ssh_authorized_keys'] }} ssh_authorized_keys: {{ pillar['tlu-harvester']['os']['ssh_authorized_keys'] }}
hostname: node1 hostname: node1
password: {{ pillar['harvester']['os']['password'] }} password: {{ pillar['tlu-harvester']['os']['password'] }}
dns_nameservers: dns_nameservers:
- {{ pillar['network']['ip'] }} - {{ pillar['network']['ip'] }}
password: {{ pillar['harvester']['os']['password'] }} password: {{ pillar['tlu-harvester']['os']['password'] }}
ntp_servers: ntp_servers:
- {{ pillar['network']['ip'] }} - {{ pillar['network']['ip'] }}
write_files: write_files:
@ -23,13 +23,13 @@ install:
networks: networks:
harvester-mgmt: harvester-mgmt:
interfaces: interfaces:
- name: {{ pillar['harvester']['install']['mgmt-interface'] }} - name: {{ pillar['tlu-harvester']['install']['mgmt-interface'] }}
method: static method: static
ip: {{ pillar['network']['ip'][0:-1] }}{{ pillar['network']['hosts']['node1'] }} ip: {{ pillar['network']['ip'][0:-1] }}{{ pillar['network']['hosts']['node1'] }}
subnet_mask: 255.255.255.0 subnet_mask: 255.255.255.0
gateway: {{ pillar['network']['ip'] }} gateway: {{ pillar['network']['ip'] }}
default_route: true default_route: true
device: {{ pillar['harvester']['device'] }} device: {{ pillar['tlu-harvester']['device'] }}
iso_url: http://{{ pillar['network']['ip'] }}/harvester/harvester-v{{ pillar['harvester']['version'] }}-amd64.iso iso_url: http://{{ pillar['network']['ip'] }}/harvester/harvester-v{{ pillar['tlu-harvester']['version'] }}-amd64.iso
vip: {{ pillar['network']['ip'][0:-1] }}{{ pillar['network']['hosts']['harvester'] }} vip: {{ pillar['network']['ip'][0:-1] }}{{ pillar['network']['hosts']['harvester'] }}
vip_mode: static vip_mode: static

View File

@ -1,12 +1,12 @@
server_url: https://harvester.{{ pillar['network']['domain'] }}:8443 server_url: https://harvester.{{ pillar['network']['domain'] }}:8443
token: {{ pillar['harvester']['token'] }} token: {{ pillar['tlu-harvester']['token'] }}
os: os:
ssh_authorized_keys: {{ pillar['harvester']['os']['ssh_authorized_keys'] }} ssh_authorized_keys: {{ pillar['tlu-harvester']['os']['ssh_authorized_keys'] }}
hostname: node2 hostname: node2
password: {{ pillar['harvester']['os']['password'] }} password: {{ pillar['tlu-harvester']['os']['password'] }}
dns_nameservers: dns_nameservers:
- {{ pillar['network']['ip'] }} - {{ pillar['network']['ip'] }}
password: {{ pillar['harvester']['os']['password'] }} password: {{ pillar['tlu-harvester']['os']['password'] }}
ntp_servers: ntp_servers:
- {{ pillar['network']['ip'] }} - {{ pillar['network']['ip'] }}
write_files: write_files:
@ -24,11 +24,11 @@ install:
networks: networks:
harvester-mgmt: harvester-mgmt:
interfaces: interfaces:
- name: {{ pillar['harvester']['install']['mgmt-interface'] }} - name: {{ pillar['tlu-harvester']['install']['mgmt-interface'] }}
method: static method: static
ip: {{ pillar['network']['ip'][0:-1] }}{{ pillar['network']['hosts']['node2'] }} ip: {{ pillar['network']['ip'][0:-1] }}{{ pillar['network']['hosts']['node2'] }}
subnet_mask: 255.255.255.0 subnet_mask: 255.255.255.0
gateway: {{ pillar['network']['ip'] }} gateway: {{ pillar['network']['ip'] }}
default_route: true default_route: true
device: {{ pillar['harvester']['device'] }} device: {{ pillar['tlu-harvester']['device'] }}
iso_url: http://{{ pillar['network']['ip'] }}/harvester/harvester-v{{ pillar['harvester']['version'] }}-amd64.iso iso_url: http://{{ pillar['network']['ip'] }}/harvester/harvester-v{{ pillar['tlu-harvester']['version'] }}-amd64.iso

View File

@ -1,12 +1,12 @@
server_url: https://harvester.{{ pillar['network']['domain'] }}:8443 server_url: https://harvester.{{ pillar['network']['domain'] }}:8443
token: {{ pillar['harvester']['token'] }} token: {{ pillar['tlu-harvester']['token'] }}
os: os:
ssh_authorized_keys: {{ pillar['harvester']['os']['ssh_authorized_keys'] }} ssh_authorized_keys: {{ pillar['tlu-harvester']['os']['ssh_authorized_keys'] }}
hostname: node3 hostname: node3
password: {{ pillar['harvester']['os']['password'] }} password: {{ pillar['tlu-harvester']['os']['password'] }}
dns_nameservers: dns_nameservers:
- {{ pillar['network']['ip'] }} - {{ pillar['network']['ip'] }}
password: {{ pillar['harvester']['os']['password'] }} password: {{ pillar['tlu-harvester']['os']['password'] }}
ntp_servers: ntp_servers:
- {{ pillar['network']['ip'] }} - {{ pillar['network']['ip'] }}
write_files: write_files:
@ -24,11 +24,11 @@ install:
networks: networks:
harvester-mgmt: harvester-mgmt:
interfaces: interfaces:
- name: {{ pillar['harvester']['install']['mgmt-interface'] }} - name: {{ pillar['tlu-harvester']['install']['mgmt-interface'] }}
method: static method: static
ip: {{ pillar['network']['ip'][0:-1] }}{{ pillar['network']['hosts']['node3'] }} ip: {{ pillar['network']['ip'][0:-1] }}{{ pillar['network']['hosts']['node3'] }}
subnet_mask: 255.255.255.0 subnet_mask: 255.255.255.0
gateway: {{ pillar['network']['ip'] }} gateway: {{ pillar['network']['ip'] }}
default_route: true default_route: true
device: {{ pillar['harvester']['device'] }} device: {{ pillar['tlu-harvester']['device'] }}
iso_url: http://{{ pillar['network']['ip'] }}/harvester/harvester-v{{ pillar['harvester']['version'] }}-amd64.iso iso_url: http://{{ pillar['network']['ip'] }}/harvester/harvester-v{{ pillar['tlu-harvester']['version'] }}-amd64.iso

View File

@ -0,0 +1,11 @@
## Menu Colours
set menu_color_normal=white/black
set menu_color_highlight=white/green
{% for node in ['node1', 'node2', 'node3'] -%}
menuentry 'TLU Harvester {{ pillar['tlu-harvester']['version'] }} {{ node }}' --class os {
linux harvester-v{{ pillar['tlu-harvester']['version'] }}-vmlinuz-amd64 nomodeset initrd=harvester-v{{ pillar['tlu-harvester']['version'] }}-initrd-amd64 ip=dhcp net.ifnames=1 rd.cos.disable rd.noverifyssl console=tty1 root=live:http://{{ pillar['network']['ip'] }}/harvester/harvester-v{{ pillar['tlu-harvester']['version'] }}-rootfs-amd64.squashfs harvester.install.automatic=true harvester.install.config_url=http://{{ pillar['network']['ip'] }}/harvester/{{ node }}.yaml
initrd harvester-v{{ pillar['tlu-harvester']['version'] }}-initrd-amd64
boot
}
{% endfor %}

View File

@ -1,9 +1,9 @@
{% for distname, items in pillar['images'].items() %} {% for dist, items in pillar['tlu-harvester']['images'].items() %}
{% for item in items %} {% for item in items %}
{% set filename = item['url'].split('/')[-1] %} {% set filename = item['url'].split('/')[-1] %}
Downloading image {{ filename }}: Downloading image {{ filename }}:
file.managed: file.managed:
- name: /srv/www/htdocs/images/{{ filename }} - name: /srv/www/htdocs/images/{{ dist }}/{{ filename }}
- source: {{ item['url'] }} - source: {{ item['url'] }}
- source_hash: {{ item['checksum'] }} - source_hash: {{ item['checksum'] }}
- user: root - user: root

View File

@ -0,0 +1,4 @@
include:
- tlu-harvester.pxe
- tlu-harvester.manifests
- tlu-harvester.images

View File

@ -0,0 +1,11 @@
Add tlu-harvester manifests:
file.recurse:
- name: /home/{{ pillar['username'] }}/tlu-harvester
- source: salt://tlu-harvester/files/manifests
- template: jinja
- user: {{ pillar['username'] }}
- group: users
- file_mode: "0600"
- include_empty: True
- makedirs: True
- dir_modes: "0700"

View File

@ -0,0 +1,19 @@
{% for node in ['node1', 'node2', 'node3'] -%}
Create tlu harvester cluster yaml for {{ node }}:
file.managed:
- name: /srv/www/htdocs/harvester/{{ node }}.yaml
- source: salt://tlu-harvester/files/{{ node }}.yaml.jinja
- template: jinja
- user: root
- group: root
- mode: "0644"
{% endfor %}
Update harvester grub file:
file.managed:
- name: /srv/tftpboot/tlu-harvester.cfg
- source: salt://tlu-harvester/files/tlu-harvester.cfg.jinja
- template: jinja
- user: root
- group: root
- mode: "0644"

View File

@ -15,4 +15,4 @@ base:
- docker.registry - docker.registry
- remote-desktop - remote-desktop
- wol - wol
- images - tlu-harvester