Skip to content

Commit

Permalink
Add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Thanhphan1147 committed Jan 8, 2024
1 parent 43ae9cf commit 750de21
Show file tree
Hide file tree
Showing 6 changed files with 175 additions and 0 deletions.
10 changes: 10 additions & 0 deletions docs/how-to/configure-agent-node-label.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# How to configure installable plugins

### Configure `jenkins_agent_labels`

Use the `jenkins_agent_labels` configuration to allow assigning different labels to the agent's node on the jenkins server.
Comma-separated list of node labels. If empty, the agent's node will have the underlying machine's arch as a label by default, most of the time this will be `x86_64`. If this value is configured before any integrations with the jenkins charm is established, the label will be applied during the node's creation once an integration has been established.

```
juju config jenkins-agent jenkins_agent_labels=label1,label2,label3
```
32 changes: 32 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Jenkins-k8s Operator

A [Juju](https://juju.is/) [charm](https://juju.is/docs/olm/charmed-operators) deploying and managing [Jenkins](https://www.jenkins.io/) Agent on machines and configurable to use a Jenkins charm deployed in another Juju model.

This charm simplifies initial deployment and "day N" operations of Jenkins Agent on VMs and bare metal.

As such, the charm makes it easy for those looking to take control of their own agents whilst keeping operations simple, and gives them the freedom to deploy on the platform of their choice.

For DevOps or SRE teams this charm will make operating Jenkins Agent simple and straightforward through Juju's clean interface. It will allow easy deployment into multiple environments for testing changes, and supports scaling out for enterprise deployments.

## Project and community

The Jenkins-agent Operator is a member of the Ubuntu family. It's an open source project that warmly welcomes community projects, contributions, suggestions, fixes and constructive feedback.

- [Code of conduct](https://ubuntu.com/community/code-of-conduct)
- [Get support](https://discourse.charmhub.io/)
- [Join our online chat](https://chat.charmhub.io/charmhub/channels/charm-dev)
- [Contribute](Contribute)

Thinking about using the Jenkins-k8s Operator for your next project? [Get in touch](https://chat.charmhub.io/charmhub/channels/charm-dev)!

# Contents

1. [Tutorial](tutorial)
1. [Getting Started](tutorial/getting-started.md)
1. [How to](how-to)
1. [Configure agent node label](how-to/configure-agent-node-label.md)
1. [Reference](reference)
1. [Actions](reference/actions.md)
1. [Configurations](reference/configurations.md)
1. [Integrations](reference/integrations.md)
1. [Explanation](explanation)
3 changes: 3 additions & 0 deletions docs/reference/actions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Actions

See [Actions](https://charmhub.io/jenkins-agent/actions).
3 changes: 3 additions & 0 deletions docs/reference/configurations.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Configurations

See [Configure](https://charmhub.io/jenkins-agent/configure).
27 changes: 27 additions & 0 deletions docs/reference/integrations.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Integrations

### agent

_Interface_: jenkins_agent_v0
_Supported charms_: [jenkins-agent-k8s](https://charmhub.io/jenkins-agent-k8s),
[jenkins-agent](https://charmhub.io/jenkins-agent)

Jenkins agents provide a way to perform tasks scheduled by the Jenkins server. Jenkins agents are
used to distribute workload across multiple containers, allowing parallel execution of jobs.

Example agent relate command: `juju relate jenkins-k8s:agent jenkins-agent-k8s:agent`

To create a [cross model relation](https://juju.is/docs/olm/manage-cross-model-integrations) with
a jenkins-agent (VM) charm, create an offer from the machine model.

`juju offer jenkins-agent:agent`

Then, relate the offer from the k8s model where jenkins-k8s charm resides.

`juju relate jenkins-k8s:agent <controller-name>:<juju-user>/<agent-model>.jenkins-agent`

An example of such command would look like the following, using a jenkins-agent deployed on a
localhost
[lxd controller](https://juju.is/docs/olm/get-started-with-juju#heading--prepare-your-cloud).

`juju relate jenkins-k8s:agent localhost:admin/jenkins-vm-model.jenkins-agent`
100 changes: 100 additions & 0 deletions docs/tutorial/getting-started.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# Getting Started

## What you'll do

- Deploy the [jenkins-agent charm](https://charmhub.io/jenkins-agent)
- Deploy the [jenkins-k8s charm](https://charmhub.io/jenkins-k8s) and integrate with it via a cross-model integration

The `jenkins-agent` charm helps deploy a Jenkins agent with ease and also helps operate the charm. This
tutorial will walk you through each step of deployment to get a basic Jenkins agent deployment and integrate it with Jenkins.

### Prerequisites

To deploy the `jenkins-agent` charm, you'll need to have a bootstrapped machine model. Learn about
bootstrapping different clouds [here](https://juju.is/docs/olm/get-started-with-juju#heading--prepare-your-cloud).

Use `juju bootstrap localhost localhost` to bootstrap a `lxd` machine controller with the name
`localhost` for tutorial purposes.

### Setting up the tutorial model

To easily clean up the resources and to separate your workload from the contents of this tutorial,
it is recommended to set up a new model with the following command.

```
juju add-model tutorial
```

### Deploy the jenkins-agent charm

Start off by deploying the jenkins-agent charm. By default it will deploy the latest stable release
of the jenkins-agent charm.

```
# Deploy an edge version of the charm until stable version is released.
juju deploy jenkins-agent
```

### Deploy and integrate with the jenkins-k8s charm

To deploy jenkins-k8s charm, you will need a juju bootstrapped with any kubernetes controller.
To see how to bootstrap your juju installation with microk8s, please refer to the documentation
on microk8s [installation](https://juju.is/docs/olm/microk8s).

Use `juju bootstrap microk8s localhost-microk8s` to bootstrap a `microk8s` machine controller with the name
`localhost-microk8s` for tutorial purposes.

Then, switch to your kubernetes controller add a model for the jenkins-k8s charm with the following command:
```
juju switch -c localhost-microk8s
juju add-model jenkins-tutorial
```

Continue by deploying the jenkins-k8s charm. by default it will deploy the latest stable release of the jenkins-k8s charm:
```
juju deploy jenkins-k8s --channel=latest/edge
```

The Jenkins application can only have a single server unit. Adding more units through --num-units parameter will cause the application to misbehave.

#### Create an offer for Cross Model Relation

To integrate charms
[across different models](https://juju.is/docs/juju/manage-cross-model-integrations), a juju
[`offer`](https://juju.is/docs/juju/manage-cross-model-integrations#heading--create-an-offer) is
required.

Create an offer of the `jenkins-k8s` charm's `agent` relation.

```
juju offer jenkins-k8s:agent
```

The output should look similar to the contents below:

```
Application "jenkins-k8s" endpoints [agent] available at "admin/jenkins-tutorial.jenkins-k8s"
```

#### Integrate the Jenkins agent charm through the offer

Switch back to the k8s model where the `jenkins-agent` charm is deployed. An example of the switch
command looks like the following: `juju switch localhost:tutorial`.

Integrate the `jenkins-agent` charm to the `jenkins-k8s` server charm through the offer.
The syntax of the offer is as follows: `<controller>:<user>/<model>.<charm>`.

```
juju integrate jenkins-agent:agent localhost-microk8s:admin/jenkins-tutorial.jenkins-agent
```


### Cleaning up the environment

Congratulations! You have successfully finished the tutorial. You can now remove the
models that you’ve created using the following command.

```
juju destroy model localhost-microk8s:admin/jenkins-tutorial -y --release-storage
juju destroy model localhost:admin/tutorial -y --release-storage
```

0 comments on commit 750de21

Please sign in to comment.