From 1db752520e21a2832bfdd3ae2b5fc68750cc9077 Mon Sep 17 00:00:00 2001 From: Edward Cheng Date: Mon, 26 Aug 2024 13:17:53 +1000 Subject: [PATCH 1/2] refactor for metallb --- .../metallb-conf/env/k3s-cluster/advertisement.yaml | 10 ++++++++-- .../metallb-conf/env/k3s-cluster/cluster-ip.yaml | 2 +- .../metallb-conf/env/k3s-cluster/config.json | 4 ++-- .../metallb-conf/env/k3s-cluster/kustomization.yaml | 4 ++-- .../metallb/env/k3s-cluster/kustomization.yaml | 7 ++++--- infrastructures/metallb/env/k3s-cluster/values.yaml | 7 +++++++ .../templates/{metallb-system.yaml => metallb.yaml} | 2 +- 7 files changed, 25 insertions(+), 11 deletions(-) create mode 100644 infrastructures/metallb/env/k3s-cluster/values.yaml rename resources/namespaces/env/k3s-cluster/templates/{metallb-system.yaml => metallb.yaml} (86%) diff --git a/infrastructures/metallb-conf/env/k3s-cluster/advertisement.yaml b/infrastructures/metallb-conf/env/k3s-cluster/advertisement.yaml index 1a9fa24..dcdd3b6 100644 --- a/infrastructures/metallb-conf/env/k3s-cluster/advertisement.yaml +++ b/infrastructures/metallb-conf/env/k3s-cluster/advertisement.yaml @@ -2,7 +2,13 @@ apiVersion: metallb.io/v1beta1 kind: L2Advertisement metadata: name: l2-advertisement - namespace: metallb-system + namespace: metallb spec: ipAddressPools: - - k3s-cluster-ips \ No newline at end of file + - k3s-cluster-ips + nodeSelectors: + - matchExpressions: + - key: kubernetes.io/os + operator: In + values: + - linux \ No newline at end of file diff --git a/infrastructures/metallb-conf/env/k3s-cluster/cluster-ip.yaml b/infrastructures/metallb-conf/env/k3s-cluster/cluster-ip.yaml index 578726c..9ba1ecf 100644 --- a/infrastructures/metallb-conf/env/k3s-cluster/cluster-ip.yaml +++ b/infrastructures/metallb-conf/env/k3s-cluster/cluster-ip.yaml @@ -2,7 +2,7 @@ apiVersion: metallb.io/v1beta1 kind: IPAddressPool metadata: name: k3s-cluster-ips - namespace: metallb-system + namespace: metallb spec: addresses: - 192.168.10.100/32 diff --git a/infrastructures/metallb-conf/env/k3s-cluster/config.json b/infrastructures/metallb-conf/env/k3s-cluster/config.json index af85c10..df65c2a 100644 --- a/infrastructures/metallb-conf/env/k3s-cluster/config.json +++ b/infrastructures/metallb-conf/env/k3s-cluster/config.json @@ -1,8 +1,8 @@ { "appName": "metallb-conf", "userGivenName": "metallb-conf", - "namespace": "metallb-system", - "destNamespace": "metallb-system", + "namespace": "metallb", + "destNamespace": "metallb", "destServer": "https://kubernetes.default.svc", "srcPath": "infrastructures/metallb-conf/env/k3s-cluster", "srcRepoURL": "https://github.com/3dwardch3ng/home-cluster-ops.git", diff --git a/infrastructures/metallb-conf/env/k3s-cluster/kustomization.yaml b/infrastructures/metallb-conf/env/k3s-cluster/kustomization.yaml index b70fdad..1672071 100644 --- a/infrastructures/metallb-conf/env/k3s-cluster/kustomization.yaml +++ b/infrastructures/metallb-conf/env/k3s-cluster/kustomization.yaml @@ -1,5 +1,5 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: - - ./cluster-ip.yaml - - ./advertisement.yaml \ No newline at end of file + - ./advertisement.yaml + - ./cluster-ip.yaml \ No newline at end of file diff --git a/infrastructures/metallb/env/k3s-cluster/kustomization.yaml b/infrastructures/metallb/env/k3s-cluster/kustomization.yaml index f34b4e2..a75e522 100644 --- a/infrastructures/metallb/env/k3s-cluster/kustomization.yaml +++ b/infrastructures/metallb/env/k3s-cluster/kustomization.yaml @@ -2,6 +2,7 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization helmCharts: - name: metallb - repo: https://metallb.github.io/metallb - version: 0.14.8 - releaseName: metallb \ No newline at end of file + repo: oci://registry-1.docker.io/bitnamicharts + version: 6.3.10 + releaseName: metallb + valuesFile: values.yaml \ No newline at end of file diff --git a/infrastructures/metallb/env/k3s-cluster/values.yaml b/infrastructures/metallb/env/k3s-cluster/values.yaml new file mode 100644 index 0000000..abea11d --- /dev/null +++ b/infrastructures/metallb/env/k3s-cluster/values.yaml @@ -0,0 +1,7 @@ +namespaceOverride: "metallb-system" +controller: + podSecurityContext: + fsGroup: 1000 + containerSecurityContext: + runAsUser: 1000 + runAsGroup: 1000 diff --git a/resources/namespaces/env/k3s-cluster/templates/metallb-system.yaml b/resources/namespaces/env/k3s-cluster/templates/metallb.yaml similarity index 86% rename from resources/namespaces/env/k3s-cluster/templates/metallb-system.yaml rename to resources/namespaces/env/k3s-cluster/templates/metallb.yaml index b219659..917148c 100644 --- a/resources/namespaces/env/k3s-cluster/templates/metallb-system.yaml +++ b/resources/namespaces/env/k3s-cluster/templates/metallb.yaml @@ -4,6 +4,6 @@ metadata: annotations: argocd.argoproj.io/sync-options: Prune=false creationTimestamp: null - name: metallb-system + name: metallb spec: {} status: {} From 9ecf48108d06664d0e170fb0c2460abdf1c9c878 Mon Sep 17 00:00:00 2001 From: Edward Cheng Date: Mon, 26 Aug 2024 13:20:07 +1000 Subject: [PATCH 2/2] refactor for metallb --- .../metallb-conf/env/k3s-cluster/advertisement.yaml | 10 ++-------- .../metallb-conf/env/k3s-cluster/cluster-ip.yaml | 2 +- .../metallb-conf/env/k3s-cluster/config.json | 4 ++-- .../metallb-conf/env/k3s-cluster/kustomization.yaml | 4 ++-- .../templates/{metallb.yaml => metallb-system.yaml} | 2 +- 5 files changed, 8 insertions(+), 14 deletions(-) rename resources/namespaces/env/k3s-cluster/templates/{metallb.yaml => metallb-system.yaml} (86%) diff --git a/infrastructures/metallb-conf/env/k3s-cluster/advertisement.yaml b/infrastructures/metallb-conf/env/k3s-cluster/advertisement.yaml index dcdd3b6..1a9fa24 100644 --- a/infrastructures/metallb-conf/env/k3s-cluster/advertisement.yaml +++ b/infrastructures/metallb-conf/env/k3s-cluster/advertisement.yaml @@ -2,13 +2,7 @@ apiVersion: metallb.io/v1beta1 kind: L2Advertisement metadata: name: l2-advertisement - namespace: metallb + namespace: metallb-system spec: ipAddressPools: - - k3s-cluster-ips - nodeSelectors: - - matchExpressions: - - key: kubernetes.io/os - operator: In - values: - - linux \ No newline at end of file + - k3s-cluster-ips \ No newline at end of file diff --git a/infrastructures/metallb-conf/env/k3s-cluster/cluster-ip.yaml b/infrastructures/metallb-conf/env/k3s-cluster/cluster-ip.yaml index 9ba1ecf..578726c 100644 --- a/infrastructures/metallb-conf/env/k3s-cluster/cluster-ip.yaml +++ b/infrastructures/metallb-conf/env/k3s-cluster/cluster-ip.yaml @@ -2,7 +2,7 @@ apiVersion: metallb.io/v1beta1 kind: IPAddressPool metadata: name: k3s-cluster-ips - namespace: metallb + namespace: metallb-system spec: addresses: - 192.168.10.100/32 diff --git a/infrastructures/metallb-conf/env/k3s-cluster/config.json b/infrastructures/metallb-conf/env/k3s-cluster/config.json index df65c2a..af85c10 100644 --- a/infrastructures/metallb-conf/env/k3s-cluster/config.json +++ b/infrastructures/metallb-conf/env/k3s-cluster/config.json @@ -1,8 +1,8 @@ { "appName": "metallb-conf", "userGivenName": "metallb-conf", - "namespace": "metallb", - "destNamespace": "metallb", + "namespace": "metallb-system", + "destNamespace": "metallb-system", "destServer": "https://kubernetes.default.svc", "srcPath": "infrastructures/metallb-conf/env/k3s-cluster", "srcRepoURL": "https://github.com/3dwardch3ng/home-cluster-ops.git", diff --git a/infrastructures/metallb-conf/env/k3s-cluster/kustomization.yaml b/infrastructures/metallb-conf/env/k3s-cluster/kustomization.yaml index 1672071..b70fdad 100644 --- a/infrastructures/metallb-conf/env/k3s-cluster/kustomization.yaml +++ b/infrastructures/metallb-conf/env/k3s-cluster/kustomization.yaml @@ -1,5 +1,5 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: - - ./advertisement.yaml - - ./cluster-ip.yaml \ No newline at end of file + - ./cluster-ip.yaml + - ./advertisement.yaml \ No newline at end of file diff --git a/resources/namespaces/env/k3s-cluster/templates/metallb.yaml b/resources/namespaces/env/k3s-cluster/templates/metallb-system.yaml similarity index 86% rename from resources/namespaces/env/k3s-cluster/templates/metallb.yaml rename to resources/namespaces/env/k3s-cluster/templates/metallb-system.yaml index 917148c..b219659 100644 --- a/resources/namespaces/env/k3s-cluster/templates/metallb.yaml +++ b/resources/namespaces/env/k3s-cluster/templates/metallb-system.yaml @@ -4,6 +4,6 @@ metadata: annotations: argocd.argoproj.io/sync-options: Prune=false creationTimestamp: null - name: metallb + name: metallb-system spec: {} status: {}