All Products
Search
Document Center

Microservices Engine:Deploy SchedulerX in a Kubernetes cluster

Last Updated:Mar 11, 2026

SchedulerX schedules periodic programs, runs scripts in Shell, Python, PHP, and Node.js, calls HTTP operations, and manages native Kubernetes Jobs, CronJobs, and Pods. This topic covers three deployment methods and how to create Jobs after deployment.

Why use SchedulerX for Kubernetes scheduling

Edit scripts without rebuilding images

Standard Kubernetes Jobs require you to package scripts into container images and configure commands in YAML. Every script change means a new image build and redeployment.

With SchedulerX, edit scripts directly in the console. SchedulerX runs them in Pods automatically, and changes take effect on the next scheduled run. No image builds or YAML updates are needed.

Supported languages: Shell, Python, PHP, and Node.js.

Show code

apiVersion: batch/v1
kind: Job
metadata:
  name: hello
spec:
  template:
    spec:
      containers:
      - name: hello
        image: registry.cn-hangzhou.aliyuncs.com/test/hello:1.0.0
        command: ["sh",  "/root/hello.sh"]
      restartPolicy: Never
  backoffLimit: 4

Drag-and-drop workflow orchestration

SchedulerX provides a visual editor for orchestrating Kubernetes Jobs with drag-and-drop operations. Running workflows are displayed as directed acyclic graphs (DAGs), making it straightforward to identify blocked Jobs and troubleshoot issues.

Show code

# Diamond workflow:
#   A
#  / \
# B   C
#  \ /
#   D
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
  generateName: dag-diamond-
spec:
  entrypoint: diamond
  templates:
  - name: diamond
    dag:
      tasks:
      - name: A
        template: echo
        arguments:
          parameters: [{name: message, value: A}]
      - name: B
        depends: "A"
        template: echo
        arguments:
          parameters: [{name: message, value: B}]
      - name: C
        depends: "A"
        template: echo
        arguments:
          parameters: [{name: message, value: C}]
      - name: D
        depends: "B && C"
        template: echo
        arguments:
          parameters: [{name: message, value: D}]

  - name: echo
    inputs:
      parameters:
      - name: message
    container:
      image: alpine:3.7
      command: [echo, "{{inputs.parameters.message}}"]

Argo Workflows, a widely adopted solution, requires workflow definitions in YAML:

Built-in monitoring and alerting

SchedulerX monitors every Pod and Job it schedules:

  • Alert channels: text messages, phone calls, emails, and webhook URLs for DingTalk, WeCom, and Lark bots.

  • Alert triggers: Job execution failures and timeouts.

Automatic log collection

SchedulerX collects Pod and Job logs automatically. When a Pod fails, check the logs directly in the SchedulerX console instead of running kubectl logs.

Log collection in the SchedulerX console

Real-time monitoring dashboard

The Overview page in the SchedulerX console displays all Jobs and their status in real time.

Mixed deployment of online and offline Jobs

Some periodic Jobs consume significant resources but run infrequently (for example, once per hour or once per day). Instead of running them in the same process as your business application, create a separate Pod for the Job. This isolates resource-intensive batch work from your online services. SchedulerX supports scheduling both Java and Kubernetes Job types in a single environment.

Prerequisites

Before you begin, make sure that you have:

Create a Kubernetes application

Choose a deployment method

MethodBest forHow it works
Deployment YAML (recommended)Non-Java applicationsDeploys the SchedulerX agent as a standalone Pod
Helm chartNon-Java applications with Helm-based workflowsInstalls the agent through a Helm package
Java SDKJava applications that also schedule Kubernetes JobsEmbeds SchedulerX in your application process

Agent image reference

All Deployment-based and Helm-based installations use the SchedulerX agent image. Select the image that matches your cluster's chip architecture and region.

ArchitectureChina regionsOutside China
x86_64registry.cn-hangzhou.aliyuncs.com/schedulerx/agent:latest-amd64schedulerx-registry.ap-southeast-1.cr.aliyuncs.com/schedulerx/agent:latest-amd64
ARM64registry.cn-hangzhou.aliyuncs.com/schedulerx/agent:latest-arm64schedulerx-registry.ap-southeast-1.cr.aliyuncs.com/schedulerx/agent:latest-arm64

Agent environment variables

The SchedulerX agent requires the following environment variables. Find these values on the Application Management and Namespace pages in the SchedulerX console.

VariableDescriptionExample
SCHEDULERX_ENDPOINTRegional endpoint for your application. See Endpoints.addr-sh-internal.edas.aliyun.com
SCHEDULERX_NAMESPACENamespace ID, found on the Namespace page.f856c3f8-a15c-...
SCHEDULERX_GROUPIDApplication ID, found on the Application Management page.k8s-test3
SCHEDULERX_APPKEYApplication key, found on the Application Management page.--
View the namespace ID

Method 1 (recommended): Deploy using a Deployment

For non-Java applications, deploy schedulerx-agent.yaml as a Deployment. The SchedulerX agent runs as a standalone Pod that communicates with the Kubernetes API server.

SchedulerX Deployment architecture

Step 1: Configure a service account

The service account provides an identity for validation and authorization when SchedulerX schedules Kubernetes Jobs. By default, the service account of the namespace to which the Job belongs is used.

Run the service account YAML once per namespace. Choose the scope that fits your use case:

ScopeWhen to useRBAC resources
Single namespaceSchedule Pods and Jobs within one namespace onlyRole + RoleBinding
Cross-namespaceSchedule Pods and Jobs across multiple namespacesClusterRole + ClusterRoleBinding

Single-namespace scope

Show code

apiVersion: v1
kind: ServiceAccount
metadata:
  name: schedulerx
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: schedulerx-role
rules:
  - apiGroups: [""]
    resources: ["pods"]
    verbs: ["create","delete","get","list","patch","update","watch"]
  - apiGroups: [""]
    resources: ["pods/log"]
    verbs: ["get","list","watch"]
  - apiGroups: [""]
    resources: ["configmaps"]
    verbs: ["create","delete","get","list","patch","update"]
  - apiGroups: [""]
    resources: ["events"]
    verbs: ["watch"]
  - apiGroups: ["batch"]
    resources: ["jobs","cronjobs"]
    verbs: ["create","delete","get","list","patch","update","watch"]
---
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: schedulerx-binding
subjects:
  - kind: ServiceAccount
    name: schedulerx
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: schedulerx-role

Apply the YAML:

kubectl apply -f schedulerx-serviceaccount.yaml -n <your-namespace>

Cross-namespace scope

Replace <NAMESPACE1> and <NAMESPACE2> with the namespaces where the SchedulerX service account should operate.

Apply the YAML:

kubectl apply -f schedulerx-clusterrole.yaml

Show code

apiVersion: v1
kind: ServiceAccount
metadata:
  name: schedulerx
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: schedulerx-cluster-role
rules:
  - apiGroups: [""]
    resources: ["pods"]
    verbs: ["create","delete","get","list","patch","update","watch"]
  - apiGroups: [""]
    resources: ["pods/log"]
    verbs: ["get","list","watch"]
  - apiGroups: [""]
    resources: ["configmaps"]
    verbs: ["create","delete","get","list","patch","update"]
  - apiGroups: [""]
    resources: ["events"]
    verbs: ["watch"]
  - apiGroups: ["batch"]
    resources: ["jobs","cronjobs"]
    verbs: ["create","delete","get","list","patch","update","watch"]
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: schedulerx-cluster-binding
subjects:
  - kind: ServiceAccount
    name: schedulerx
    namespace: <NAMESPACE1>
  - kind: ServiceAccount
    name: schedulerx
    namespace: <NAMESPACE2>
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: schedulerx-cluster-role

Step 2: Install the SchedulerX agent

Create a file named schedulerx-agent.yaml with the following content. Replace the environment variable values with your application's access parameters (see Agent environment variables).

Show code

apiVersion: apps/v1
kind: Deployment
metadata:
  name: schedulerx-agent
  labels:
    app: schedulerx-agent
spec:
  replicas: 1
  selector:
    matchLabels:
      app: schedulerx-agent
  template:
    metadata:
      labels:
        app: schedulerx-agent
    spec:
      serviceAccountName: schedulerx
      containers:
      - name: schedulerx-agent
        image: <agent-image>    # See the agent image reference table
        imagePullPolicy: Always
        resources:
          limits:
            cpu: 500m
          requests:
            cpu: 500m
        env:
          - name: "SCHEDULERX_ENDPOINT"
            value: "<your-endpoint>"
          - name: "SCHEDULERX_NAMESPACE"
            value: "<your-namespace-id>"
          - name: "SCHEDULERX_GROUPID"
            value: "<your-app-id>"
          - name: "SCHEDULERX_APPKEY"
            value: "<your-app-key>"
          - name: "SCHEDULERX_STARTER_MODE"
            value: "pod"
        livenessProbe:
          exec:
            command: ["/bin/bash","/root/health.sh"]
          timeoutSeconds: 30
          initialDelaySeconds: 30

Apply the Deployment:

kubectl apply -f schedulerx-agent.yaml -n <your-namespace>

Verify the deployment

  1. Check that the agent Pod is running: Expected output:

       kubectl get pods -l app=schedulerx-agent -n <your-namespace>
       NAME                               READY   STATUS    RESTARTS   AGE
       schedulerx-agent-xxxxxxxxx-xxxxx   1/1     Running   0          1m
  2. Confirm the agent is connected by checking the Application Management page in the SchedulerX console. An available instance indicates a successful connection.

Method 2: Deploy using a Helm chart

If your team uses Helm for Kubernetes package management, install the SchedulerX agent as a Helm chart.

Additional prerequisite: Helm is installed on your machine.

Step 1: Download the Helm chart

wget https://schedulerx2.oss-cn-hangzhou.aliyuncs.com/helm/schedulerxchart-2.0.0.tgz

Step 2: Install the Helm chart

  1. Get your application's access parameters from the SchedulerX console:

    1. Log on to the MSE SchedulerX console.

    2. In the top navigation bar, select a region.

    3. In the left-side navigation pane, click Application Management.

    4. On the Application Management page, click Access configuration in the Operation column. In the upper-left corner of the Access configuration panel, select k8s from the drop-down list.

  2. Run the installation command. Replace the placeholder values with your access parameters:

    Note

    The default image in the access configuration is the x86_64 Internet image. Select an image that matches your cluster's architecture and region from theagent image referencetable.

       helm install schedulerxchart schedulerxchart-2.0.0.tgz \
         --set SCHEDULERX_ENDPOINT=<your-endpoint> \
         --set SCHEDULERX_NAMESPACE=<your-namespace-id> \
         --set SCHEDULERX_GROUPID=<your-app-id> \
         --set SCHEDULERX_APPKEY=<your-app-key> \
         --set SCHEDULERX_AGENT_IMAGE=<agent-image>

    Helm installation process

Verify the deployment

  1. Check that the agent Pod is running: Expected output:

       kubectl get pods -l app=schedulerx-agent -n <your-namespace>
       NAME                               READY   STATUS    RESTARTS   AGE
       schedulerx-agent-xxxxxxxxx-xxxxx   1/1     Running   0          1m
  2. Confirm the agent is connected by checking the Application Management page in the SchedulerX console. An available instance indicates a successful connection.

Method 3: Deploy using the SchedulerX Java SDK

For Java applications that need to schedule both Java programs and Kubernetes Jobs, embed SchedulerX in your application using the Java SDK. In this mode, SchedulerX shares the same process as your application.

Java SDK architecture

Connect your application to SchedulerX

  1. Integrate the SchedulerX SDK for Java with your Spring Boot application. See Connect a Spring Boot application to SchedulerX.

  2. Add the schedulerx-plugin-kubernetes dependency to enable Kubernetes Job scheduling:

    Note

    Replace schedulerx2.version with the latest version. See Release notes.

       <dependency>
         <groupId>com.aliyun.schedulerx</groupId>
         <artifactId>schedulerx2-spring-boot-starter</artifactId>
         <version>${schedulerx2.version}</version>
       </dependency>
       <dependency>
         <groupId>com.aliyun.schedulerx</groupId>
         <artifactId>schedulerx2-plugin-kubernetes</artifactId>
         <version>${schedulerx2-plugin-kubernetes.version}</version>
       </dependency>

Create and run Kubernetes Jobs

After deploying the SchedulerX agent, create Kubernetes Jobs from the SchedulerX console. For all Job types below, go to the Task Management page and click Create task. For full details, see Job management.

Run a Shell script

  1. In the Create task panel, set Task type to K8s and resource to Shell-Script.

  2. Use the default busybox image or specify a custom image.

  3. Click Run once.

A Pod named schedulerx-shell-{JobId} starts in the cluster.

Shell script Pod running in the cluster

Check the execution history and Pod logs on the Task Management page.

Run a Python script

  1. In the Create task panel, set Task type to K8s and resource to Python-Script.

  2. Use the default python image or specify a custom image.

  3. Click Run once.

A Pod named schedulerx-python-{JobId} starts in the cluster.

Python script Pod running in the cluster

Check the execution history and Pod logs on the Task Management page.

Python script execution logs

Run a PHP script

  1. In the Create task panel, set Task type to K8s and resource to Php-Script.

  2. Use the default php:7.4-cli image or specify a custom image.

    PHP script creation

  3. Click Run once.

A Pod named schedulerx-php-{JobId} starts in the cluster.

PHP script Pod running in the cluster

Check the execution history and Pod logs on the Task Management page.

PHP script execution logs

Run a Node.js script

  1. In the Create task panel, set Task type to K8s and resource to Nodejs-Script.

  2. Use the default node:16 image or specify a custom image.

    Node.js script creation

  3. Click Run once.

A Pod named schedulerx-node-{JobId} starts in the cluster.

Node.js script Pod running in the cluster

Check the execution history and Pod logs on the Task Management page.

Node.js script execution logs

Run a native Kubernetes Job (Job-YAML)

  1. In the Create task panel, set Task type to K8s and resource to Job-YAML.

  2. Enter the Job YAML definition.

    Job-YAML creation

  3. Click Run once.

The Job and its Pod start in the cluster.

Job-YAML Pod running in the cluster

Check the execution history and Pod logs on the Task Management page.

Job-YAML execution logs

Run a native Kubernetes CronJob (CronJob-YAML)

  1. In the Create task panel, set Task type to K8s and resource to CronJob-YAML.

  2. Enter the CronJob YAML definition.

    CronJob-YAML creation

  3. Click Run once.

In the Operation column for the Job, choose more > Historical records to view the Pod status in the Task instance records panel.

CronJob-YAML execution

Check the Pod execution history and logs on the Task Management page.

CronJob-YAML execution logs

Run a native Kubernetes Pod (Pod-YAML)

  1. In the Create task panel, set Task type to K8s and resource to Pod-YAML.

  2. Enter the Pod YAML definition.

    Pod-YAML creation

  3. Click Run once.

The Pod starts in the cluster.

Pod-YAML Pod running in the cluster

Check the execution history and Pod logs on the Task Management page.

Pod-YAML execution logs
Note

When using Pod-YAML, keep the following in mind:

  • Avoid scheduling long-running Pods, such as web application Pods. Once started, these Pods never complete.

  • Disable Pod restart policies. Otherwise, the Pod restarts repeatedly after completion.

What's next