Setting Up TeamCity for Kubernetes
TeamCity integration with Kubernetes does not depend on the
kubectl tool and thus does not require installing it in your cluster.
Make sure the TeamCity user is allowed to perform writing operations in the Kubernetes namespace used by TeamCity agents.
You might also require to configure the following privileges for your Kubernetes user role:
get— if you want to create an agent pod using a deployment configuration.
list— to allow TeamCity to suggest the namespaces available on your server.
Here is an example of setting up all required permissions via Kubernetes RBAC:
Kubernetes Cloud Profile Configuration
To establish the integration with Kubernetes, you need to create a dedicated cloud profile in TeamCity. Open the settings of the required project and, under the Cloud Profiles section, click Create new profile.
The table below lists options specific for Kubernetes cloud profiles.
Kubernetes API server URL
Specify the URL of the Kubernetes API server.
Certificate Authority (CA)
Enter the content of the CA certificate for your cluster.
Select the required authentication strategy.
Depending on the selected strategy, the set of extra options will vary. Refer to the Kubernetes documentation for details on available options.
Adding Kubernetes Cloud Image
After configuring the general Kubernetes settings, you can proceed with adding a new build agent image.
Click Add image and configure its options:
Select one of the three types described below.
Assign the launched instances to a specific agent pool.
Agent name prefix
(Optional) Show the same prefix for all instances of this image, when displaying them in TeamCity.
Max number of instances
(Optional) Set this number if you want to limit how many instances are launched based on this image.
Use pod template from deployment
Select this option to run a new pod based on a specific deployment configuration created in your Kubernetes cluster. If you are using Kubernetes Dashboard, you can find the list of available deployments under Workloads | Deployments.
You can create a simple deployment from the latest TeamCity agent image as follows:
Run single container
Docker image name
Name of the Docker image, similarly to the one used with the
Image pull policy
The policy of updating the image.
(Optional) Set the command run by the container.
(Optional) Set the command arguments.
Use custom pod template
Enter your own pod template in a YAML format. Use this option when you need to specify additional configuration for a launched pod, such as resources' requests/limits or credentials. This option is alternative to the template from deployment specification and allows editing the configuration directly in the TeamCity UI/DSL.
Example of a simple template: