Check connectivity with doctor
Run read-only doctor probes against Kafka, Schema Registry and ACL permissions before the first apply, and read the results.
On this page
doctor never changes anything, so run it before the first apply against a new cluster, or as the first step of a pipeline. It takes no manifests and checks one cluster at a time.
Before you start
- A cluster config file,
clusters/prod.yamlon this page, and the environment variables and files itsvalueFromreferences point to. Connect to a secured Kafka cluster shows how to write one.
Steps
1. Run doctor
monedula-gitops doctor --cluster-config-file ./clusters/prod.yaml
When the config file or directory defines more than one cluster, select one with --cluster. -o json or -o yaml returns the result as a document:
monedula-gitops doctor --cluster-config-file ./clusters --cluster prod-eu -o json
2. Read the results
doctor runs every check, even after one fails. The human output starts with the cluster name, lists each check on its own line, marked PASS, FAIL, WARN or SKIP with a short message, and ends with Doctor: healthy or the number of failed checks. The checks run in this order:
| Check | What it does | When it fails |
|---|---|---|
config |
Confirms that the cluster config parsed. Its message summarizes the bootstrap servers, TLS on or off, the authentication mechanism and the Schema Registry endpoint, never a secret. | It always passes when doctor gets this far; a config that does not parse stops doctor with exit code 2 before any check. |
kafka-connect |
Builds the Kafka client: parses the connection settings and resolves the credentials. It makes no network call. | A setting is invalid or a referenced environment variable or file cannot be read. |
kafka-admin |
Lists the topics, the first real call to the brokers. It proves that the brokers are reachable through the Admin API and that TLS and authentication work. The message gives the number of topics. | A wrong address, or a TLS or authentication problem. If kafka-connect failed, this check is not run and fails too. |
acl-read |
Lists the ACLs. The message gives the number of ACLs. | The principal may not read ACLs, which takes Describe on the Cluster resource. |
leader-distribution |
Confirms that every rack in replicaPlacement.leaderDistribution.racks has a registered broker and asks the broker whether the principal may Alter the cluster. Skipped when the cluster config lists no racks. New in 1.2.0, see Declare replica placement and spread leaders across racks. |
A listed rack has no broker, or the principal lacks Alter on the Cluster resource. When the broker does not report the principal’s permissions or the question itself fails, the check is a WARN. |
replica-placement |
Counts the registered brokers per rack against a placement constraint declared as JSON in replicaPlacement.constraints. Skipped when the cluster config declares none. New in 1.3.0. |
A rack named by the constraint has fewer brokers than the replicas and observers asked of it, or the cluster has fewer brokers than the constraint needs in all. When the racks cannot be read, the check is a WARN. |
mds |
Authenticates to Confluent MDS and lists the role bindings in the Kafka cluster’s scope. Skipped when the cluster config has no authorization.mds. |
A wrong endpoint, credentials or TLS settings for MDS. An empty list of bindings is a pass. |
schema-registry |
Lists the Schema Registry subjects. Skipped when the cluster config has no schemaRegistry. |
A wrong endpoint, credentials or TLS settings for the registry. |
rest |
Resolves the Kafka cluster ID that the Kafka REST API serves, from rest.clusterId or by asking the API. Skipped when the cluster config has no rest; the message then warns that mirror topics are unavailable and that KafkaTopic cannot detect mirrors created outside Git. |
A wrong endpoint, credentials or TLS settings for Kafka REST, or an API that serves no cluster or several. |
rest-cluster-binding |
Compares the Kafka cluster ID from the brokers with the one from Kafka REST, and prints both. | The IDs differ (ClusterIdentityMismatch): bootstrapServers and rest.endpoint reach different clusters, so no mirror state is trusted. |
rest-mirrors |
Lists every mirror topic on the cluster. The message gives the number and notes that only read permissions were checked. | Kafka REST denies or fails the listing. |
link:<name> |
One check per cluster link on the cluster, with its state and cluster.link.prefix. |
The link is not ACTIVE or its configs cannot be read. A paused link, or one with auto.create.mirror.topics.enable=true, which can create mirrors outside Git, is a WARN. |
A skipped check or a warning does not make the result unhealthy. doctor exits 0 when no check fails, and 2 when any check fails or the command cannot start, for example because no cluster config was given, the --cluster name is unknown, or several clusters are loaded without --cluster.
In the json and yaml output, the document has the kind DoctorOutput, the cluster name, a checks list with the name, status and message of each check, and healthy, which is true when no check failed.
3. Fix what failed
Fix the first failed check first, because later checks often fail for the same reason. A kafka-connect failure points at the valueFrom references in the cluster config. A kafka-admin failure with a passing kafka-connect points at the network, TLS or credentials. Least-privilege connecting principal lists the permissions each kind of resource needs.
A healthy result does not prove that the principal may create topics, change ACLs or manage quotas and users; those permissions show up at the first apply.
The operator checks each KafkaCluster resource in a similar way and reports the result as conditions. Run this in the namespace of the KafkaCluster:
kubectl get kafkacluster prod -o jsonpath='{.status.conditions}'
Related
- The doctor command reference lists its flags.
- Validate and preview changes in CI is the next step after a healthy run.
- Runnable version: scenarios/24-doctor-preflight