Compare commits
No commits in common. "master" and "0.0.2" have entirely different histories.
5 changed files with 0 additions and 126 deletions
18
README_GO.md
18
README_GO.md
|
@ -8,21 +8,3 @@ export HAPROXY_TEMPLATE="./haproxy.tmpl"
|
||||||
|
|
||||||
./haproxy-generator > /etc/haproxy/haproxy.cfg && sudo systemctl restart haproxy
|
./haproxy-generator > /etc/haproxy/haproxy.cfg && sudo systemctl restart haproxy
|
||||||
```
|
```
|
||||||
|
|
||||||
# HaProxy Template
|
|
||||||
|
|
||||||
```
|
|
||||||
{{- range .backends }}
|
|
||||||
|
|
||||||
backend {{ .Name }}
|
|
||||||
mode tcp
|
|
||||||
balance leastconn
|
|
||||||
cookie {{ .Name }} insert indirect nocache
|
|
||||||
|
|
||||||
{{- range .Servers }}
|
|
||||||
server {{ .Name }} {{ .Address }}:{{ .Port }} check cookie {{ .Cookie }}
|
|
||||||
{{- end }}
|
|
||||||
|
|
||||||
{{- end }}
|
|
||||||
|
|
||||||
```
|
|
|
@ -1,30 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Erstellt ein Token
|
|
||||||
TOKEN=$(kubectl -n kube-system create token haproxy-sa)
|
|
||||||
|
|
||||||
# Get Cluster Info
|
|
||||||
CLUSTER_NAME=$(kubectl config view -o jsonpath='{.clusters[0].name}')
|
|
||||||
CLUSTER_SERVER=$(kubectl config view -o jsonpath="{.clusters[0].cluster.server}")
|
|
||||||
CA_DATA=$(kubectl config view --raw -o jsonpath="{.clusters[0].cluster.certificate-authority-data}")
|
|
||||||
|
|
||||||
# Erstelle kubeconfig
|
|
||||||
cat <<EOF > haproxy-kubeconfig.yaml
|
|
||||||
apiVersion: v1
|
|
||||||
kind: Config
|
|
||||||
clusters:
|
|
||||||
- cluster:
|
|
||||||
certificate-authority-data: ${CA_DATA}
|
|
||||||
server: ${CLUSTER_SERVER}
|
|
||||||
name: ${CLUSTER_NAME}
|
|
||||||
contexts:
|
|
||||||
- context:
|
|
||||||
cluster: ${CLUSTER_NAME}
|
|
||||||
user: haproxy-sa
|
|
||||||
name: haproxy-context
|
|
||||||
current-context: haproxy-context
|
|
||||||
users:
|
|
||||||
- name: haproxy-sa
|
|
||||||
user:
|
|
||||||
token: ${TOKEN}
|
|
||||||
EOF
|
|
|
@ -1,42 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
BIN_PATH="/usr/local/bin/haproxy_generator"
|
|
||||||
CONFIG_PATH="/etc/haproxy/haproxy.cfg"
|
|
||||||
NEW_CONFIG="${CONFIG_PATH}.new"
|
|
||||||
TEMPLATE_PATH="/etc/haproxy/haproxy.tmpl"
|
|
||||||
|
|
||||||
# Setze notwendige Umgebungsvariablen
|
|
||||||
export HAPROXY_TEMPLATE="$TEMPLATE_PATH"
|
|
||||||
export KUBERNETES_HOST="https://10.0.20.7:6443"
|
|
||||||
export KUBERNETES_TOKEN="eyJhbGciOi..." # <<< hier echten Token einfügen
|
|
||||||
export KUBERNETES_VERIFYSSL="false"
|
|
||||||
|
|
||||||
# Prüfe, ob Template vorhanden ist
|
|
||||||
if [ ! -f "$TEMPLATE_PATH" ]; then
|
|
||||||
echo "[ERROR] Template-Datei nicht gefunden: $TEMPLATE_PATH" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Neue Konfiguration generieren
|
|
||||||
if ! "$BIN_PATH" > "$NEW_CONFIG"; then
|
|
||||||
echo "[ERROR] Fehler beim Ausführen von haproxy_generator" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Syntaxprüfung der neuen Konfiguration
|
|
||||||
if ! /sbin/haproxy -f "$NEW_CONFIG" -c; then
|
|
||||||
echo "[ERROR] Neue Konfiguration ist syntaktisch ungültig (haproxy -c)" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Unterschiede prüfen und ggf. übernehmen
|
|
||||||
if ! diff -q "$CONFIG_PATH" "$NEW_CONFIG" > /dev/null; then
|
|
||||||
echo "[INFO] Änderungen erkannt - Konfiguration wird übernommen"
|
|
||||||
mv "$NEW_CONFIG" "$CONFIG_PATH"
|
|
||||||
/usr/sbin/service haproxy reload
|
|
||||||
else
|
|
||||||
echo "[INFO] Keine Änderungen - kein Reload notwendig"
|
|
||||||
rm -f "$NEW_CONFIG"
|
|
||||||
fi
|
|
|
@ -1,9 +0,0 @@
|
||||||
apiVersion: v1
|
|
||||||
kind: ConfigMap
|
|
||||||
metadata:
|
|
||||||
name: haproxy-config
|
|
||||||
namespace: kube-system
|
|
||||||
data:
|
|
||||||
ssl-redirect: "true"
|
|
||||||
timeout-http-request: "5s"
|
|
||||||
use-forwarded-headers: "true"
|
|
|
@ -1,27 +0,0 @@
|
||||||
apiVersion: v1
|
|
||||||
kind: ServiceAccount
|
|
||||||
metadata:
|
|
||||||
name: gateway
|
|
||||||
namespace: kube-system
|
|
||||||
---
|
|
||||||
apiVersion: rbac.authorization.k8s.io/v1
|
|
||||||
kind: ClusterRole
|
|
||||||
metadata:
|
|
||||||
name: gateway
|
|
||||||
rules:
|
|
||||||
- apiGroups: [""]
|
|
||||||
resources: ["endpoints", "services", "namespaces", "nodes"]
|
|
||||||
verbs: ["get", "list", "watch"]
|
|
||||||
---
|
|
||||||
apiVersion: rbac.authorization.k8s.io/v1
|
|
||||||
kind: ClusterRoleBinding
|
|
||||||
metadata:
|
|
||||||
name: gateway
|
|
||||||
roleRef:
|
|
||||||
apiGroup: rbac.authorization.k8s.io
|
|
||||||
kind: ClusterRole
|
|
||||||
name: gateway
|
|
||||||
subjects:
|
|
||||||
- kind: ServiceAccount
|
|
||||||
name: gateway
|
|
||||||
namespace: kube-system
|
|
Loading…
Add table
Reference in a new issue