> For the complete documentation index, see [llms.txt](https://docs.kiloiot.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.kiloiot.io/kilo-docs-de/kilo-center/kilo-mioty-service-center/getting-started/installation-kubernetes-helm.md).

# Installation: Kubernetes (Helm)

Stellen Sie KiloCenter mit Helm in Kubernetes bereit — Chart, Voraussetzungen (k8s 1.25+, PostgreSQL 14+, Redis 7+) und Ingress.

### Ziel

Stelle KiloCenter mithilfe des in diesem Repository enthaltenen Helm-Charts in einem Kubernetes-Cluster bereit.

### Voraussetzungen

| Anforderung         | Mindestversion |
| ------------------- | -------------- |
| Kubernetes-Cluster  | 1.25+          |
| Helm                | 3.x            |
| Externes PostgreSQL | 14+            |
| Externes Redis      | 7+             |

PostgreSQL und Redis werden **nicht** von diesem Chart bereitgestellt. Stelle sie separat bereit (verwaltete Dienste, Operatoren oder eigenständig) und gib die Verbindungsdetails in deiner Werte-Überschreibung an.

### Architektur

```
                  Internet
                     |
               [ Ingress ] (optional)
                /         \\
         kc-web:80    kc-gateway:9090
                          |
                    kc-core:50051 ---- kc-identity:50052
                    /      |      \\
             bssci:5000  scaci:5001  mosquitto:1883
                                         |
                                    [MQTT-Clients]
```

Das Chart stellt fünf Dienste und einen MQTT-Broker bereit:

| Komponente    | Port(s)                                                 | Beschreibung                                    |
| ------------- | ------------------------------------------------------- | ----------------------------------------------- |
| `kc-core`     | 50051 (gRPC), 5000 (BSSCI), 5001 (SCACI), 8086 (Health) | Service-Center-Engine                           |
| `kc-gateway`  | 9090 (gRPC-Web), 8087 (Health)                          | Externer API-Ingress                            |
| `kc-identity` | 50052 (gRPC), 8088 (Health)                             | Identität, Benutzer, Organisationen             |
| `kc-web`      | 80                                                      | Web-Verwaltungsoberfläche (nginx)               |
| `mosquitto`   | 1883, 9001 (WebSocket)                                  | MQTT-Broker                                     |
| `certgen`     | —                                                       | Pre-Install-Hook, der TLS-Zertifikate generiert |

### Schritt 1: Erstelle eine Werte-Überschreibung

Überschreibe mindestens die Datenbank-, Redis- und Geheimnis-Einstellungen:

```yaml
# my-values.yaml
postgresql:
  host: my-postgres.default.svc.cluster.local
  password: "a-strong-password"
  sslMode: "require"

redis:
  host: my-redis.default.svc.cluster.local

secrets:
  authHmacSecret: "replace-with-a-random-string-at-least-32-bytes"
  mqttAdminPassword: "strong-mqtt-admin-pw"
  mqttClientPassword: "strong-mqtt-client-pw"

certgen:
  serverName: "kilocenter.example.com"
```

> **Wichtig:** Das `authHmacSecret` wird verwendet, um JWT-Token zwischen KC-Gateway und KC-Identity zu signieren und zu verifizieren. Es muss mindestens 32 Zeichen lang sein.

### Schritt 2: Installieren

```bash
helm install kilocenter ./helm/kilocenter -f my-values.yaml
```

Bei der ersten Installation führt ein Pre-Install-Hook-Job das `certgen` Binary aus, um eine selbstsignierte CA und ein Serverzertifikat in ein gemeinsam genutztes PVC zu generieren. Nachfolgende Upgrades überspringen die Generierung, wenn bereits Zertifikate vorhanden sind.

### Schritt 3: Validieren

```bash
# Prüfe, ob alle Pods laufen
kubectl get pods -l app.kubernetes.io/instance=kilocenter

# Prüfe den Dienststatus
kubectl exec deploy/kilocenter-kc-core -- wget -qO- http://localhost:8086/health/ping
kubectl exec deploy/kilocenter-kc-identity -- wget -qO- http://localhost:8088/health
kubectl exec deploy/kilocenter-kc-gateway -- wget -qO- http://localhost:8087/health
```

### Schritt 4: Auf die UI zugreifen

Ohne Ingress verwende Port-Forwarding:

```bash
kubectl port-forward svc/kilocenter-kc-web 8080:80
```

Dann öffne <http://localhost:8080/> in deinem Browser.

### Standard-Administratorkonto

Beim ersten Start wird per Datenbankmigration ein Standard-Admin-Benutzer erstellt:

|              |                               |
| ------------ | ----------------------------- |
| **E-Mail**   | `admin [at] kilocenter.local` |
| **Passwort** | `admin123!`                   |

> Ersetze `[at]` durch `@` beim Anmelden.

> **Warnung:** Ändere das Passwort oder entferne dieses Konto vor jeder öffentlich erreichbaren Bereitstellung. Die Zugangsdaten sind in diesem Repository veröffentlicht.

### Ingress

Aktiviere den standardmäßigen Kubernetes-Ingress in deiner Werte-Überschreibung:

```yaml
ingress:
  enabled: true
  className: nginx
  hosts:
    - host: kilocenter.example.com
      paths:
        - path: /
          pathType: Prefix
          service: kc-web
          port: 80
        - path: /kilocenter.api
          pathType: Prefix
          service: kc-gateway
          port: 9090
  tls:
    - secretName: kilocenter-tls
      hosts:
        - kilocenter.example.com
```

Wenn du Ingress verwendest, füge deine Domain zu den zugelassenen CORS-Ursprüngen hinzu:

```yaml
kcGateway:
  config:
    corsOrigins:
      - "https://kilocenter.example.com"
```

### BSSCI/SCACI-Protokollzugriff

Basisstationen verbinden sich direkt über TCP+TLS auf den Ports 5000 (BSSCI) und 5001 (SCACI) mit KC-Core. Das sind reine TCP-Verbindungen, kein HTTP. Um sie extern bereitzustellen, erstelle einen LoadBalancer-Dienst:

```yaml
apiVersion: v1
kind: Service
metadata:
  name: kilocenter-bssci
spec:
  type: LoadBalancer
  selector:
    app.kubernetes.io/name: kc-core
    app.kubernetes.io/instance: kilocenter
  ports:
    - name: bssci
      port: 5000
      targetPort: 5000
    - name: scaci
      port: 5001
      targetPort: 5001
```

### TLS-Zertifikate

Das `certgen` Hook erzeugt bei der ersten Installation eine selbstsignierte CA und ein Serverzertifikat. Für den Produktionseinsatz ersetze diese durch Zertifikate, die von einer vertrauenswürdigen CA signiert sind, indem du dein eigenes Secret oder PVC unter `/app/certificates` im kc-core-Pod.

### Konfigurationsreferenz

Die vollständige Liste der konfigurierbaren Parameter findest du im README des Helm-Charts.

### Aktualisierung

```bash
helm upgrade kilocenter ./helm/kilocenter -f my-values.yaml
```

Setze einen bestimmten Image-Tag, um eine Version festzuschreiben:

```yaml
global:
  imageTag: "1.0.0"
```

### Fehlerbehebung

| Symptom                        | Wahrscheinliche Ursache               | Lösung                                                                                |
| ------------------------------ | ------------------------------------- | ------------------------------------------------------------------------------------- |
| Pods in `ImagePullBackOff`     | Fehlendes Image-Pull-Secret           | Füge `global.imagePullSecrets` mit deinen Registry-Zugangsdaten hinzu                 |
| KC-Core-Readiness-Probe 503    | Abhängigkeit nicht bereit             | Prüfe, ob KC-Identity und PostgreSQL laufen                                           |
| `invalid_token` nach dem Login | HMAC-Secret stimmt nicht überein      | Stelle sicher, `secrets.authHmacSecret` gesetzt ist (gleich für Gateway und Identity) |
| BSSCI-Verbindung abgelehnt     | Kein externer Dienst                  | Erstelle einen LoadBalancer-Dienst für die Ports 5000/5001                            |
| gRPC-Web-Fehler im Browser     | CORS oder Ingress falsch konfiguriert | Prüfe `kcGateway.config.corsOrigins` und die Ingress-Pfade                            |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.kiloiot.io/kilo-docs-de/kilo-center/kilo-mioty-service-center/getting-started/installation-kubernetes-helm.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
