feat: metallb, kubegres

This commit is contained in:
ange 2024-02-18 01:56:19 +01:00
parent ab8be47b7b
commit 740b62be58
Signed by: ange
GPG Key ID: 9E0C4157BB7BEB1D
8 changed files with 110 additions and 95 deletions

View File

@ -4,92 +4,92 @@
hosts: all
tasks:
- name: Copy conf
copy:
src: rootfs/
dest: /
- name: Copy conf
copy:
src: rootfs/
dest: /
- name: Restart sshd
service:
name: sshd.service
state: restarted
- name: Restart sshd
service:
name: sshd.service
state: restarted
- name: SSH port 40022
set_fact:
ansible_port: 40022
- name: SSH port 40022
set_fact:
ansible_port: 40022
- name: Add {{ codename }} repo
deb822_repository:
name: debian
types: deb
uris: http://deb.debian.org/debian
suites: "{{ codename }} {{ codename }}-updates {{ codename }}-backports"
components:
- main
- non-free-firmware
- name: Add {{ codename }} repo
deb822_repository:
name: debian
types: deb
uris: http://deb.debian.org/debian
suites: "{{ codename }} {{ codename }}-updates {{ codename }}-backports"
components:
- main
- non-free-firmware
- name: Add {{ codename }}-security repo
deb822_repository:
name: debian-security
types: deb
uris: http://security.debian.org/debian-security/
suites: "{{ codename }}-security"
components:
- main
- non-free-firmware
- name: Add {{ codename }}-security repo
deb822_repository:
name: debian-security
types: deb
uris: http://security.debian.org/debian-security/
suites: "{{ codename }}-security"
components:
- main
- non-free-firmware
- name: Add libcontainers repo (CRI-O)
deb822_repository:
name: libcontainers
types: deb
uris: "https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/{{ os }}/"
suites: /
signed_by: "https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/{{ os }}/Release.key"
- name: Add libcontainers repo (CRI-O)
deb822_repository:
name: libcontainers
types: deb
uris: "https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/{{ os }}/"
suites: /
signed_by: "https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/{{ os }}/Release.key"
- name: Add libcontainers-crio repo (CRI-O)
deb822_repository:
name: libcontainers-crio
types: deb
uris: "https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable:/cri-o:/{{ k8s_version }}/{{ os }}/"
suites: /
signed_by: "https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable:/cri-o:/{{ k8s_version }}/{{ os }}/Release.key"
- name: Add libcontainers-crio repo (CRI-O)
deb822_repository:
name: libcontainers-crio
types: deb
uris: "https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable:/cri-o:/{{ k8s_version }}/{{ os }}/"
suites: /
signed_by: "https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable:/cri-o:/{{ k8s_version }}/{{ os }}/Release.key"
- name: Add k8s repo
deb822_repository:
name: k8s
types: deb
uris: "https://pkgs.k8s.io/core:/stable:/v{{ k8s_version }}/deb/"
suites: /
signed_by: "https://pkgs.k8s.io/core:/stable:/v{{ k8s_version }}/deb/Release.key"
- name: Add k8s repo
deb822_repository:
name: k8s
types: deb
uris: "https://pkgs.k8s.io/core:/stable:/v{{ k8s_version }}/deb/"
suites: /
signed_by: "https://pkgs.k8s.io/core:/stable:/v{{ k8s_version }}/deb/Release.key"
- name: Upgrade
apt:
update_cache: true
upgrade: dist
autoremove: true
purge: true
- name: Upgrade
apt:
update_cache: true
upgrade: dist
autoremove: true
purge: true
- name: Install pkgs
apt:
install_recommends: false
name:
- ceph
- ceph-common
- cri-o
- cri-o-runc
- cri-tools
- cron
- iptables-persistent
- kubeadm
- kubectl
- kubectx
- kubelet
- vim
- name: Install pkgs
apt:
install_recommends: false
name:
- ceph
- ceph-common
- cri-o
- cri-o-runc
- cri-tools
- cron
- iptables-persistent
- kubeadm
- kubectl
- kubectx
- kubelet
- vim
- name: Enable crio service
service:
name: crio.service
enabled: true
- name: Enable crio service
service:
name: crio.service
enabled: true
- name: Reboot
reboot:
- name: Reboot
reboot:

View File

@ -7,15 +7,25 @@
KUBECONFIG: /etc/kubernetes/admin.conf
tasks:
- name: Init k8s
shell: kubeadm init --pod-network-cidr=10.244.0.0/16 --control-plane-endpoint="{{ endpoint }}"
- name: Remove master node taint
shell: kubectl taint node --all node-role.kubernetes.io/control-plane:NoSchedule-
- name: Apply flannel
shell: kubectl apply -f https://github.com/flannel-io/flannel/releases/latest/download/kube-flannel.yml
- name: Apply nginx ingress
shell: kubectl apply -f "https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v{{ nginx_version }}/deploy/static/provider/baremetal/deploy.yaml"
- name: Apply cert-manager
shell: kubectl apply -f "https://github.com/cert-manager/cert-manager/releases/download/v{{ certmanager_version }}/cert-manager.yaml"
- name: Reboot
reboot:
- name: Init k8s
shell: kubeadm init --pod-network-cidr=10.244.0.0/16 --control-plane-endpoint="{{ endpoint }}"
- name: Remove master node taint
shell: kubectl taint node --all node-role.kubernetes.io/control-plane:NoSchedule-
- name: Apply flannel
shell: kubectl apply -f "https://github.com/flannel-io/flannel/releases/latest/download/kube-flannel.yml"
- name: Apply metallb
shell: kubectl apply -f "https://raw.githubusercontent.com/metallb/metallb/v{{ mettallb_version }}/config/manifests/metallb-native.yaml"
- name: Apply nginx ingress
shell: kubectl apply -f "https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v{{ nginx_version }}/deploy/static/provider/baremetal/deploy.yaml"
- name: Apply cert-manager
shell: kubectl apply -f "https://github.com/cert-manager/cert-manager/releases/latest/download/cert-manager.yaml"
- name: Apply kubegres
shell: kubectl apply -f "https://raw.githubusercontent.com/reactive-tech/kubegres/v{{ kubegres_version }}/kubegres.yaml"
- name: Apply manifests
shell: |
kubectl apply -f - <<EOF
{{ lookup('template', '{{ item }}') }}
EOF
with_fileglob: 'manifests/*.yaml'
- name: Reboot
reboot:

View File

@ -1,6 +1,6 @@
#!/bin/bash -e
endpoint="$(awk -F '[ \t]*:[ \t]*' '$1 == "endpoint" {print $NF}' group_vars/all)"
endpoint="$(sed -n 's/^endpoint:\s*//p' group_vars/all)"
ssh "$endpoint" sudo cat /etc/kubernetes/admin.conf > kubeconfig
chmod 600 kubeconfig

View File

@ -5,6 +5,10 @@ arch: amd64
os: Debian_12
codename: bookworm
k8s_version: 1.27 # https://kubernetes.io/releases/patch-releases/#detailed-release-history-for-active-branches
metallb_version: 0.14.3 # https://github.com/metallb/metallb/releases
nginx_version: 1.9.6 # https://github.com/kubernetes/ingress-nginx/releases
certmanager_version: 1.14.2 # https://github.com/cert-manager/cert-manager/releases/
kubegres_version: 1.17 # https://github.com/reactive-tech/kubegres/releases
# TODO
rook_version: 1.13.4 # https://github.com/rook/rook/releases
nfs_version: 4.6.0 # https://github.com/kubernetes-csi/csi-driver-nfs/releases

View File

@ -1,6 +1,7 @@
apiVersion: v1
data:
use-proxy-protocol: "true"
allow-snippet-annotations: "true"
kind: ConfigMap
metadata:
name: ingress-nginx-controller

View File

@ -7,7 +7,7 @@ metadata:
app.kubernetes.io/instance: ingress-nginx
app.kubernetes.io/name: ingress-nginx
app.kubernetes.io/part-of: ingress-nginx
app.kubernetes.io/version: 1.9.6
app.kubernetes.io/version: "{{ nginx_version }}"
name: ingress-nginx-controller
namespace: ingress-nginx
spec:

View File

@ -5,7 +5,7 @@ metadata:
name: letsencrypt-prod
spec:
acme:
email: ange@yw5n.com
email: "{{ letsencrypt_email }}"
privateKeySecretRef:
name: letsencrypt-prod
server: https://acme-v02.api.letsencrypt.org/directory

View File

@ -5,7 +5,7 @@ metadata:
name: letsencrypt-staging
spec:
acme:
email: ange@yw5n.com
email: "{{ letsencrypt_email }}"
privateKeySecretRef:
name: letsencrypt-staging
server: https://acme-staging-v02.api.letsencrypt.org/directory