jenkins agent #4
Deploy this charm on Kubernetes with the CLI. Find out how by reading the docs.
Description
Agent for Jenkins, the leading open source automation server. Jenkins provides hundreds of plugins to support building, deploying and automating any project.
Jenkins Agent Operator
A Juju charm deploying and managing Jenkins Agent on Kubernetes, configurable to use a Jenkins charm deployed in another Juju model, or to connect to a standalone Jenkins instance.
Overview
Jenkins is a self-contained, open source automation server which can be used to automate all sorts of tasks related to building, testing, and delivering or deploying software.
For documentation on Jenkins itself, see here.
Usage
For details on using Kubernetes with Juju see here, and for details on using Juju with MicroK8s for easy local testing see here.
The charm supports cross-model relations to connect to a Juju-deployed Jenkins instance in another model. We'll use this to deploy a Jenkins instance and connect our Jenkins Agent to it.
First we're going to bootstrap and deploy Juju on LXC. We'll later add our MicroK8s model to this same controller.
juju bootstrap localhost lxd
juju deploy jenkins --config password=admin
Then go to the jenkins interface by visiting $JENKINS_IP:8080
in a browser,
and logging in with the username admin
and password admin
(as set in
config above). You can configure the plugins you want, and either create an
initial admin user or skip that and continue with the pre-created one.
Now we're going to create our k8s model and generate a cross-model relation offer:
microk8s.config | juju add-k8s micro --controller=lxd
juju add-model jenkins-agent-k8s micro
juju deploy cs:~jenkins-ci-charmers/jenkins-agent
The charm status will be "Blocked" with a message of "Missing required config: jenkins_agent_name jenkins_agent_token jenkins_master_url". This will be fixed by creating and accepting our cross-model relation. We do this from within the k8s model:
juju offer jenkins-agent:slave
# The output will be something like:
# Application "jenkins-agent" endpoints [slave] available at "admin/jenkins-agent-k8s.jenkins-agent"
Switch back to your IaaS model where you deployed jenkins and run:
# Adjust based on the output of your 'juju offer' command above
juju add-relation jenkins <your-controller>:admin/<your-microk8s-model>.jenkins-agent
You can now visit $JENKINS_IP:8080/computer/
in a browser and you'll see the
jenkins agent has been added to your jenkins instance.
Configuration
- image
- (string) The docker image to install. Required. Defaults to jenkins-agent image on dockerhub
- jenkinscicharmers/jenkinsagent:edge
- jenkins_agent_labels
- (string) Comma-separated list of labels to be assigned to the agent in Jenkins. If not set it will default to the agents hardware identifier, e.g.: 'x86_64'
- jenkins_agent_name
- (string) Agent name as configured in Jenkins. Multiple names can be input by using `:` as a separator. Example: "agent-one:agent-two:agent-three"
- jenkins_agent_token
- (string) Agent token provided by Jenkins. Can be found in your Jenkins instance at ${JENKINS_URL}/computer/${AGENT_NAME}/. Multiple tokens can be input by using `:` as a separator matching the order of the agents in `jenkins_agent_name`. Example: "token-one:token-two:token-three"
- jenkins_master_url
- (string) Configure the agent to use an explicit Jenkins master instead of using the jenkins-agent relation. This allows the agent to connect to a Jenkins instance not managed by Juju.