CLI tool to automate server lifecycle
A new customer server starts with a hand-written manifesta HubSpot event.
My team lead's workstream. I delivered most of its tickets, including the rewrite into a CLI.
A customer starts life as a record in HubSpot, but their server starts life as a manifest in the GitOps repository, in one of five regions.
Why it was needed
Someone carried the name, CRM ID, cluster, purpose and expiry from one to the other by hand, for every create, update and delete. That was slow, and one wrong value meant a wrong server.
How it was done
A HubSpot workflow triggers a GitLab pipeline, and the CLI checks the payload, writes the manifest and opens a merge request.
A person approves and Argo CD deploys, so the CRM can propose a change to production but never make one.
Rebuilt it as one Python CLI, published to the internal registry and released by Git tag.
Replaced pip with uv, and merged five per-region sync jobs into one threaded job.
Problems on the way
Deleting a server made its cleanup impossible.
The keys to de-register it from a remote-access service lived in the database being deleted. Fix: An Argo CD pre-delete hook de-registers first, and blocks the delete if that fails.
An upgrade wave hit seven servers it should not have, and missed nineteen.
A missing upgrade date and a CRM that disagreed with the clusters, a risk I had documented but not enforced. Fix: Traced both causes. The check belongs in the pipeline, not only in the runbook.
A documented risk is not a fixed risk.
Results
- 36%faster server creation, 58 to 37 seconds
- 5 → 1HubSpot sync jobs, now about 28 seconds
- 3lifecycle actions opened as merge requests