03 Mise en place de Kubernetes
Installation et configuration de Cilium (CNI), Envoy Gateway et cert-manager pour Kubernetes
Table des matières
Prérequis
talosctlinstallékubectlinstallé- Machine physique ou VM avec au moins 2 cœurs CPU et 4 Go de RAM.
- Image Talos Linux avec les extensions
siderolabs/util-linux-toolsetsiderolabs/iscsi-tools(voir https://factory.talos.dev/).
Cilium
Installation manuelle.
N’installez pas Cilium si vous utilisez Flannel. Pour les utilisateurs de Flannel, une section MetalLB se trouve plus bas.
## Pour le support de l'API Gateway
kubectl apply --server-side -f https://raw.githubusercontent.com/kubernetes-sigs/gateway-api/v1.6.1/config/crd/standard/gateway.networking.k8s.io_gatewayclasses.yaml
kubectl apply --server-side -f https://raw.githubusercontent.com/kubernetes-sigs/gateway-api/v1.6.1/config/crd/standard/gateway.networking.k8s.io_gateways.yaml
kubectl apply --server-side -f https://raw.githubusercontent.com/kubernetes-sigs/gateway-api/v1.6.1/config/crd/standard/gateway.networking.k8s.io_httproutes.yaml
kubectl apply --server-side -f https://raw.githubusercontent.com/kubernetes-sigs/gateway-api/v1.6.1/config/crd/standard/gateway.networking.k8s.io_referencegrants.yaml
kubectl apply --server-side -f https://raw.githubusercontent.com/kubernetes-sigs/gateway-api/v1.6.1/config/crd/standard/gateway.networking.k8s.io_grpcroutes.yaml
kubectl apply --server-side -f https://raw.githubusercontent.com/kubernetes-sigs/gateway-api/v1.6.1/config/crd/standard/gateway.networking.k8s.io_backendtlspolicies.yaml
kubectl apply --server-side -f https://raw.githubusercontent.com/kubernetes-sigs/gateway-api/v1.6.1/config/crd/standard/gateway.networking.k8s.io_tlsroutes.yaml
kubectl apply --server-side -f https://raw.githubusercontent.com/kubernetes-sigs/gateway-api/v1.6.1/config/crd/standard/gateway.networking.k8s.io_listenersets.yaml
kubectl apply --server-side -f https://raw.githubusercontent.com/kubernetes-sigs/gateway-api/v1.6.1/config/crd/standard/gateway.networking.k8s.io_tcproutes.yaml
kubectl apply --server-side -f https://raw.githubusercontent.com/kubernetes-sigs/gateway-api/v1.6.1/config/crd/standard/gateway.networking.k8s.io_udproutes.yaml
export cilium_version="1.20.0"
export cilium_replicas=2 ## resuire seulement si cluster nono hoste
helm install cilium oci://quay.io/cilium/charts/cilium \
--version ${cilium_version} \
--namespace kube-system \
--set operator.replicas=${cilium_replicas} \
--set devices={eno1,bridge} \
--set ipam.mode=kubernetes \
--set kubeProxyReplacement=true \
--set securityContext.capabilities.ciliumAgent="{CHOWN,KILL,NET_ADMIN,NET_RAW,IPC_LOCK,SYS_ADMIN,SYS_RESOURCE,DAC_OVERRIDE,FOWNER,SETGID,SETUID}" \
--set securityContext.capabilities.cleanCiliumState="{NET_ADMIN,SYS_ADMIN,SYS_RESOURCE}" \
--set cgroup.autoMount.enabled=false \
--set cgroup.hostRoot=/sys/fs/cgroup \
--set k8sServiceHost=localhost \
--set k8sServicePort=7445 \
--set gatewayAPI.enabled=true \
--set gatewayAPI.enableAlpn=true \
--set gatewayAPI.enableAppProtocol=true
Cilium LoadBalancer
Configuration des pools d’adresses IP du LoadBalancer
Variables :
LB_RANGE="192.168.1.0/24"
cat <<EOF | kubectl apply -f -
apiVersion: "cilium.io/v2"
kind: CiliumLoadBalancerIPPool
metadata:
name: lb-ip-pool
labels:
pool: "blue"
spec:
blocks:
- cidr: $LB_RANGE
EOF
Cilium Gateway
cat <<EOF | kubectl apply -f -
apiVersion: gateway.networking.k8s.io/v1
kind: GatewayClass
metadata:
name: envoy-external
spec:
controllerName: gateway.envoyproxy.io/gatewayclass-controller
parametersRef:
group: gateway.envoyproxy.io
kind: EnvoyProxy
name: external-config
namespace: envoy-gateway-system
---
apiVersion: gateway.networking.k8s.io/v1
kind: GatewayClass
metadata:
name: envoy-internal
spec:
controllerName: gateway.envoyproxy.io/gatewayclass-controller
EOF
cert-manager
cPanel
export EMAIL=""
export cpanel_url=""
export cpanel_user=""
export cpanel_api=""
## Ce n’est pas idéal, mais c’est une solution temporaire…
kubectl apply -f https://raw.githubusercontent.com/jamesorlakin/cert-manager-cpanel-dns-webhook/master/deploy/v0.3.0.yaml
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: Secret
type: Opaque
metadata:
name: cpanel-credentials
namespace: cert-manager
stringData:
username: ${cpanel_user}
apiToken: ${cpanel_api}
---
apiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata:
name: letsencrypt
spec:
acme:
server: https://acme-v02.api.letsencrypt.org/directory
email: $EMAIL
privateKeySecretRef:
name: letsencrypt-prod
solvers:
- dns01:
webhook:
groupName: jameslakin.co.uk
solverName: cpanel-solver
config:
cpanelUrl: ${cpanel_url}
secretRef: cert-manager/cpanel-credentials
EOF