Service
Schemas
Schema Service
Service is a kind of workload profile that describes how to run your application code. This
is typically used for long-running web applications that should "never" go down, and handle
short-lived latency-sensitive web requests, or events.
Attributes
Name and Description | Type | Default Value | Required |
---|---|---|---|
containers Containers defines the templates of containers to be ran. More info: https://kubernetes.io/docs/concepts/containers | {str: container.Container} | Undefined | required |
replicas Number of container replicas based on this configuration that should be ran. | int | 2 | required |
ports The list of ports of the Service should get exposed. | [network.Port] | Undefined | optional |
secrets | {str: secret.Secret} | Undefined | optional |
labels Labels are key/value pairs that are attached to the workload. | {str: str} | Undefined | optional |
annotations Annotations are key/value pairs that attach arbitrary non-identifying metadata to the workload. | {str: str} | Undefined | optional |
type Type represents the type of workload used by this Service. Currently, it supports several types, including Deployment and CollaSet. | "Deployment" | "CollaSet" | Deployment | optional |
Examples
# Instantiate a long-running service and its image is "nginx:v1"
import catalog.models.schema.v1.workload as wl
import catalog.models.schema.v1.workload.container as c
svc = wl.Service {
containers: {
"nginx": c.Container {
image: "nginx:v1"
}
}
ports: [
n.Port {
port: 80
public: True
}
n.Port {
port: 9090
}
]
}
Base Schema
Schema Container
Container describes how the Application's tasks are expected to be run. Depending on
the replicas parameter 1 or more containers can be created from each template.
Attributes
Name and Description | Type | Default Value | Required |
---|---|---|---|
image Image refers to the Docker image name to run for this container. More info: https://kubernetes.io/docs/concepts/containers/images | str | Undefined | required |
command Entrypoint array. Not executed within a shell. Command will overwrite the ENTRYPOINT value set in the Dockfile, otherwise the Docker image's ENTRYPOINT is used if this is not provided. | [str] | Undefined | optional |
args Arguments to the entrypoint. Args will overwrite the CMD value set in the Dockfile, otherwise the Docker image's CMD is used if this is not provided. | [str] | Undefined | optional |
env List of environment variables to set in the container. The value of the environment variable may be static text or a value from a secret. | {str: str} | Undefined | optional |
workingDir The working directory of the running process defined in entrypoint. Default container runtime will be used if this is not specified. | str | Undefined | optional |
resources Map of resource requirements the container should run with. The resources parameter is a dict with the key being the resource name and the value being the resource value. | {str: str} | Undefined | optional |
files List of files to create in the container. The files parameter is a dict with the key being the file name in the container and the value being the target file specification. | {str: container.FileSpec} | Undefined | optional |
dirs Collection of volumes mount into the container's filesystem. The dirs parameter is a dict with the key being the folder name in the container and the value being the referenced volume. | {str: str} | Undefined | optional |
livenessProbe LivenessProbe indicates if a running process is healthy. Container will be restarted if the probe fails. | p.Probe | Undefined | optional |
readinessProbe ReadinessProbe indicates whether an application is available to handle requests. | p.Probe | Undefined | optional |
startupProbe StartupProbe indicates that the container has started for the first time. Container will be restarted if the probe fails. | p.Probe | Undefined | optional |
lifecycle Lifecycle refers to actions that the management system should take in response to container lifecycle events. | lc.Lifecycle | Undefined | optional |
Examples
import catalog.models.schema.v1.workload.container as c
web = c.Container {
image: "nginx:latest"
command: ["/bin/sh", "-c", "echo hi"]
env: {
"name": "value"
}
resources: {
"cpu": "2"
"memory": "4Gi"
}
}
Schema FileSpec
FileSpec defines the target file in a Container.
Attributes
Name and Description | Type | Default Value | Required |
---|---|---|---|
mode Mode bits used to set permissions on this file, must be an octal value between 0000 and 0777 or a decimal value between 0 and 511 | str | Undefined | required |
content File content in plain text. | str | Undefined | optional |
contentFrom Source for the file content, reference to a secret of configmap value. | str | Undefined | optional |
Examples
import catalog.models.schema.v1.workload.container as c
tmpFile = c.FileSpec {
content: "some file contents"
mode: "0777"
}
Schema Probe
Probe describes a health check to be performed against a container to determine whether it is
alive or ready to receive traffic. There are three probe types: readiness, liveness, and startup.
Attributes
Name and Description | Type | Default Value | Required |
---|---|---|---|
probeHandler The action taken to determine the alive or health of a container | probe.Exec | probe.Http | probe.Tcp | Undefined | required |
initialDelaySeconds The number of seconds before health checking is activated. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle\#container-probes | int | Undefined | optional |
timeoutSeconds The number of seconds after which the probe times out. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle\#container-probes | int | Undefined | optional |
periodSeconds How often (in seconds) to perform the probe. | int | Undefined | optional |
successThreshold Minimum consecutive successes for the probe to be considered successful after having failed. | int | Undefined | optional |
failureThreshold Minimum consecutive failures for the probe to be considered failed after having succeeded. | int | Undefined | optional |
terminationGracePeriod | int | Undefined | optional |
Examples
import catalog.models.schema.v1.workload.container.probe as p
probe = p.Probe {
probeHandler: p.Http {
path: "/healthz"
}
initialDelaySeconds: 10
}
Schema Exec
Exec describes a "run in container" action.
Attributes
Name and Description | Type | Default Value | Required |
---|---|---|---|
command The command line to execute inside the container. | [str] | Undefined | required |
Examples
import catalog.models.schema.v1.workload.container.probe as p
execProbe = p.Exec {
command: ["probe.sh"]
}
Schema Http
Http describes an action based on HTTP Get requests.
Attributes
Name and Description | Type | Default Value | Required |
---|---|---|---|
url The full qualified url to send HTTP requests. | str | Undefined | required |
headers Collection of custom headers to set in the request | {str: str} | Undefined | optional |
Examples
import catalog.models.schema.v1.workload.container.probe as p
httpProbe = p.Http {
url: "http://localhost:80"
headers: {
"X-HEADER": "VALUE"
}
}
Schema Tcp
Tcp describes an action based on opening a socket.
Attributes
Name and Description | Type | Default Value | Required |
---|---|---|---|
url The full qualified url to open a socket. | str | Undefined | required |
Examples
import catalog.models.schema.v1.workload.container.probe as p
tcpProbe = p.Tcp {
url: "tcp://localhost:1234"
}
Schema Lifecycle
Lifecycle describes actions that the management system should take in response
to container lifecycle events.
Attributes
Name and Description | Type | Default Value | Required |
---|---|---|---|
preStop The action to be taken before a container is terminated due to an API request or management event such as liveness/startup probe failure, preemption, resource contention, etc. More info: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/\#container-hooks | probe.Exec | probe.Http | Undefined | optional |
postStart The action to be taken after a container is created. More info: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/\#container-hooks | probe.Exec | probe.Http | Undefined | optional |
Examples
import catalog.models.schema.v1.workload.container.probe as p
import catalog.models.schema.v1.workload.container.lifecycle as lc
lifecycleHook = lc.Lifecycle {
preStop: p.Exec {
command: ["preStop.sh"]
}
postStart: p.Http {
url: "http://localhost:80"
}
}
Schema Secret
Secret can be used to store sensitive data.
Attributes
Name and Description | Type | Default Value | Required |
---|---|---|---|
type Type of secret, used to facilitate programmatic handling of secret data. More info: https://kubernetes.io/docs/concepts/configuration/secret/\#secret-types | "basic" | "opaque" | opaque | required |
data Data contains the non-binary secret data in string form. | {str: str} | Undefined | optional |
immutable Immutable, if set to true, ensures that data stored in the Secret cannot be updated. | bool | Undefined | optional |
Examples
import catalog.models.schema.v1.workload.secret as sec
basicAuth = sec.Secret {
type: "basic"
data: {
"username": ""
"password": ""
}
}
Schema Port
Port defines the exposed port of Service, which can be used to describe how the Service
get accessed.
Attributes
Name and Description | Type | Default Value | Required |
---|---|---|---|
port The exposed port of the Service. | int | 80 | required |
protocol The protocol to access the port. | "TCP" | "UDP" | "TCP" | optional |
public Public defines whether the port can be accessed through Internet. | bool | False | optional |
targetPort The backend container port. If empty, set it the same as the port. | int | Undefined | optional |
Examples
import catalog.models.schema.v1.workload.network as n
port = n.Port {
port: 80
targetPort: 8080
protocol: "TCP"
public: True
}