Files
test/templates/schemas/generic-http-service.v1.json
2026-10-22 02:06:39 +00:00

117 lines
4.6 KiB
JSON

{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://platform.example/templates/generic-http-service/v1",
"title": "generic-http-service@v1",
"description": "One HTTP workload: a Deployment and a ClusterIP Service for in-cluster traffic.",
"type": "object",
"additionalProperties": false,
"required": ["templateRef", "metadata", "runtime", "replicas", "resources", "healthCheck"],
"properties": {
"templateRef": {
"description": "The contract this spec is frozen against. Never a chart coordinate.",
"type": "object",
"additionalProperties": false,
"required": ["name", "version"],
"properties": {
"name": {"type": "string", "pattern": "^[a-z][a-z0-9-]{0,62}$"},
"version": {"type": "string", "pattern": "^v[0-9]+$"}
}
},
"type": {"const": "web"},
"metadata": {
"type": "object",
"additionalProperties": false,
"properties": {
"description": {"type": "string"},
"owner": {"type": "string"},
"labels": {
"description": "The platform/ prefix is reserved: the gateway writes its own identity labels there and a spec must not collide with them.",
"type": "object",
"propertyNames": {"not": {"pattern": "^platform\\.example/"}},
"additionalProperties": {"type": "string"}
}
}
},
"runtime": {
"type": "object",
"additionalProperties": false,
"required": ["image", "resolvedImage", "ports"],
"properties": {
"image": {"type": "string"},
"resolvedImage": {
"description": "Digest-pinned by the Backend; a tag would break reproducibility.",
"type": "string",
"pattern": "^[^ @]+@sha256:[a-f0-9]{64}$"
},
"command": {"type": "array", "items": {"type": "string"}},
"args": {"type": "array", "items": {"type": "string"}},
"ports": {
"type": "array",
"minItems": 1,
"maxItems": 1,
"items": {
"type": "object",
"additionalProperties": false,
"required": ["name", "containerPort"],
"properties": {
"name": {"type": "string", "pattern": "^[a-z][a-z0-9-]{0,14}$"},
"containerPort": {"type": "integer", "minimum": 1, "maximum": 65535}
}
}
},
"runAsRoot": {
"description": "Run the container as root, for images that cannot drop privileges. Every other restricted control still applies; a port below 1024 also gets NET_BIND_SERVICE, without which root still cannot bind it.",
"type": "boolean"
}
}
},
"env": {
"type": "object",
"propertyNames": {"pattern": "^[A-Za-z_][A-Za-z0-9_]*$"},
"additionalProperties": {"type": "string"}
},
"replicas": {"type": "integer", "minimum": 1, "maximum": 10},
"resources": {
"type": "object",
"additionalProperties": false,
"required": ["size"],
"properties": {"size": {"enum": ["nano", "small", "medium", "large"]}}
},
"healthCheck": {
"type": "object",
"additionalProperties": false,
"required": ["path", "port", "initialDelaySeconds"],
"properties": {
"path": {"type": "string", "pattern": "^/"},
"port": {"type": "integer", "minimum": 1, "maximum": 65535},
"initialDelaySeconds": {"type": "integer", "minimum": 0, "maximum": 600}
}
},
"exposure": {
"description": "public renders an Ingress on the platform's wildcard host; path stays pinned to \"/\" because the template routes the whole host to one Service.",
"type": "object",
"additionalProperties": false,
"properties": {"public": {"type": "boolean"}, "path": {"const": "/"}}
},
"secretRefs": {"type": "array", "maxItems": 0},
"mounts": {"type": "array", "maxItems": 0},
"dependencies": {"type": "array", "maxItems": 0},
"contract": {"type": "object", "additionalProperties": false}
},
"allOf": [
{
"$comment": "A public deployment is addressed by a hostname built from the service name, so that name has to be present. It travels in metadata.labels.service, optional for a private deployment; requiring it only when exposure.public is true keeps the dependency visible in the published contract instead of surfacing as a render error.",
"if": {
"type": "object",
"required": ["exposure"],
"properties": {"exposure": {"required": ["public"], "properties": {"public": {"const": true}}}}
},
"then": {
"properties": {
"metadata": {"required": ["labels"], "properties": {"labels": {"required": ["service"]}}}
}
}
}
]
}