Author: Harry Lee
Work in progress!
The purpose of this project is to create a dockerized TeamCity Agent that can be deployed on Kubernetes. Included in the image is aws-cli and kubectl. This project is adapted from the Official TeamCity Docker Agent. The instructions from the official repo is still applicable and should be followed before using this repo.
- You want to implement CI/CD using TeamCity with the agent deployed in Kubernetes.
- Your Kubernetes cluster is deployed on AWS.
- You are running CI using docker containers.
- You want to build docker images in docker containers (Docker in Docker).
- You want to push docker images to AWS ECR.
- Your CI/CD workflow consists of only
bash/shell
,docker
,kubectl
andawscli
.
This image differs from the official image in that it is based on the official OpenJDK image: openjdk:8-jre.
Further, kubectl
and awscli
is installed in order to deploy to Kubernetes and push images to AWS ECR.
-
Ensure that you have downloaded the buildAgent.zip installation file following these instructions.
-
Extract the contents of buildAgent.zip to
dist/buildagent/
in the current directory (where the Dockerfile is) using the following commands:mkdir dist unzip buildAgent.zip -d dist/buildagent mv dist/buildagent/conf dist/buildagent/conf_dist
-
Build the docker image using:
docker build -t teamcity-agent .
-
To run and test the image on your local machine:
docker run --name=teamcity-agent \ -e SERVER_URL=<value> \ -e DOCKER_IN_DOCKER="start" \ -e AWS_ACCESS_KEY_ID=<value> \ -e AWS_SECRET_ACCESS_KEY=<value> \ -e CLUSTER_NAME=<value> \ -e USER_NAME=<value> \ -e MASTER_LOAD_BALANCER=<value> \ -e S3_BUCKET=<value> \ -e S3_KEY=<value> \ --privileged \ -d teamcity-agent
SERVER_URL
is the URL of the TeamCity Server, it needs to be in the form: http://<value>/DOCKER_IN_DOCKER
specifies if Docker in Docker is to be usedAWS_ACCESS_KEY_ID
is the AWS_ACCESS_KEY_ID for the AWS IAM role of the userAWS_SECRET_ACCESS_KEY
is the AWS_SECRET_ACCESS_KEY for the AWS IAM role of the userCLUSTER_NAME
is the name of the Kubernetes clusterUSER_NAME
is the user that is enrolled into Kubernetes through RBACMASTER_LOAD_BALANCER
is the URL to the Kubernetes master nodes, it needs to be in the form: http://<value>/S3_BUCKET
is the AWS S3 bucket that stores the Kubernetes user credentialsS3_KEY
is the file name of the.tar.gz
that store the Kubernetes user credentials