Skip to content

Commit

Permalink
Make module not sks-specific (#3)
Browse files Browse the repository at this point in the history
Turns out we'll need to use the module as a generic one after all, so it won't have the auto-injected locals and variables. Now it's a completely generic and re-usable module outside of our sks-specific setup.

Which also means that we can go back to an open source license and make the repo public
  • Loading branch information
iuriaranda authored Sep 6, 2023
1 parent f997d93 commit 27790ea
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 26 deletions.
24 changes: 19 additions & 5 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
LICENSE
MIT License

Unless superseded by a signed license agreement between you and ILIBRIS BV
("Skyscrapers"), the copyright of this software and associated documentation
files (the "Software") is held by Skyscrapers with all rights reserved.
Copyright (c) 2023 Skyscrapers

https://skyscrapers.eu
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
37 changes: 21 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ This module sets up a set of Bitbucket runners on a Kubernetes cluster. It accep

## Requirements

| Name | Version |
| ---------------------------------------------------------------------------- | ------- |
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | ~> 1.0 |
| <a name="requirement_kubernetes"></a> [kubernetes](#requirement\_kubernetes) | ~> 2.13 |
| Name | Version |
| ---------------------------------------------------------------------------- | --------------- |
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0, < 1.6.0 |
| <a name="requirement_kubernetes"></a> [kubernetes](#requirement\_kubernetes) | ~> 2.13 |

## Providers

Expand All @@ -23,21 +23,26 @@ No modules.

## Resources

| Name | Type |
| ------------------------------------------------------------------------------------------------------------------------------------------- | -------- |
| [kubernetes_service.bitbucket_runner](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/service) | resource |
| [kubernetes_stateful_set.bitbucket_runner](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/stateful_set) | resource |
| Name | Type |
| ------------------------------------------------------------------------------------------------------------------------------------------------- | -------- |
| [kubernetes_service.bitbucket_runner](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/service) | resource |
| [kubernetes_service_account.bitbucket_runner](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/service_account) | resource |
| [kubernetes_stateful_set.bitbucket_runner](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/stateful_set) | resource |

## Inputs

| Name | Description | Type | Default | Required |
| ----------------------------------------------------------------------------------------- | --------------------------------------------------- | ------------------------------------------------------------------------------------------------------ | ------- | :------: |
| <a name="input_bitbucket_runners"></a> [bitbucket\_runners](#input\_bitbucket\_runners) | Map of Bitbucket runner definitions | `map(any)` | n/a | yes |
| <a name="input_environment"></a> [environment](#input\_environment) | n/a | `string` | n/a | yes |
| <a name="input_k8s_namespace"></a> [k8s\_namespace](#input\_k8s\_namespace) | Kubernetes namespace where to deploy the runners to | `string` | n/a | yes |
| <a name="input_k8s_node_selector"></a> [k8s\_node\_selector](#input\_k8s\_node\_selector) | Node selector to apply to the runner StatefulSets | `map(string)` | `null` | no |
| <a name="input_k8s_tolerations"></a> [k8s\_tolerations](#input\_k8s\_tolerations) | Tolerations to apply to the runner StatefulSets | <pre>list(object({<br> effect = string<br> key = string<br> value = string<br> }))</pre> | `[]` | no |
| Name | Description | Type | Default | Required |
| ------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- | :------: |
| <a name="input_bitbucket_runners"></a> [bitbucket\_runners](#input\_bitbucket\_runners) | Map of Bitbucket runner definitions | <pre>map(object({<br> resources = optional(object({<br> limits = optional(object({<br> cpu = optional(string)<br> memory = optional(string)<br> }))<br> requests = optional(object({<br> cpu = optional(string)<br> memory = optional(string)<br> }))<br> }))<br> }))</pre> | n/a | yes |
| <a name="input_k8s_namespace"></a> [k8s\_namespace](#input\_k8s\_namespace) | Kubernetes namespace where to deploy the runners to | `string` | n/a | yes |
| <a name="input_k8s_labels"></a> [k8s\_labels](#input\_k8s\_labels) | Labels to apply to all Kubernetes objects | `map(string)` | `{}` | no |
| <a name="input_k8s_node_selector"></a> [k8s\_node\_selector](#input\_k8s\_node\_selector) | Node selector to apply to the runner StatefulSets | `map(string)` | `null` | no |
| <a name="input_k8s_service_account_annotations"></a> [k8s\_service\_account\_annotations](#input\_k8s\_service\_account\_annotations) | Annotations to attach to the ServiceAccount | `map(string)` | `{}` | no |
| <a name="input_k8s_tolerations"></a> [k8s\_tolerations](#input\_k8s\_tolerations) | Tolerations to apply to the runner StatefulSets | <pre>list(object({<br> effect = string<br> key = string<br> value = string<br> }))</pre> | `[]` | no |
| <a name="input_pod_default_resources"></a> [pod\_default\_resources](#input\_pod\_default\_resources) | Default resources that will be applied to all runner Pods, unless overriden in the runner definition | <pre>object({<br> limits = optional(object({<br> cpu = optional(string)<br> memory = optional(string)<br> }))<br> requests = optional(object({<br> cpu = optional(string)<br> memory = optional(string)<br> }))<br> })</pre> | <pre>{<br> "limits": {<br> "cpu": null,<br> "memory": "4G"<br> },<br> "requests": {<br> "cpu": 1,<br> "memory": "1G"<br> }<br>}</pre> | no |

## Outputs

No outputs.
| Name | Description |
| --------------------------------------------------------------------------------------------------------------------------------------- | ----------- |
| <a name="output_kubernetes_service_account_name"></a> [kubernetes\_service\_account\_name](#output\_kubernetes\_service\_account\_name) | n/a |
2 changes: 1 addition & 1 deletion service.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ resource "kubernetes_service" "bitbucket_runner" {
name = "bitbucket-${each.key}"
namespace = var.k8s_namespace

labels = merge(local.k8s_default_labels, {
labels = merge(var.k8s_labels, {
"app.kubernetes.io/name" = "bitbucket-runner"
"app.kubernetes.io/instance" = each.key
})
Expand Down
2 changes: 1 addition & 1 deletion serviceaccount.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ resource "kubernetes_service_account" "bitbucket_runner" {
name = "bitbucket-runner"
namespace = var.k8s_namespace

labels = merge(local.k8s_default_labels, {
labels = merge(var.k8s_labels, {
"app.kubernetes.io/name" = "bitbucket-runner"
})

Expand Down
2 changes: 1 addition & 1 deletion statefulset.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ resource "kubernetes_stateful_set" "bitbucket_runner" {
name = "bitbucket-${each.key}"
namespace = var.k8s_namespace

labels = merge(local.k8s_default_labels, {
labels = merge(var.k8s_labels, {
"app.kubernetes.io/name" = "bitbucket-runner"
"app.kubernetes.io/instance" = each.key
})
Expand Down
6 changes: 4 additions & 2 deletions variables.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
variable "environment" {
type = string
variable "k8s_labels" {
type = map(string)
description = "Labels to apply to all Kubernetes objects"
default = {}
}

variable "bitbucket_runners" {
Expand Down

0 comments on commit 27790ea

Please sign in to comment.