Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 6 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,18 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Install terraform
run: |
sudo snap install terraform --classic
- name: Install tox & poetry
run: |
pipx install tox
pipx install poetry
- name: Run linters
working-directory: ${{ matrix.path }}
run: tox run -e lint
run: |
tox run -e lint
tox run -e lint-terraform

unit-test:
strategy:
Expand Down
3 changes: 3 additions & 0 deletions kubernetes/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ build/
.coverage
__pycache__/
*.py[cod]

.terraform
.terraform.lock.hcl
15 changes: 15 additions & 0 deletions kubernetes/terraform/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
resource "juju_application" "mysql_router" {
name = var.app_name
model = var.model_name

charm {
name = "mysql-router-k8s"
base = var.base
channel = var.channel
revision = var.revision
}

config = var.config
constraints = var.constraints
units = var.units
}
23 changes: 23 additions & 0 deletions kubernetes/terraform/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
output "app_name" {
description = "Name of the MySQL Router K8s application"
value = juju_application.mysql_router.name
}

output "provides" {
description = "Map of all the provided endpoints"
value = {
database = "database"
grafana_dashboard = "grafana-dashboard"
metrics_endpoint = "metrics-endpoint"
}
}

output "requires" {
description = "Map of all the required endpoints"
value = {
backend_database = "backend-database"
certificates = "certificates"
logging = "logging"
tracing = "tracing"
}
}
46 changes: 46 additions & 0 deletions kubernetes/terraform/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
variable "model_name" {
description = "Name of the juju model to deploy to"
type = string
}

variable "app_name" {
description = "Name of the juju application"
type = string
default = "mysql-router-k8s"
}

variable "base" {
description = "Application base"
type = string
default = "ubuntu@22.04"
}

variable "config" {
description = "Application configuration. Details at https://charmhub.io/mysql-router-k8s/configurations"
type = map(string)
default = {}
}

variable "constraints" {
description = "Juju constraints for the application"
type = string
default = "arch=amd64"
}

variable "channel" {
description = "Charm channel to deploy from"
type = string
default = "8.0/stable"
}

variable "revision" {
description = "Charm revision to deploy"
type = number
default = null
}

variable "units" {
description = "Number of units to deploy"
type = number
default = 1
}
10 changes: 10 additions & 0 deletions kubernetes/terraform/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
terraform {
required_version = ">= 1.6.6"

required_providers {
juju = {
source = "juju/juju"
version = ">= 0.20.0, < 1.0.0"
}
}
}
9 changes: 9 additions & 0 deletions kubernetes/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ env_list = lint, unit
src_path = "{tox_root}/src"
tests_path = "{tox_root}/tests"
scripts_path = "{tox_root}/scripts"
terraform_path = "{tox_root}/terraform"
all_path = {[vars]src_path} {[vars]tests_path} {[vars]scripts_path}

[testenv]
Expand All @@ -17,6 +18,7 @@ set_env =
PY_COLORS = 1
allowlist_externals =
poetry
terraform

[testenv:format]
description = Apply coding style standards to code
Expand All @@ -37,6 +39,13 @@ commands =
poetry run ruff check {[vars]all_path}
poetry run ruff format --check --diff {[vars]all_path}

[testenv:lint-terraform]
description = Check code against Terraform style standards
commands =
terraform fmt -check -diff -recursive {[vars]terraform_path}
terraform -chdir={[vars]terraform_path} init -backend=false
terraform -chdir={[vars]terraform_path} validate

[testenv:unit]
description = Run unit tests
commands_pre =
Expand Down
3 changes: 3 additions & 0 deletions machines/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ build/
coverage.xml
__pycache__/
*.py[cod]

.terraform
.terraform.lock.hcl
15 changes: 15 additions & 0 deletions machines/terraform/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
resource "juju_application" "mysql_router" {
name = var.app_name
model = var.model_name

charm {
name = "mysql-router"
base = var.base
channel = var.channel
revision = var.revision
}

config = var.config
constraints = var.constraints
units = var.units
}
21 changes: 21 additions & 0 deletions machines/terraform/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
output "app_name" {
description = "Name of the MySQL Router VM application"
value = juju_application.mysql_router.name
}

output "provides" {
description = "Map of all the provided endpoints"
value = {
database = "database"
cos_agent = "cos-agent"
}
}

output "requires" {
description = "Map of all the required endpoints"
value = {
backend_database = "backend-database"
certificates = "certificates"
tracing = "tracing"
}
}
46 changes: 46 additions & 0 deletions machines/terraform/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
variable "model_name" {
description = "Name of the juju model to deploy to"
type = string
}

variable "app_name" {
description = "Name of the juju application"
type = string
default = "mysql-router"
}

variable "base" {
description = "Application base"
type = string
default = "ubuntu@22.04"
}

variable "config" {
description = "Application configuration. Details at https://charmhub.io/mysql-router/configurations"
type = map(string)
default = {}
}

variable "constraints" {
description = "Juju constraints for the application"
type = string
default = "arch=amd64"
}

variable "channel" {
description = "Charm channel to deploy from"
type = string
default = "dpe/candidate"
}

variable "revision" {
description = "Charm revision to deploy"
type = number
default = null
}

variable "units" {
description = "Number of units to deploy"
type = number
default = 1
}
10 changes: 10 additions & 0 deletions machines/terraform/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
terraform {
required_version = ">= 1.6.6"

required_providers {
juju = {
source = "juju/juju"
version = ">= 0.20.0, < 1.0.0"
}
}
}
9 changes: 9 additions & 0 deletions machines/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ env_list = lint, unit
[vars]
src_path = "{tox_root}/src"
tests_path = "{tox_root}/tests"
terraform_path = "{tox_root}/terraform"
all_path = {[vars]src_path} {[vars]tests_path}

[testenv]
Expand All @@ -16,6 +17,7 @@ set_env =
PY_COLORS = 1
allowlist_externals =
poetry
terraform

[testenv:format]
description = Apply coding style standards to code
Expand All @@ -36,6 +38,13 @@ commands =
poetry run ruff check {[vars]all_path}
poetry run ruff format --check --diff {[vars]all_path}

[testenv:lint-terraform]
description = Check code against Terraform style standards
commands =
terraform fmt -check -diff -recursive {[vars]terraform_path}
terraform -chdir={[vars]terraform_path} init -backend=false
terraform -chdir={[vars]terraform_path} validate

[testenv:unit]
description = Run unit tests
commands_pre =
Expand Down