Best practice of using custom DB with K8s API for Rest APIs

I have a REST WebServer writing data to MySql DB on K8s. The rest apis writes to DB during POST and fetches from DB during Get. Few Rest APIs needs to call K8s APIs underneath to access K8s resources(CRUD)

POST /api1 → write data to Mysql and return UUID on successful DB write
POST /api2 → write data to MySql, creates resource in K8s using k8s api and return UUID on successful DB and K8s write

The problem in api2 is that there are 2 writes happening in the api call workflow(Mysql, K8s ETCD). What is correct way to make writes consistent for the API to act like a single transaction? If any of writes fail, revert to the original state and return error back to the user. This will enable user to try the operation again. If both writes are successful, return UUID back to the user.

Is there a better way to handle the same problem?