feat: splitted lb and ingress and added service_account

This commit is contained in:
Simon Cornet 2025-09-17 08:12:50 +02:00
commit 59fb6fe9da
3 changed files with 138 additions and 50 deletions

View file

@ -1,54 +1,6 @@
# Basics
# Ingress Controller
Lets install a basic loadbalancer (MetalLB) and ingress controller (NGINX or Traefik) on a basic Talos Linux cluster
using 3 dedicated (to be labelled) worker nodes.
## MetalLB
```shell
# add repo and install
helm repo add metallb https://metallb.github.io/metallb
helm repo update
helm install metallb metallb/metallb -n metallb-system --create-namespace --wait
# fix pod security for speaker pods
kubectl label namespace metallb-system pod-security.kubernetes.io/enforce=privileged
kubectl label namespace metallb-system pod-security.kubernetes.io/audit=privileged
kubectl label namespace metallb-system pod-security.kubernetes.io/warn=privileged
# restart speaker daemonset
kubectl rollout restart daemonset/metallb-speaker -n metallb-system
```
```shell
# configure metallb
cat <<EOF | kubectl apply -f -
---
apiVersion: metallb.io/v1beta1
kind: IPAddressPool
metadata:
name: ingress-pool
namespace: metallb-system
spec:
addresses:
- 10.8.15.175/32
---
apiVersion: metallb.io/v1beta1
kind: L2Advertisement
metadata:
name: ingress-pool
namespace: metallb-system
spec:
ipAddressPools:
- ingress-pool
EOF
```
### Uninstall MetalLB
```shell
helm uninstall metallb -n metallb-system
```
Lets install an ingress controller (NGINX or Traefik) on a basic Talos Linux cluster.
## NGINX (option 1)

50
docs/talos-linux/lb.md Normal file
View file

@ -0,0 +1,50 @@
# Loadbalancer
Lets install a loadbalancer (MetalLB) on a Talos Linux cluster.
## MetalLB
```shell
# add repo and install
helm repo add metallb https://metallb.github.io/metallb
helm repo update
helm install metallb metallb/metallb -n metallb-system --create-namespace --wait
# fix pod security for speaker pods
kubectl label namespace metallb-system pod-security.kubernetes.io/enforce=privileged
kubectl label namespace metallb-system pod-security.kubernetes.io/audit=privileged
kubectl label namespace metallb-system pod-security.kubernetes.io/warn=privileged
# restart speaker daemonset
kubectl rollout restart daemonset/metallb-speaker -n metallb-system
```
```shell
# configure metallb
cat <<EOF | kubectl apply -f -
---
apiVersion: metallb.io/v1beta1
kind: IPAddressPool
metadata:
name: ingress-pool
namespace: metallb-system
spec:
addresses:
- 10.8.15.175/32
---
apiVersion: metallb.io/v1beta1
kind: L2Advertisement
metadata:
name: ingress-pool
namespace: metallb-system
spec:
ipAddressPools:
- ingress-pool
EOF
```
### Uninstall MetalLB
```shell
helm uninstall metallb -n metallb-system
```

View file

@ -0,0 +1,86 @@
# Service Account
Lets create a service account for cicd activities in a new namespace.
## Namespace
```yaml
cat <<EOF | kubectl apply -f -
---
apiVersion: "v1"
kind: "Namespace"
metadata:
name: "my-namespace"
EOF
```
## Service Account
```yaml
cat <<EOF | kubectl apply -f -
---
apiVersion: "v1"
kind: "ServiceAccount"
metadata:
name: "buzz"
namespace: "my-namespace"
EOF
```
## Role
```yaml
cat <<EOF | kubectl apply -f -
---
apiVersion: "rbac.authorization.k8s.io/v1"
kind: "Role"
metadata:
namespace: "my-namespace"
name: "buzz-role"
rules:
- apiGroups: ["apps"]
resources: ["deployments"]
verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]
- apiGroups: [""]
resources: ["services", "configmaps", "secrets"]
verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]
- apiGroups: ["networking.k8s.io"]
resources: ["ingresses"]
verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]
EOF
```
## RoleBinding
```yaml
cat <<EOF | kubectl apply -f -
---
apiVersion: "rbac.authorization.k8s.io/v1"
kind: "RoleBinding"
metadata:
name: "buzz-binding"
namespace: "my-namespace"
subjects:
- kind: "ServiceAccount"
name: "buzz"
namespace: "my-namespace"
roleRef:
kind: "Role"
name: "buzz-role"
apiGroup: "rbac.authorization.k8s.io"
EOF
```
## Token and KubeConfig (OmnI)
Get the token for the user.
```shell
kubectl create token buzz -n my-namespace
```
When using OmnI you can get the service account details (kubeconf) using the following command;
```shell
omnictl kubeconfig --service-account -c <cluster-name> --user buzz /tmp/buzz-kubeconfig.yaml
```