<a id="cmf-manage-apps"></a>

# Describe, Update and Delete Confluent Manager for Apache Flink Applications

Flink applications are deployed in Confluent Platform with Confluent Manager for Apache Flink® (CMF), which is a
central management component of Confluent Platform for Apache Flink. CMF enables you to manage a fleet of Flink jobs, either applications or SQL statements,
across multiple environments.
There are different ways to interact with Confluent Manager for Apache Flink application resources.

## Describe an application

You can check the current state of an Application by fetching the resource.
The following example shows how to use the REST API or the Confluent CLI to describe an application:

### REST API

The following example show how to use the REST API to describe an application:

```bash
curl -v -H "Content-Type: application/json" \
http://cmf:8080/cmf/api/v1/environments/env-1/applications/app-1
```

### Confluent CLI

The following example shows how to use the Confluent CLI with the `describe` command to describe an application:

```bash
confluent --environment env-1 flink application describe app-1
```

## Update an application

You can make changes to an application by updating it. Common operations are rescaling, suspending and resuming an
application.

- To scale an application up or down, you have to adjust the `spec.job.parallelism` field.
- You can suspend an application by setting the `spec.job.state` field to `suspended` and it is resumed by setting
  the field to `running`.
- You can resume an application by setting the `spec.job.state` field to `running`.

CMF provides [Application Instances](application-instances.md#cmf-application-instances) to track application updates.
An update results in a new application instance when it changes the effective
specification of the application, which is the application specification
merged with the environment defaults.

### REST API

The following example shows how to update an application with the REST API. The example
uses a POST request to update the resource with an adjusted resource file `app-1.json`:

```bash
curl -v -H "Content-Type: application/json" \
-X POST http://cmf:8080/cmf/api/v1/environments/env-1/applications \
-d @/path/to/app-1.json
```

### Confluent CLI

The following example shows e Confluent CLI with the `update` to update an
application with the adjusted resource file `app-1.json`:

```bash
confluent --environment env-1 flink application update /path/to/app-1.json
```

## Delete an application

You can delete an application by deleting the application resource using the REST API or the Confluent CLI. This will also delete the corresponding Flink cluster.

### REST API

The following example shows how you can delete an application with the
REST API:

```bash
curl -v -H "Content-Type: application/json" \
-X DELETE http://cmf:8080/cmf/api/v1/environments/env-1/applications/app-1
```

### Confluent CLI

The following example shows how you can delete an application with the
Confluent CLI:

```bash
confluent --environment env-1 flink application delete app-1
```

## Inspect an application with the Flink WebUI

Apache Flink provides a WebUI that you can use to inspect a Flink job.
By default, this WebUI is not accessible, but the Confluent CLI features a command to port-forward
requests to the Flink WebUI, and make it available locally.

The following command starts port forwarding, which exposes the Flink WebUI on port 8088:

```bash
confluent --environment env-1 --port 8088 flink application web-ui-forward app-1
```

You can access the WebUI of the application’s Flink cluster with a browser at [http://localhost:8088](http://localhost:8088).

#### NOTE
CMF can’t proxy the Flink Web UI when TLS is enabled on the Flink REST endpoint (`security.ssl.rest.enabled: true`).
As a workaround, run `kubectl -n <namespace> port-forward svc/<cluster-id>-rest 8081:8081` and open `https://localhost:8081`.

<a id="cmf-manage-apps-disconnected-cluster"></a>

## Behavior on disconnected or decommissioned clusters

When the Kubernetes cluster that an environment is bound to is `DISCONNECTED` or
`DECOMMISSIONED`, the behavior of application operations changes:

- **Read operations** (describe, list) return the last known data cached in CMF. The response
  includes a `status.warning` field indicating that the data may be stale and does not reflect
  the actual state on Kubernetes.
- **Write operations** (create, update, start, suspend, delete) are rejected with **HTTP 503**.

To remove an application from CMF’s database when the cluster is unreachable, use
`?force=true` on the delete request. With `force`, CMF skips the cluster
connectivity check, still tries to delete the `FlinkDeployment` on Kubernetes,
and removes the application from its database even if the Kubernetes delete
fails. In that case, the `FlinkDeployment` custom resource is left as an
orphan on the cluster. `force` does not bypass the savepoint check. If
savepoints are attached to the application, the request fails with HTTP 409
until you detach or delete them.

```bash
curl -X DELETE \
  "http://cmf:8080/cmf/api/v1/environments/env-1/applications/app-1?force=true"
```

For more information on cluster states and recovery, see [Manage Multiple Kubernetes Clusters in Confluent Manager for Apache Flink](../../configure/kubernetes-clusters.md#cmf-kubernetes-clusters).

## Related content

- [Application Instances in Confluent Manager for Apache Flink](application-instances.md#cmf-application-instances)
- [Create Confluent Manager for Apache Flink Applications](create.md#cmf-create-apps)
- [Savepoint Management in Confluent Manager for Apache Flink](../savepoints.md#cmf-savepoints)
- [Manage Multiple Kubernetes Clusters in Confluent Manager for Apache Flink](../../configure/kubernetes-clusters.md#cmf-kubernetes-clusters)
