f8d3cbdd59
Add the FastAPI app, PostgreSQL migrations, Docker/Helm packaging, API contracts, docs, client examples, and the unit/integration/compatibility test suite for local client and tooling labs without a real vCenter.
163 lines
5.3 KiB
Markdown
163 lines
5.3 KiB
Markdown
**Language / Язык:** [English](kubernetes.md) | [Русский](ru/kubernetes.md)
|
|
|
|
# Kubernetes / Helm
|
|
|
|
Deploy the published Docker Hub runtime image with the chart in
|
|
[`helm/vmware-api-simulator`](../helm/vmware-api-simulator).
|
|
|
|
Image: [`inecs/vmware-api-simulator`](https://hub.docker.com/r/inecs/vmware-api-simulator)
|
|
|
|
## Prerequisites
|
|
|
|
- Kubernetes 1.27+ (or comparable)
|
|
- Helm 3.14+
|
|
- [Ingress NGINX](https://kubernetes.github.io/ingress-nginx/) (or another
|
|
IngressClass that supports HTTP-01)
|
|
- [cert-manager](https://cert-manager.io/) installed cluster-wide
|
|
|
|
Example cert-manager install:
|
|
|
|
```bash
|
|
kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.17.2/cert-manager.yaml
|
|
```
|
|
|
|
## Quick install (Hub release + Ingress + Let's Encrypt)
|
|
|
|
From a git checkout of this repository:
|
|
|
|
```bash
|
|
helm upgrade --install vmware-sim ./helm/vmware-api-simulator \
|
|
-n vmware-sim --create-namespace \
|
|
-f ./helm/vmware-api-simulator/values-ingress-example.yaml \
|
|
--set certManager.email=you@example.com \
|
|
--set ingress.hosts[0].host=vmware-sim.example.com \
|
|
--set ingress.tls[0].hosts[0]=vmware-sim.example.com \
|
|
--set secret.ticketSigningKey="$(openssl rand -hex 32)" \
|
|
--set postgresql.auth.password="$(openssl rand -hex 16)"
|
|
```
|
|
|
|
What this does:
|
|
|
|
1. Pulls `inecs/vmware-api-simulator:0.1.0` (see `image.tag` in the example file).
|
|
2. Installs bundled PostgreSQL 17 (`postgres:17.5-bookworm`, same as Compose).
|
|
3. Runs schema migrations in an init container (idempotent).
|
|
4. Seeds the `small` lab profile (`seed.enabled=true`).
|
|
5. Creates `ClusterIssuer` resources:
|
|
- `letsencrypt-prod`
|
|
- `letsencrypt-staging`
|
|
6. Creates an Ingress with
|
|
`cert-manager.io/cluster-issuer: letsencrypt-prod` and a TLS secret
|
|
`vmware-api-simulator-tls`.
|
|
|
|
DNS for `vmware-sim.example.com` must point at your Ingress controller. Then:
|
|
|
|
```bash
|
|
kubectl -n vmware-sim get certificate,ingress,pods
|
|
# wait until Certificate READY=True
|
|
curl -sS https://vmware-sim.example.com/health/ready
|
|
open https://vmware-sim.example.com/
|
|
```
|
|
|
|
Default seeded login: `administrator@vsphere.local` / `VMware1!`.
|
|
|
|
### Staging first (recommended)
|
|
|
|
Validate HTTP-01 without hitting production rate limits:
|
|
|
|
```bash
|
|
helm upgrade --install vmware-sim ./helm/vmware-api-simulator \
|
|
-n vmware-sim --create-namespace \
|
|
-f ./helm/vmware-api-simulator/values-ingress-example.yaml \
|
|
--set certManager.email=you@example.com \
|
|
--set certManager.useStaging=true \
|
|
--set ingress.hosts[0].host=vmware-sim.example.com \
|
|
--set ingress.tls[0].hosts[0]=vmware-sim.example.com \
|
|
--set secret.ticketSigningKey="$(openssl rand -hex 32)"
|
|
```
|
|
|
|
Browsers will not trust the staging CA — use `curl -k` while testing. Flip
|
|
`certManager.useStaging=false` and recreate the Certificate/TLS secret for
|
|
production.
|
|
|
|
## Minimal install (ClusterIP + port-forward)
|
|
|
|
```bash
|
|
helm upgrade --install vmware-sim ./helm/vmware-api-simulator \
|
|
-n vmware-sim --create-namespace \
|
|
--set secret.ticketSigningKey="$(openssl rand -hex 32)" \
|
|
--set seed.enabled=true
|
|
|
|
kubectl -n vmware-sim port-forward svc/vmware-sim-vmware-api-simulator 8080:8080
|
|
```
|
|
|
|
Open http://127.0.0.1:8080/. The Service exposes the internal application
|
|
port (`8080`, see [Ports](ports.md)) — the chart does not run the nginx
|
|
TLS gateway used by Compose; put TLS in front of it via Ingress in
|
|
production, or talk to the plain-HTTP Service for local testing.
|
|
|
|
## External PostgreSQL
|
|
|
|
```bash
|
|
helm upgrade --install vmware-sim ./helm/vmware-api-simulator \
|
|
-n vmware-sim --create-namespace \
|
|
--set postgresql.enabled=false \
|
|
--set secret.ticketSigningKey="$(openssl rand -hex 32)" \
|
|
--set secret.databaseUrl='postgresql://user:pass@pg.example.com:5432/vmware_simulator'
|
|
```
|
|
|
|
Or use `secret.existingSecret` with keys `DATABASE_URL` and `TICKET_SIGNING_KEY`.
|
|
|
|
## How TLS issuance works
|
|
|
|
When `certManager.enabled=true` and `certManager.createClusterIssuer=true`, the
|
|
chart creates ACME `ClusterIssuer` objects that solve HTTP-01 through your
|
|
Ingress class. The Ingress template adds:
|
|
|
|
```yaml
|
|
metadata:
|
|
annotations:
|
|
cert-manager.io/cluster-issuer: letsencrypt-prod
|
|
spec:
|
|
tls:
|
|
- secretName: vmware-api-simulator-tls
|
|
hosts: [vmware-sim.example.com]
|
|
```
|
|
|
|
cert-manager then creates a `Certificate`, completes HTTP-01, and stores the
|
|
Let's Encrypt key pair in that TLS secret. The chart does **not** install
|
|
cert-manager or the Ingress controller — only the issuers + Ingress wiring.
|
|
|
|
If ClusterIssuers already exist cluster-wide, set:
|
|
|
|
```yaml
|
|
certManager:
|
|
enabled: true
|
|
createClusterIssuer: false
|
|
issuerName: your-existing-issuer
|
|
```
|
|
|
|
## Operations
|
|
|
|
```bash
|
|
# logs
|
|
kubectl -n vmware-sim logs -l app.kubernetes.io/instance=vmware-sim -c simulator -f
|
|
|
|
# reseed
|
|
kubectl -n vmware-sim exec deploy/vmware-sim-vmware-api-simulator -- \
|
|
python -m app.simulation.seed_cli
|
|
# SEED_VSPHERE_PROFILE via: kubectl set env ... or --set seed.profile=demo-cluster and upgrade
|
|
|
|
# uninstall
|
|
helm -n vmware-sim uninstall vmware-sim
|
|
```
|
|
|
|
## Values reference
|
|
|
|
See [`helm/vmware-api-simulator/values.yaml`](../helm/vmware-api-simulator/values.yaml)
|
|
and the [chart README](../helm/vmware-api-simulator/README.md). Related docs:
|
|
|
|
- [Getting started](getting-started.md) — Compose paths
|
|
- [Operations](operations.md) — Docker Hub publish / release compose
|
|
- [Security](security.md) — lab credentials and trust boundary
|
|
- [Ports](ports.md) — internal `8080` vs published gateway ports
|