Verified Commit 7da4e3f2 authored by Hugo's avatar Hugo
Browse files

disks & addons

parent 54650547
# ada-lovelace-cluster
Ada Lovelace cluster IaC
\ No newline at end of file
Ada Lovelace cluster IaC
## Pre-requis
- terraform
- ansible
- python
```
ansible-galaxy install -r requirements.yaml
pip3 install openshift
```
......@@ -11,7 +11,9 @@ api:
ingress:
lbType: lb11
privateIp: 10.0.1.6
ports: ["80", "443"]
ports:
80: "32080"
443: "32443"
nodes:
c1:
type: vm
......
- name: destroy infrastructure
hosts: localhost
tasks:
- name: remove k0s conf
file:
path: k0sctl.yaml
state: absent
- name: run terraform
community.general.terraform:
project_path: "terraform/"
......
apiVersion: helm.k0sproject.io/v1beta1
kind: Chart
metadata:
name: cert-manager
namespace: "kube-system"
spec:
chartName: jetstack/cert-manager
namespace: cert-manager
version: 1.3.1
values: ""
apiVersion: helm.k0sproject.io/v1beta1
kind: Chart
metadata:
name: ingress-nginx
namespace: "kube-system"
spec:
chartName: ingress-nginx/ingress-nginx
namespace: ingress-nginx
version: 3.30.0
values: ""
apiVersion: helm.k0sproject.io/v1beta1
kind: Chart
metadata:
name: prometheus-stack
namespace: "kube-system"
spec:
chartName: prometheus-community/kube-prometheus-stack
namespace: monitoring
version: 15.4.5
values: ""
---
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: local-storage
provisioner: kubernetes.io/no-provisioner
volumeBindingMode: WaitForFirstConsumer
---
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: openebs-lvm
allowVolumeExpansion: true
volumeBindingMode: WaitForFirstConsumer
parameters:
fstype: "xfs"
volgroup: "vg-k8s"
provisioner: local.csi.openebs.io
......@@ -21,9 +21,4 @@
hosts: localhost
tasks:
- import_tasks: "tasks/deploy.yaml"
- name: deploy addons
hosts: controller
remote_user: root
tasks:
- import_tasks: "tasks/addons.yaml"
collections:
- kubernetes.core
- ansible.posix
- name: synchronization addons
ansible.posix.synchronize:
src: "addons/{{item}}/"
dest: "/var/lib/k0s/manifests/{{item}}"
delete: yes
- name: set ingress label
kubernetes.core.k8s:
kubeconfig: kubeconfig
state: present
definition:
apiVersion: v1
kind: Node
metadata:
name: "{{ cluster.name }}-{{ item.key }}"
labels:
ingress: "{{ item.value.ingress | string | lower }}"
loop: "{{ cluster.nodes | dict2items }}"
loop_control:
label: "{{ item.key }}"
when: item.value.role == "worker"
- name: add chart repositories
kubernetes.core.helm_repository:
name: "{{ item.name }}"
repo_url: "{{ item.url }}"
loop:
- helm
- openebs
- name: stable
url: https://charts.helm.sh/stable
- name: prometheus-community
url: https://prometheus-community.github.io/helm-charts
- name: openebs
url: https://openebs.github.io/charts
- name: openebs-lvmlocalpv
url: https://openebs.github.io/lvm-localpv
- name: ingress-nginx
url: https://kubernetes.github.io/ingress-nginx
- name: jetstack
url: https://charts.jetstack.io
- name: minio
url: https://operator.min.io/
loop_control:
label: "{{ item.name }}"
- name: deploy cert-manager
kubernetes.core.helm:
kubeconfig: kubeconfig
update_repo_cache: yes
create_namespace: yes
name: cert-manager
chart_ref: jetstack/cert-manager
release_namespace: cert-manager
chart_version: 1.3.1
values:
installCRDs: true
- name: deploy ingress-nginx
kubernetes.core.helm:
kubeconfig: kubeconfig
update_repo_cache: yes
create_namespace: yes
name: ingress-nginx
chart_ref: ingress-nginx/ingress-nginx
release_namespace: ingress-nginx
chart_version: 3.30.0
values:
controller:
kind: DaemonSet
nodeSelector:
kubernetes.io/os: linux
ingress: "true"
service:
type: NodePort
nodePorts:
http: "32080"
https: "32443"
- name: deploy prometheus-stack
kubernetes.core.helm:
kubeconfig: kubeconfig
update_repo_cache: yes
create_namespace: yes
name: prometheus-stack
chart_ref: prometheus-community/kube-prometheus-stack
release_namespace: monitoring
chart_version: 15.4.5
- name: deploy openebs-lvmlocalpv
kubernetes.core.helm:
kubeconfig: kubeconfig
update_repo_cache: yes
name: openebs-lvmlocalpv
chart_ref: openebs-lvmlocalpv/lvm-localpv
release_namespace: kube-system
chart_version: 0.5.0
values:
lvmNode:
kubeletDir: "/var/lib/k0s/kubelet/"
- name: deploy persistent volumes
kubernetes.core.k8s:
kubeconfig: kubeconfig
state: present
template: "pvs.yaml.j2"
- name: deploy storage classes
kubernetes.core.k8s:
kubeconfig: kubeconfig
state: present
src: "files/scs.yaml"
......@@ -26,19 +26,30 @@
dest: "/var/lib/kubelet"
state: link
- name: read device information
community.general.parted:
device: "{{ item }}"
unit: GiB
loop: "{{ node_disks }}"
register: diskinfo
- debug:
var: diskinfo
- name: create a volume group
community.general.lvg:
vg: vg-k8s
pvs: "{{ node_pvs }}"
pvresize: yes
when: node_pvs | length > 0
- name: create disks folder
file:
path: /mnt/disks
state: directory
- name: format disks
community.general.filesystem:
fstype: xfs
dev: "{{ item }}"
loop: "{{ node_disks }}"
- name: mount disks
ansible.posix.mount:
path: "/mnt/disks/{{item.key}}"
src: "{{ item.value.device }}"
fstype: xfs
state: mounted
loop: "{{ node.volumes | dict2items | selectattr('value.vg', 'false') }}"
loop_control:
label: "{{ item.key }}"
......@@ -29,18 +29,5 @@ spec:
mtu: 1440
wireguard: true
ipAutodetectionMethod: cidr={{cluster.network.cloudCidr}}
extensions:
helm:
repositories:
- name: stable
url: https://charts.helm.sh/stable
- name: prometheus-community
url: https://prometheus-community.github.io/helm-charts
- name: openebs
url: https://openebs.github.io/charts
- name: ingress-nginx
url: https://kubernetes.github.io/ingress-nginx
- name: jetstack
url: https://charts.jetstack.io
- name: minio
url: https://operator.min.io/
telemetry:
enabled: false
{% for node in cluster.nodes | dict2items %}
{% for volume in node.value.volumes | dict2items %}
{% if volume.value.vg == false %}
---
apiVersion: v1
kind: PersistentVolume
metadata:
name: "{{node.key}}-{{volume.key}}"
spec:
capacity:
storage: "{{volume.value.size}}Gi"
volumeMode: Filesystem
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
storageClassName: local-storage
local:
path: "/mnt/disks/{{volume.key}}"
nodeAffinity:
required:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- "{{cluster.name}}-{{node.key}}"
{% endif %}
{% endfor %}
{% endfor %}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment