Skip to content

Commit

Permalink
feat(deployment): adds support for exposing healthcheck for deployments
Browse files Browse the repository at this point in the history
This commit adds support for defining liveness probe. You can set HTTP, EXEC or TCP liveness probe
  • Loading branch information
RomilShah committed Aug 21, 2023
1 parent 4c32573 commit 750c332
Show file tree
Hide file tree
Showing 6 changed files with 189 additions and 3 deletions.
19 changes: 19 additions & 0 deletions riocli/apply/manifests/package-nonros-device.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ spec:
limits: # Optional
cpu: 0.025 # Unit: Core (Optional)
memory: 128 # Unit: MB (Optional)
livenessProbe: # Optional
exec:
command:
- "shell-cmd"
initialDelaySeconds: 5 # Number of seconds after the container has started before liveness probes are initiated.
periodSeconds: 10 # How often (in seconds) to perform the probe.
failureThreshold: 1 # Minimum consecutive failures for the probe to be considered failed after having succeeded.
successThreshold: 3 # Minimum consecutive successes for the probe to be considered successful after having failed.
timeoutSeconds: 1 # Number of seconds after which the probe times out.
build:
depends:
kind: build
Expand All @@ -31,6 +40,16 @@ spec:
limits: # Optional
cpu: 0.025 # Unit: Core (Optional)
memory: 128 # Unit: MB (Optional)
livenessProbe:
http:
path: "/"
port: 90
initialDelaySeconds: 5 # Number of seconds after the container has started before liveness probes are initiated.
periodSeconds: 10 # How often (in seconds) to perform the probe.
failureThreshold: 1 # Minimum consecutive failures for the probe to be considered failed after having succeeded.
successThreshold: 3 # Minimum consecutive successes for the probe to be considered successful after having failed.
timeoutSeconds: 1 # Number of seconds after which the probe times out.

docker:
image: "busybox:latest"
imagePullPolicy: "Always" # Always, Never, IfNotPresent(default)
Expand Down
17 changes: 17 additions & 0 deletions riocli/apply/manifests/package-ros-device-no-rosbag.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ spec:
limits: # Optional
cpu: 0.025 # Unit: Core (Optional)
memory: 128 # Unit: MB (Optional)
livenessProbe: # Optional
tcp:
port: 999
initialDelaySeconds: 5 # Number of seconds after the container has started before liveness probes are initiated.
periodSeconds: 10 # How often (in seconds) to perform the probe.
failureThreshold: 1 # Minimum consecutive failures for the probe to be considered failed after having succeeded.
successThreshold: 3 # Minimum consecutive successes for the probe to be considered successful after having failed.
timeoutSeconds: 1 # Number of seconds after which the probe times out.
build:
depends:
kind: build
Expand All @@ -32,6 +40,15 @@ spec:
limits: # Optional
cpu: 0.025 # Unit: Core (Optional)
memory: 128 # Unit: MB (Optional)
livenessProbe: # Optional
http:
path: "/"
port: 90
initialDelaySeconds: 5 # Number of seconds after the container has started before liveness probes are initiated.
periodSeconds: 10 # How often (in seconds) to perform the probe.
failureThreshold: 1 # Minimum consecutive failures for the probe to be considered failed after having succeeded.
successThreshold: 3 # Minimum consecutive successes for the probe to be considered successful after having failed.
timeoutSeconds: 1 # Number of seconds after which the probe times out.
docker:
image: "busybox:latest"
imagePullPolicy: "Always" # Always, Never, IfNotPresent(default)
Expand Down
18 changes: 18 additions & 0 deletions riocli/apply/manifests/package-ros-device-rosbag.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ spec:
limits: # Optional
cpu: 0.025 # Unit: Core (Optional)
memory: 128 # Unit: MB (Optional)
livenessProbe: # Optional
http:
path: "/"
port: 90
initialDelaySeconds: 5 # Number of seconds after the container has started before liveness probes are initiated.
periodSeconds: 10 # How often (in seconds) to perform the probe.
failureThreshold: 1 # Minimum consecutive failures for the probe to be considered failed after having succeeded.
successThreshold: 3 # Minimum consecutive successes for the probe to be considered successful after having failed.
timeoutSeconds: 1 # Number of seconds after which the probe times out.
build:
depends:
kind: build
Expand All @@ -32,6 +41,15 @@ spec:
limits: # Optional
cpu: 0.025 # Unit: Core (Optional)
memory: 128 # Unit: MB (Optional)
livenessProbe: # Optional
exec:
command:
- "shell-cmd"
initialDelaySeconds: 5 # Number of seconds after the container has started before liveness probes are initiated.
periodSeconds: 10 # How often (in seconds) to perform the probe.
failureThreshold: 1 # Minimum consecutive failures for the probe to be considered failed after having succeeded.
successThreshold: 3 # Minimum consecutive successes for the probe to be considered successful after having failed.
timeoutSeconds: 1 # Number of seconds after which the probe times out.
docker:
image: "busybox:latest"
imagePullPolicy: "Always" # Always, Never, IfNotPresent(default)
Expand Down
53 changes: 53 additions & 0 deletions riocli/apply/manifests/package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,15 @@ spec:
limits: # Optional
cpu: 0.025 # Unit: Core (Optional)
memory: 128 # Unit: MB (Optional)
livenessProbe: # Optional
exec:
command:
- "shell-cmd"
initialDelaySeconds: 5 # Number of seconds after the container has started before liveness probes are initiated.
periodSeconds: 10 # How often (in seconds) to perform the probe.
failureThreshold: 1 # Minimum consecutive failures for the probe to be considered failed after having succeeded.
successThreshold: 3 # Minimum consecutive successes for the probe to be considered successful after having failed.
timeoutSeconds: 1 # Number of seconds after which the probe times out.
build:
depends:
kind: build
Expand All @@ -177,6 +186,14 @@ spec:
limits: # Optional
cpu: 0.025 # Unit: Core (Optional)
memory: 128 # Unit: MB (Optional)
livenessProbe: # Optional
tcp:
port: 999
initialDelaySeconds: 5 # Number of seconds after the container has started before liveness probes are initiated.
periodSeconds: 10 # How often (in seconds) to perform the probe.
failureThreshold: 1 # Minimum consecutive failures for the probe to be considered failed after having succeeded.
successThreshold: 3 # Minimum consecutive successes for the probe to be considered successful after having failed.
timeoutSeconds: 1 # Number of seconds after which the probe times out.
docker:
image: "busybox:latest"
imagePullPolicy: "Always" # Always, Never, IfNotPresent(default)
Expand Down Expand Up @@ -377,6 +394,15 @@ spec:
limits: # Optional
cpu: 0.025 # Unit: Core (Optional)
memory: 128 # Unit: MB (Optional)
livenessProbe: # Optional
exec:
command:
- "shell-cmd"
initialDelaySeconds: 5 # Number of seconds after the container has started before liveness probes are initiated.
periodSeconds: 10 # How often (in seconds) to perform the probe.
failureThreshold: 1 # Minimum consecutive failures for the probe to be considered failed after having succeeded.
successThreshold: 3 # Minimum consecutive successes for the probe to be considered successful after having failed.
timeoutSeconds: 1 # Number of seconds after which the probe times out.
build:
depends:
kind: build
Expand All @@ -388,6 +414,15 @@ spec:
limits: # Optional
cpu: 0.025 # Unit: Core (Optional)
memory: 128 # Unit: MB (Optional)
livenessProbe: # Optional
exec:
command:
- "shell-cmd"
initialDelaySeconds: 5 # Number of seconds after the container has started before liveness probes are initiated.
periodSeconds: 10 # How often (in seconds) to perform the probe.
failureThreshold: 1 # Minimum consecutive failures for the probe to be considered failed after having succeeded.
successThreshold: 3 # Minimum consecutive successes for the probe to be considered successful after having failed.
timeoutSeconds: 1 # Number of seconds after which the probe times out.
docker:
image: "busybox:latest"
imagePullPolicy: "Always" # Always, Never, IfNotPresent(default)
Expand Down Expand Up @@ -431,6 +466,15 @@ spec:
limits:
cpu: 0.025 # Unit: Core (Optional)
memory: 128 # Unit: MB (Optional)
livenessProbe: # Optional
exec:
command:
- "shell-cmd"
initialDelaySeconds: 5 # Number of seconds after the container has started before liveness probes are initiated.
periodSeconds: 10 # How often (in seconds) to perform the probe.
failureThreshold: 1 # Minimum consecutive failures for the probe to be considered failed after having succeeded.
successThreshold: 3 # Minimum consecutive successes for the probe to be considered successful after having failed.
timeoutSeconds: 1 # Number of seconds after which the probe times out.
build:
depends:
kind: build
Expand All @@ -442,6 +486,15 @@ spec:
limits:
cpu: 0.025 # Unit: Core (Optional)
memory: 128 # Unit: MB (Optional)
livenessProbe: # Optional
exec:
command:
- "shell-cmd"
initialDelaySeconds: 5 # Number of seconds after the container has started before liveness probes are initiated.
periodSeconds: 10 # How often (in seconds) to perform the probe.
failureThreshold: 1 # Minimum consecutive failures for the probe to be considered failed after having succeeded.
successThreshold: 3 # Minimum consecutive successes for the probe to be considered successful after having failed.
timeoutSeconds: 1 # Number of seconds after which the probe times out.
docker:
image: "busybox:latest"
imagePullPolicy: "Always" # Always, Never, IfNotPresent(default)
Expand Down
81 changes: 79 additions & 2 deletions riocli/jsonschema/schemas/package-schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,11 @@ definitions:
- docker
- build
- preInstalled
command:
type: string
command:
type: array
items:
type: string
description: Command to execute for the Exec probe.
runAsBash:
type: boolean
default: True
Expand All @@ -137,6 +140,10 @@ definitions:
memory:
type: number
minimum: 0
livenessProbe:
type: object
items:
"$ref": "#definations/livenessProbe"
required:
- type
dependencies:
Expand Down Expand Up @@ -734,3 +741,73 @@ definitions:
type: string
guid:
type: string

livenessProbe:
type: object
properties:
httpGet:
type: object
properties:
path:
type: string
description: Path to access for the HTTP probe.
port:
type: integer
description: Port number for the HTTP probe.
schema:
type: string
default: HTTP
description: Scheme to use for connecting to the host.
required:
- path
- port
exec:
type: object
properties:
command:
type: array
items:
type: string
description: Command to execute for the Exec probe.
required:
- command
tcpSocket:
type: object
properties:
port:
type: integer
description: Port number for the TCP probe.
required:
- port
initialDelaySeconds:
type: integer
minimum: 1
default: 1
description: Number of seconds after the container has started before liveness probes are initiated.
timeoutSeconds:
type: integer
minimum: 10
default: 1
description: Number of seconds after which the probe times out.
periodSeconds:
type: integer
minimum: 1
default: 1
description: How often (in seconds) to perform the probe.
successThreshold:
type: integer
default: 3
minimum: 1
description: Minimum consecutive successes for the probe to be considered successful after having failed.
failureThreshold:
type: integer
default: 3
minimum: 1
description: Minimum consecutive failures for the probe to be considered failed after having succeeded.
oneOf:
- required:
- httpGet
- required:
- tcpSocket
- required:
- exec
4 changes: 3 additions & 1 deletion riocli/package/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ def create_object(self, client: Client, **kwargs):
component_obj.rosBagJobDefs = self.spec.rosBagJobs

pkg_object.plans[0].components = [component_obj]

return client.create_package(pkg_object)

def update_object(self, client: Client, obj: typing.Any) -> typing.Any:
Expand Down Expand Up @@ -198,6 +197,9 @@ def _map_executable(self, exec):
'memory': exec.limits.get('memory', 0)
}

if 'livenessProbe' in exec:
exec_object.livenessProbe = exec.livenessProbe

if exec.get('runAsBash'):
if 'command' in exec:
exec_object.cmd = ['/bin/bash', '-c', exec.command]
Expand Down

0 comments on commit 750c332

Please sign in to comment.