KONG API INSTALLATION FAILURE DUE TO CASSANDRA CONFIG
We have Kong API running on Kubernetes. It uses Cassandra to store meta data. The setup used in production is clustered one but due to cost consideration we were asked to build a POC environment with single node. We were given two VMs – one to run Kubernetes control plane and other to run Cassandra and Kong worker nodes.
As you are aware there are 3 basic steps to install Kong API:
1) Create and run Cassandra pods.
2) Run Kong migrations to create Kong data schemas in Cassandra.
3) Create and run Kong pods.
We made necessary changes in values.yaml of helm charts of Cassandra and Kong to reflect new environment. When we ran Helm charts Cassandra DB and Kong migrations got created successfully but Kong pods were stuck in Init state. Kong pod had two containers: wait-for-db and Kong containers. wait-for-db container had been stuck so pod also stuck in Init state. We looked at this init container using following command:
kubectl logs <kong pod> -c wait-for-db
The error message we found in logs is:
{“log”:”Error: kong/cmd/utils/migrations.lua:25: New migrations available; run ‘kong migrations up’ to proceed\n”,”stream”:”stderr”,”time”:”2021-03-13T13:59:43.307717562Z”}
As error message had suggested to run “kong migrations up“, I have logged into init container shell and ran the command. It threw another error:
[kong@kong-pod /]$ kong migrations up
2021/03/12 14:52:13 [warn] RBAC authorization is enabled but Admin API calls will not be encrypted via SSL
Error: [Cassandra error] failed to insert cluster lock: [Unavailable exception] Cannot achieve consistency level QUORUM
Basically, the error is saying that Cassandra was not able to insert records due to insufficient quorum. Though we are using single node for Cassandra some how it was expecting a quorum. So, we revisited Kong configuration and found that Cassandra configuration was set to cluster. So we made following changes to values.yaml. Deleted Cassandra and Kong Helm deployments and re-executed Helm charts. Finally issue got fixed.
- Changed replicatio starategy from NetworkTopologyStrategy to SimpleStrategy
- Added: cassandra_repl_factor: 1
Side note, though migrations job failed to create Kong schemas it was marked as success. This prolonged our investigation.
Comments
Post a Comment