Command Discovery
Commands discovered in a namespace can vary depending on what is installed in that namespace.
There are two types of custom resources (CRs) that the Admin Service is looking for:
- An
AdminCommand
CR describes a single command that can be executed in the current namespace. - An
AdminCommandDiscoveryEndpoint
CR describes a URL that returns 1 or more command definitions that can be executed in the current namespace.
Choose the CR type based on on the context of the command and how it is to be maintained. For example, if the command is closely-coupled to an application, you can expose an HTTP endpoint
to define the available commands using the AdminCommandDiscoveryEndpoint
CR. The commands returned may change over different versions of the application without the need
for any change to the CR or Helm chart.
The AdminCommand
CR is more appropriate for commands not closely linked with any one application, or where the application cannot be modified, or does not support HTTP
endpoints.
The AdminCommand
custom resource definition (CRD) contains the command definition in the spec attribute:
apiVersion: matrixx.matrixx.com/v1
kind: AdminCommand
metadata:
name: pod-id
spec:
command:
name: id
description: Runs the id command on a pod
resourceSelector:
kind: pods
labels:
app: myapp
executor:
executeOnPod:
command:
- "/bin/sh"
- "-c"
- "id"
The AdminCommandDiscoveryEndpoint
CRD has a single url
attribute in the spec
that points to the URL where the command definition can be
queried:
apiVersion: matrixx.matrixx.com/v1
kind: AdminCommandDiscoveryEndpoint
metadata:
name: myk-service-commands
spec:
url: http://my-service.app-one/commands