SKY-DEP003 · Deployment and infrastructure
Internet-facing Ingress routes to a server in reload mode
Reload mode makes a development server watch its source files and restart when they change. SKY-DEP003 reports a Kubernetes deployment whose internet-facing Ingress routes to a Uvicorn, Gunicorn or Flask container started with --reload, or with Flask debug mode, which reloads too.
- Languages
- Kubernetes YAML, Uvicorn, Gunicorn, Flask
- Quality gate
- counted toward the gate limits (full and diff scans). Reported under reliability. It counts toward
max_reliability, which is 0 by default, so one finding fails--gate. - Finding type
- review
- Catalog name
- External Ingress routes to a reload-mode application server
Why it matters
The file watcher costs CPU in every pod, and Uvicorn's reloader runs a single worker process, so the service has less capacity than you think. Any file change inside the container restarts it mid-request.
What Skylos flags
from fastapi import FastAPI app = FastAPI() @app.get("/orders")def orders(): return {"orders": []}apiVersion: apps/v1kind: Deploymentmetadata: name: api namespace: prodspec: selector: matchLabels: app: api template: metadata: labels: app: api spec: containers: - name: api image: ghcr.io/acme/api:1.4.0 command: ["uvicorn"] args: ["app.main:app", "--reload", "--host", "0.0.0.0", "--port", "8000"] ports: - name: http containerPort: 8000---apiVersion: v1kind: Servicemetadata: name: api namespace: prodspec: selector: app: api ports: - name: http port: 80 targetPort: http---apiVersion: networking.k8s.io/v1kind: Ingressmetadata: name: api namespace: prod annotations: skylos.dev/network-scope: external skylos.dev/backend-protocol: httpspec: rules: - host: api.example.com http: paths: - path: / pathType: Prefix backend: service: name: api port: name: httpWhat Skylos leaves alone
apiVersion: apps/v1kind: Deploymentmetadata: name: api namespace: prodspec: selector: matchLabels: app: api template: metadata: labels: app: api spec: containers: - name: api image: ghcr.io/acme/api:1.4.0 command: ["uvicorn"] args: ["app.main:app", "--workers", "2", "--host", "0.0.0.0", "--port", "8000"] ports: - name: http containerPort: 8000---apiVersion: v1kind: Servicemetadata: name: api namespace: prodspec: selector: app: api ports: - name: http port: 80 targetPort: http---apiVersion: networking.k8s.io/v1kind: Ingressmetadata: name: api namespace: prod annotations: skylos.dev/network-scope: external skylos.dev/backend-protocol: httpspec: rules: - host: api.example.com http: paths: - path: / pathType: Prefix backend: service: name: api port: name: httpWhy Skylos leaves it alone
The same Uvicorn container behind the same public Ingress, started with two worker processes instead of the reloader.
How Skylos decides
- Runs with
--danger(or-a). Reads Kubernetes YAML in the repository and only works when anIngressopts in with the annotationsskylos.dev/network-scope: external(orinternet,public) andskylos.dev/backend-protocol: http. - Follows one chain inside one YAML file: Ingress path, to the
Serviceand port it names, to the one workload the Service selects, to the one container whose port the Service targets. The server must be started with a literalcommandandargs(uvicorn,gunicorn,flask run, orpython -mone of them) bound to0.0.0.0or::on that port. - Any missing, dynamic or ambiguous link (two matching workloads, a Helm template value, HTTPS or gRPC backends, rewrite or snippet annotations) makes it report nothing rather than guess.
- Reports a literal
--reloadon a Uvicorn, Gunicorn orflask runcommand, and Flask debug mode (--debug) unless--no-reloadfollows. - Does not need the
source-fileorrequired-guardsannotations. - Reports MEDIUM, as a reliability finding, on the container's
argsline.
How to fix it
Remove --reload; roll out code changes by building a new image. Set the number of workers for the pod's CPU instead.
apiVersion: apps/v1kind: Deploymentmetadata: name: api namespace: prodspec: selector: matchLabels: app: api template: metadata: labels: app: api spec: containers: - name: api image: ghcr.io/acme/api:1.4.0 command: ["uvicorn"]Removed: args: ["app.main:app", "--reload", "--host", "0.0.0.0", "--port", "8000"]Added: args: ["app.main:app", "--workers", "2",Added: "--host", "0.0.0.0", "--port", "8000"] ports: - name: http containerPort: 8000---apiVersion: v1kind: Servicemetadata: name: api namespace: prodspec: selector: app: api ports: - name: http port: 80 targetPort: http---apiVersion: networking.k8s.io/v1kind: Ingressmetadata: name: api namespace: prod annotations: skylos.dev/network-scope: external skylos.dev/backend-protocol: httpspec: rules: - host: api.example.com http: paths: - path: / pathType: Prefix backend: service: name: api port: name: httpWhen it can be wrong
- Reload turned on in code (
uvicorn.run(..., reload=True)) or through environment variables is not read. - Without the two Ingress annotations the rule never runs. Keep them in a protected place: removing them silences the rule.
- Resources split across several YAML files, Helm charts and Kustomize overlays are not joined or rendered. Scan rendered manifests.
Seeing a case that isn't listed here? Report the wrong result so the rule can be fixed. Don't paste company code: describe the shape of it.
How to silence it
Put the marker on the reported
argsline.YAML args: ["app.main:app", "--reload"] # skylos: ignore[SKY-DEP003][tool.skylos] ignore = ["SKY-DEP003"]turns the rule off for the project.A baseline (
skylos baseline ., then--baseline) accepts the findings that exist today and reports new ones.