-
Login to
GoCD server
as admin and navigate to Admin > Elastic Agent Configurations. -
Click on + Elastic Agent Profile to create new elastic agent profile for a cluster.
-
Specify a name for the elastic agent profile.
-
Configure Kubernetes GoCD elastic agent pod configuration using one of three ways below:
-
Option 1: Config Properties
- Specify GoCD elastic agent docker image name.
- Specify Maximum Memory limit. Container memory will be limited to the value specified here.
- Specify Maximum CPU limit. Container memory will be limited to the value specified here.
- Optionally specify Environment Variables. These variables are passed to the container for use.
-
Option 2: Pod Configuration
- Specify GoCD elastic agent Pod Yaml configuration. Don't forget to use
{{ POD_POSTFIX }}
and{{ CONTAINER_POSTFIX }}
placeholders, so that pod and container names are unique.
- Specify GoCD elastic agent Pod Yaml configuration. Don't forget to use
-
Option 3: Remote File
- Load the pod configuration from a remote file location and choose the type (
json
oryaml
).
- Load the pod configuration from a remote file location and choose the type (
-
-
Save your profile.
-
For accessing repositories over SSH, you need to add SSH keys to the elastic agent pod spec. Generate a new keypair, fetch the host key for the [host] you want to connect to and create the secret. The secret is structured to hold the entire contents of the .ssh folder on the GoCD agent.
Note: The steps provided below are for the official GoCD agent images listed on DockerHub.
$ ssh-keygen -t rsa -b 4096 -C "user@example.com" -f gocd-agent-ssh -P ''
$ ssh-keyscan [host] > gocd_known_hosts
$ kubectl create secret generic gocd-agent-ssh \
--from-file=id_rsa=gocd-agent-ssh \
--from-file=id_rsa.pub=gocd-agent-ssh.pub \
--from-file=known_hosts=gocd_known_hosts
Be sure to add the contents of gocd-agent-ssh.pub
to your [host].
In the pod spec, specify the volumes
section if not present and include the contents specified below:
volumes:
- name: ssh-secrets
secret:
defaultMode: 420
secretName: gocd-agent-ssh
In the container spec, specify the volumeMounts
section if not present and include the contents specified below:
volumeMounts:
- name: ssh-secrets
readOnly: true
mountPath: /home/go/.ssh
To pull images from a private registry, you usually need some secrets set up.
kubectl create secret docker-registry \
my-docker-registry \
--namespace gocd \
--docker-server=<docker_server_url> \
--docker-username=<username> \
--docker-password=<password> \
--docker-email=<email>
In the pod spec, specify the imagePullSecrets
section:
imagePullSecrets:
- name: my-docker-registry