Manage application instance pods using the saectl tool

更新时间:
复制 MD 格式

Application instances in Serverless App Engine (SAE) map to the pod resource type in Kubernetes. Use the saectl tool to inspect, debug, and delete instance pods directly from the command line.

saectl supports viewing and deleting instances only. You cannot use it to create or update application instances. To modify the application, use the SAE console or API.

Prerequisites

Before you begin, ensure that you have:

List instances

Run saectl get pod to list the instances for an application.

saectl get pod [<instance-id>] -n <namespace-id> -l sae.aliyun.com/app-name=<app-name>

Parameters

ParameterDescriptionDefault
<instance-id>Instance ID.If omitted, all instances in scope are returned.
-n <namespace-id>Namespace ID.If omitted, the default namespace is used.
-l sae.aliyun.com/app-name=<app-name>Filter by application name.If omitted, instances of all applications in scope are returned.

Output fields

FieldDescription
NAMEInstance ID.
READYNumber of ready containers / total containers. A container is ready when it passes the readiness probe check.
STATUSInstance status. Running means the instance is running.
RESTARTSNumber of container restarts.
AGEHow long the instance has been running.

Common variants

# List all instances in a namespace
saectl get pod -n <namespace-id>

# List instances for a specific application
saectl get pod -n <namespace-id> -l sae.aliyun.com/app-name=<app-name>

# Get a specific instance in YAML format
saectl get pod <instance-id> -o yaml -n <namespace-id>

# Get a specific instance in JSON format
saectl get pod <instance-id> -o json -n <namespace-id>

View instance details

Use get or describe to inspect the full configuration of an instance. The output includes all K8s YAML configuration fields described in K8s YAML configuration fields.

With get (YAML or JSON output)

saectl get pod <instance-id> -o yaml -n <namespace-id>
ParameterDescription
<instance-id>Instance ID.
-o {yaml | json}Output format.
-n <namespace-id>Namespace ID. Defaults to the default namespace if omitted.

With describe (human-readable output)

saectl describe pod <instance-id> -n <namespace-id>
ParameterDescription
<instance-id>Instance ID.
-n <namespace-id>Namespace ID. Defaults to the default namespace if omitted.

View instance logs

saectl logs <instance-id> -n <namespace-id>
ParameterDescriptionDefault
<instance-id>Instance ID.Required.
-n <namespace-id>Namespace ID.Defaults to the default namespace if omitted.

Open a shell on an instance

saectl exec -it <instance-id> /bin/bash -n <namespace-id>
ParameterDescription
<instance-id>Instance ID.
-itAllocates a TTY and keeps stdin open for an interactive session.
-n <namespace-id>Namespace ID. Defaults to the default namespace if omitted.

Delete an instance

saectl delete pod <instance-id> -n <namespace-id>
ParameterDescription
<instance-id>Instance ID.
-n <namespace-id>Namespace ID. Defaults to the default namespace if omitted.

K8s YAML configuration fields

SAE instances correspond to the Kubernetes pod resource type. The following table describes the relevant K8s YAML configuration fields.

FieldDescription
metadata.nameInstance ID.
metadata.namespaceNamespace where the instance resides.
metadata.uidInstance ID.
metadata.labelsFixed format: sae.aliyun.com/app-name: <app-name>
metadata.ownerReferencesThe Deployment to which the instance belongs. Fixed format shown below.
spec.containersContainer configuration for the instance.
status.podIPIP address of the instance.

metadata.labels

labels:
  sae.aliyun.com/app-name: <app-name>

metadata.ownerReferences

ownerReferences:
- apiVersion: apps/v1
  kind: Deployment
  name: <app-name>
  uid: <app-id>