Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create an optional deployment with a privileged dind container #345

Merged
merged 3 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion config.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,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 = true
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought we were setting the commented values to the defaults.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Fixed


# 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 @@ -614,4 +639,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
2 changes: 1 addition & 1 deletion modules/AWS/eks/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ variable "osquery_fleet_enrollment_host" {

variable "kinesis_log_producers_role_arns" {
description = "AWS kinesis log producer role"
type = object({
type = object({
eu = string
non-eu = string
})
Expand Down
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 = "Whether to start DCAPT Jmeter and Selenium deployment"
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 @@ -1317,3 +1317,47 @@ variable "confluence_s3_attachments_storage" {
type = bool
default = false
}

# test deployment configuration

variable "start_test_deployment" {
description = "Whether to start DCAPT Jmeter and Selenium deployment"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we say something like "Deploy necessary resources to start DCAPT testing"? So it is potentially flexible in future.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, sounds good.

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"
}
Loading