Knowledge base

How to submit a Flink SQL deployment using Ververica Platform's REST API

Written by Jun Qin | 18 February 2024

Question

I want to submit a Flink SQL deployment using Ververica Platform's REST API because I want to do it in our CI/CD system. How can I do so?

Answer

Note: This section applies to Ververica Platform 2.5 or later.

Creating a Flink SQL deployment is not much different from creating a job deployment. For example, to run the following SQL script in a deployment, you can POST with:

curl -X POST "https://<VVP_BASE_URL>/api/v1/namespaces/<namespace>/deployments" 
-H "accept: application/json" 
-H "Content-Type: application/json" -d 'json-data'

with the following JSON:

{
  "kind": "Deployment",
  "apiVersion": "v1",
  "metadata": {
    "name": "sqlscript-cicd",
    "displayName": "sqlscript-cicd"
  },
  "spec": {
    "state": "RUNNING",
    "upgradeStrategy": {
      "kind": "STATEFUL"
    },
    "restoreStrategy": {
      "kind": "LATEST_STATE",
      "allowNonRestoredState": false
    },
    "deploymentTargetName": "a-deployment-target",
    "template": {
      "spec": {
        "artifact": {
          "kind": "SQLSCRIPT",
          "sqlScript": "INSERT INTO table2 SELECT * from table1;",
          "flinkVersion": "1.15"
        },
        "flinkConfiguration": {
            ...
        }
      }
    }
  }
}

To submit to a session cluster instead of running a dedicated job cluster, replace deploymentTargetName in the JSON above with:

 "sessionClusterName": "a-session-cluster",

Related Information

Ververica Platform REST API