Skip to content

Commit

Permalink
Create an optional deployment with a privileged dind container (#345)
Browse files Browse the repository at this point in the history
* Create deployment with docker in docker container

* Update vars description

* Add DCAPT docs section

---------

Co-authored-by: Yevhen Ivantsov <[email protected]>
  • Loading branch information
bianchi2 and Yevhen Ivantsov authored Nov 21, 2023
1 parent ba3b177 commit b33ed3a
Show file tree
Hide file tree
Showing 6 changed files with 224 additions and 1 deletion.
27 changes: 26 additions & 1 deletion config.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,31 @@ max_cluster_capacity = 5
# are passed to Helm chart. Variables from config.tfvars take precedence over those defined in a custom values.yaml.
# monitoring_custom_values_file = "/path/to/values.yaml"

################################################################################
# DCAPT JMeter and Selenium Deployment Settings
################################################################################

# Create deployment with a docker-in-docker privileged container. Defaults to false
# start_test_deployment = false

# Initial CPU request for docker-in-docker container
# test_deployment_cpu_request = "1"

# Initial memory request for docker-in-docker container
# test_deployment_mem_request = "4Gi"

# Initial CPU limit for docker-in-docker container
# test_deployment_cpu_limit = "4"

# Initial memory limit for docker-in-docker container
# test_deployment_mem_limit = "6Gi"

# Image repository of the docker-in-docker container
# test_deployment_image_repo = "docker"

# Image tag of the docker-in-docker container
# test_deployment_image_tag = "24.0.7-dind"

################################################################################
# Jira Settings
################################################################################
Expand Down Expand Up @@ -629,4 +654,4 @@ crowd_db_name = "crowd"
# Crowd license
# To avoid storing license in a plain text file, we recommend storing it in an environment variable prefixed with `TF_VAR_` (i.e. `TF_VAR_crowd_license`) and keep the below line commented out
# If storing license as plain-text is not a concern for this environment, feel free to uncomment the following line and supply the license here
#crowd_license = "<LICENSE_KEY>"
#crowd_license = "<LICENSE_KEY>"
8 changes: 8 additions & 0 deletions dc-infrastructure.tf
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ module "base-infrastructure" {
grafana_pvc_disk_size = var.grafana_pvc_disk_size
monitoring_custom_values_file = var.monitoring_custom_values_file
monitoring_grafana_expose_lb = var.monitoring_grafana_expose_lb

test_deployment_cpu_request = var.test_deployment_cpu_request
test_deployment_mem_request = var.test_deployment_mem_request
test_deployment_cpu_limit = var.test_deployment_cpu_limit
test_deployment_mem_limit = var.test_deployment_mem_limit
test_deployment_image_repo = var.test_deployment_image_repo
test_deployment_image_tag = var.test_deployment_image_tag
start_test_deployment = var.start_test_deployment
}

module "bamboo" {
Expand Down
43 changes: 43 additions & 0 deletions docs/docs/userguide/configuration/DCAPT_CONFIGURATION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# DCAPT Configuration

Besides deploying Atlassian DC products, it is possible to spin up a testing environment to run [Data Center App Performance Toolkit tests](https://github.com/atlassian/dc-app-performance-toolkit/tree/master).

## Create DCAPT Test Deployment

Create an additional deployment for DCAPT Jmeter and Selenium test environment:

```shell
start_test_deployment = true
```

## Configure DCAPT Test Deployment

The default values works well with a typical DCAPT test, however, if you need to allocate more resources to the test container,
use the following variables to override the defaults:

### Configure CPU
```shell
test_deployment_cpu_request = "1"

test_deployment_cpu_limit = "4"
```

### Configure Memory

```shell
test_deployment_mem_request = "4Gi"

test_deployment_mem_limit = "6Gi"

```

### Configure Image and Tag

The container starts in a privileged mode to be able to run docker-in-docker. If you need to change the image repository
or tag, use the following variables:

```shell
test_deployment_image_repo = "docker"

test_deployment_image_tag = "24.0.7-dind"
```
61 changes: 61 additions & 0 deletions modules/common/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,64 @@ resource "kubernetes_namespace" "products" {
name = var.namespace
}
}

resource "kubernetes_deployment" "dcapt_exec" {
count = var.start_test_deployment ? 1 : 0
depends_on = [kubernetes_namespace.products]
metadata {
name = "dcapt"
namespace = var.namespace
labels = {
exec = "true"
}
}
spec {
replicas = 1
selector {
match_labels = {
exec = "true"
}
}
template {
metadata {
labels = {
exec = "true"
}
}
spec {
container {
name = "dcapt"
image = "${var.test_deployment_image_repo}:${var.test_deployment_image_tag}"
security_context { privileged = true }
volume_mount {
mount_path = "/data"
name = "data"
}
resources {
requests = {
cpu = var.test_deployment_cpu_request
memory = var.test_deployment_mem_request
}
limits = {
cpu = var.test_deployment_cpu_limit
memory = var.test_deployment_mem_limit
}
}
lifecycle {
post_start {
exec {
command = ["/bin/sh", "-c", "apk add --update vim bash git"]
}
}
}
}
volume {
name = "data"
empty_dir {}
}
termination_grace_period_seconds = 0
}
}
}
}

42 changes: 42 additions & 0 deletions modules/common/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -175,3 +175,45 @@ variable "monitoring_custom_values_file" {
type = string
default = ""
}

variable "start_test_deployment" {
description = "Deploy necessary resources to start DCAPT testing"
type = bool
default = false
}

variable "test_deployment_cpu_request" {
description = "Number of CPUs for DCAPT Jmeter and Selenium deployment"
type = string
default = "1"
}

variable "test_deployment_mem_request" {
description = "Amount of memory for DCAPT Jmeter and Selenium deployment"
type = string
default = "4Gi"
}

variable "test_deployment_cpu_limit" {
description = "CPU limit for DCAPT Jmeter and Selenium deployment"
type = string
default = "4"
}

variable "test_deployment_mem_limit" {
description = "Memory limit for DCAPT Jmeter and Selenium deployment"
type = string
default = "6Gi"
}

variable "test_deployment_image_repo" {
description = "Image repository of DCAPT Jmeter and Selenium deployment"
type = string
default = "docker"
}

variable "test_deployment_image_tag" {
description = "Image tag of DCAPT Jmeter and Selenium deployment"
type = string
default = "24.0.7-dind"
}
44 changes: 44 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -1367,3 +1367,47 @@ variable "confluence_s3_attachments_storage" {
type = bool
default = false
}

# test deployment configuration

variable "start_test_deployment" {
description = "Deploy necessary resources to start DCAPT testing"
type = bool
default = false
}

variable "test_deployment_cpu_request" {
description = "Number of CPUs for DCAPT Jmeter and Selenium deployment"
type = string
default = "1"
}

variable "test_deployment_mem_request" {
description = "Amount of memory for DCAPT Jmeter and Selenium deployment"
type = string
default = "4Gi"
}

variable "test_deployment_cpu_limit" {
description = "CPU limit for DCAPT Jmeter and Selenium deployment"
type = string
default = "4"
}

variable "test_deployment_mem_limit" {
description = "Memory limit for DCAPT Jmeter and Selenium deployment"
type = string
default = "6Gi"
}

variable "test_deployment_image_repo" {
description = "Image repository of DCAPT Jmeter and Selenium deployment"
type = string
default = "docker"
}

variable "test_deployment_image_tag" {
description = "Image tag of DCAPT Jmeter and Selenium deployment"
type = string
default = "24.0.7-dind"
}

0 comments on commit b33ed3a

Please sign in to comment.