---
title: Charmhub | Deploy Apache Kafka Connect - K8s using Charmhub - The Open Operator
  Collection
description: Deploy the latest version of Apache Kafka Connect - K8s as a Kubernetes
  Operator on any cloud.
url: https://charmhub.io/kafka-connect-k8s/docs/h-manage-message-schemas
---

# Apache Kafka Connect - K8s

[Canonical](https://charmhub.io/publisher/data-platform "View all packages from Canonical")

* [Canonical](https://charmhub.io/publisher/data-platform "View all packages from Canonical")

Platform:

4/stable 18

```
juju deploy kafka-connect-k8s --channel 4/stable
```

[Learn to deploy on juju >](https://juju.is/docs/juju/manage-applications)

---

#### Relevant links

* [Homepage](https://github.com/canonical/kafka-connect-k8s-operator)

---

#### Contacts

##### Maintainers

+ [Canonical Data Platform](mailto:data-platform@lists.launchpad.net)

* [Submit a bug](https://github.com/canonical/kafka-connect-k8s-operator/issues)

---

Share your thoughts on this charm with the community on discourse.

[Join the discussion](https://discourse.charmhub.io/)

# Manage message schemas

Message schemas in Apache Kafka define the structure and format of data exchanged between producers and consumers. This guide provides instructions on managing schemas in Charmed Apache Kafka using Karapace. Karapace is a drop-in replacement, open-source implementation of Confluent’s Schema Registry, and supports the storing of schemas in a central repository, which clients can access to serialize and deserialize messages written to Apache Kafka.

## [Prerequisites](https://charmhub.io/kafka-connect-k8s/docs/h-manage-message-schemas#p-36671-prerequisites)

Follow the steps of the [How to deploy Charmed Apache Kafka K8s](https://charmhub.io/kafka-connect-k8s/docs/h-deploy-anywhere) guide to set up the environment. For this guide, we will need an active Charmed Apache Kafka application, related to an active Charmed Apache ZooKeeper application.

## [Deploy and set up Karapace](https://charmhub.io/kafka-connect-k8s/docs/h-manage-message-schemas#p-36671-deploy-and-set-up-karapace)

To deploy Karapace and integrate it with Apache Kafka, use the following commands:

```
juju deploy karapace --channel latest/edge
juju integrate karapace kafka-k8s
```

Once deployed, the password to access the Karapace REST API can be obtained:

```
juju run karapace/leader get-password username="operator"
```

To check that Karapace works correctly, list all registered schemas using the password from the previous command’s output:

```
curl -u operator:<password> -X GET http://<karapace-unit-ip>:8081/subjects
```

## [Registering a new schema](https://charmhub.io/kafka-connect-k8s/docs/h-manage-message-schemas#p-36671-registering-a-new-schema)

To register the first version of a schema `<schema-name>` with fields `<field1>` which is a string, and `<field2>` which is an integer using Avro schema, run:

```
curl -u operator:<password> -X POST -H "Content-Type: application/vnd.schemaregistry.v1+json" \
     http://<karapace-unit-ip>:8081/subjects/<schema-name>/versions \ --data '{"schema": "{\"type\": \"record\", \"name\": \"Obj\", \"fields\":[{\"name\": \"<field1>\", \"type\": \"string\"},{\"name\": \"<field2>\", \"type\": \"int\"}]}"}'
```

If successful, this should result in an output showing the global ID for this new schema:

```
{"id":1}
```

To register a version of the same schema above using JSON schema to a different subject with name `<schema-name-json>`, run:

```
curl -u operator:<password> -X POST -H "Content-Type: application/vnd.schemaregistry.v1+json" \
    http://<karapace-unit-ip>:8081/subjects/<schema-name-json>/versions \
    --data '{"schemaType": "JSON", "schema": "{\"type\": \"object\",\"properties\":{\"<field1>\":{\"type\": \"string\"}, \"<field2>\":{\"type\": \"number\"}},\"additionalProperties\":true}"}'
```

If successful, this should result in output:

```
{"id":2}
```

## [Add new schema version](https://charmhub.io/kafka-connect-k8s/docs/h-manage-message-schemas#p-36671-add-new-schema-version)

To test the compatibility of a schema with the latest schema version, for example `<schema-name>` schema with `<field2>` removed, run:

```
curl -u operator:<password> -X POST -H "Content-Type: application/vnd.schemaregistry.v1+json" \
     http://<karapace-unit-ip>:8081/subjects/<schema-name>/versions/latest \
    --data '{"schema": "{\"type\": \"record\", \"name\": \"Obj\", \"fields\":[{\"name\": \"<field1>\", \"type\": \"string\"}]}"}'
```

If compatible, this will result in output:

```
{"is_compatible":true}
```

To register a new schema version, run:

```
curl -u operator:<password> -X POST -H "Content-Type: application/vnd.schemaregistry.v1+json" \
     http://<karapace-unit-ip>:8081/subjects/<schema-name>/versions \
    --data '{"schema": "{\"type\": \"record\", \"name\": \"Obj\", \"fields\":[{\"name\": \"<field1>\", \"type\": \"string\"}]}"}'
```

## [Delete schema version](https://charmhub.io/kafka-connect-k8s/docs/h-manage-message-schemas#p-36671-delete-schema-version)

To delete a specific schema version:

```
curl -u operator:<password> -X DELETE http://<karapace-unit-ip>:8081/subjects/<schema-name>/versions/<schema-version>
```

To delete all versions of a schema:

```
curl -u operator:<password> -X DELETE http://<karapace-unit-ip>:8081/subjects/<schema-name-json>
```

---
