Auto remove disconnected agent on kubernetes

Completed

Hi,

I deployed 1 Teamcity and 2 Agents on Kubernetes.

When my cluster restarts, there are new PODs were created and the old agents are disconnected (server shutdown).

Is there any way to remove the disconnected agents automatically? because they are using agent licenses.

Thanks,

0
2 comments
Avatar
Fedor Rumyantsev

There are multiple options you could go with:

1) if the agents are configured to use persistent storage (so that their "conf" folder persists through the restart), on start they will be picked up again by server, eliminating the need to remove and re-add. If persistent agents would work for you, I would suggest to set them up to persist their "conf" folder.

2) if you want the agents to start clean, with no data persistance, there is a Kubernetes plugin allowing to use Cloud Profile feature with Kubernetes cluster.
More on Cloud Profiles: https://www.jetbrains.com/help/teamcity/agent-cloud-profile.html
Plugin: https://plugins.jetbrains.com/plugin/9818-kubernetes-support
With this, you could set up a pool of agents based on cluster; it would help to ensure agents are automatically deployed on demand.

3) alternatively, you can also use REST API to unauthorize agents after restart (so that they do not count as license consumers) and remove them.
If this approach would work for you, I`d suggest to check the following endpoint:
https://www.jetbrains.com/help/teamcity/rest-api.html#RESTAPI-Agents
Namely, "Authorize/unauthorize an agent" and "Delete a build agent" methods.

0
Avatar
Permanently deleted user

Thank you,
I am using option 1 but if I have 3 pods, i create 3 deployments with 3 volumes. I don't know it is corect or not but it is working for me.

I will try the option 2.

0

Please sign in to leave a comment.