Skip to content
Draft
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
3 changes: 2 additions & 1 deletion server/terraform/charm/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ output "app_name" {
output "endpoints" {
description = "Map of all endpoints"
value = {
nginx_route = "nginx-route"
nginx_route = "nginx-route"
traefik_route = "traefik-route"
}
}
2 changes: 1 addition & 1 deletion server/terraform/charm/variables.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
variable "app_name" {
type = string
default = "api"
default = "hwapi"
description = "Name to give the deployed application"
}

Expand Down
28 changes: 13 additions & 15 deletions server/terraform/product/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,27 +39,25 @@ deployment onto any Kubernetes environment managed by [Juju].
| Name | Type |
| ------------------------------------------------------------- | ----------- |
| [juju_model.hardware_api][juju_model] | data source |
| [juju_application.nginx_ingress_integrator][juju_application] | resource |
| [juju_integration.hardware_api_ingress][juju_integration] | resource |
| [juju_application.traefik_k8s][juju_application] | resource |
| [juju_integration.traefik_k8s-hardware_api][juju_integration] | resource |
| [juju_application.lego][juju_application] | resource |
| [juju_integration.lego-traefik_k8s][juju_integration] | resource |

## Inputs

| Name | Description | Type |
| ------------------------ | --------------------------------------------------------------------------------- | ------ |
| model | Reference to an existing model resource or data source for the model to deploy to | string |
| hardware_api | n/a | object |
| nginx_ingress_integrator | n/a | object |
| Name | Description | Type |
| ------------ | --------------------------------------------------------------------------------- | ------ |
| model | Reference to an existing model resource or data source for the model to deploy to | string |
| hardware_api | n/a | object |
| traefik_k8s | n/a | object |
| lego | n/a | object |

## Outputs

| Name | Description |
| --------------------------------- | --------------------------------------------------------- |
| hardware_api_app_name | Name of the deployed Hardware API application |
| hardware_api_requires | |
| hardware_api_provides | |
| nginx_ingress_integrator_app_name | Name of the deployed NGINX Ingress Integrator application |
| nginx_ingress_integrator_requires | |
| nginx_ingress_integrator_provides | |
| Name | Description |
| ------------ | -------------------------------------- |
| applications | The applications making up the product |

[terraform]: https://terraform.io
[hardware-api-charm]: https://charmhub.io/hardware-api
Expand Down
46 changes: 35 additions & 11 deletions server/terraform/product/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,51 @@ module "hardware_api" {
units = var.hardware_api.units
}

resource "juju_application" "nginx_ingress_integrator" {
name = var.nginx_ingress_integrator.app_name
resource "juju_application" "traefik_k8s" {
name = var.traefik_k8s.app_name
model = data.juju_model.hardware_api.name
trust = true
charm {
name = "nginx-ingress-integrator"
channel = var.nginx_ingress_integrator.channel
revision = var.nginx_ingress_integrator.revision
name = "traefik-k8s"
channel = var.traefik_k8s.channel
revision = var.traefik_k8s.revision
}
units = var.nginx_ingress_integrator.units
config = var.nginx_ingress_integrator.config
units = 1
config = var.traefik_k8s.config
}

resource "juju_integration" "hardware_api_ingress" {
resource "juju_integration" "traefik_k8s-hardware_api" {
model = data.juju_model.hardware_api.name
application {
name = juju_application.traefik_k8s.name
endpoint = "traefik-route"
}
application {
name = module.hardware_api.app_name
endpoint = module.hardware_api.endpoints.nginx_route
endpoint = module.hardware_api.endpoints.traefik_route
}
}

resource "juju_application" "lego" {
name = var.lego.app_name
model = data.juju_model.hardware_api.name
charm {
name = "lego"
channel = var.lego.channel
revision = var.lego.revision
}
units = 1
config = var.lego.config
}

resource "juju_integration" "lego-traefik_k8s" {
model = data.juju_model.hardware_api.name
application {
name = juju_application.lego.name
endpoint = "certificates"
}
application {
name = juju_application.nginx_ingress_integrator.name
endpoint = "nginx-route"
name = juju_application.traefik_k8s.name
endpoint = "certificates"
}
}
30 changes: 4 additions & 26 deletions server/terraform/product/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,29 +1,7 @@
output "hardware_api_app_name" {
description = "The name of the Hardware API application"
value = module.hardware_api.app_name
}

output "hardware_api_requires" {
value = {
nginx_route = "nginx-route"
}
}

output "hardware_api_provides" {
value = {}
}

output "nginx_ingress_integrator_app_name" {
description = "The name of the NGINX Ingress Integrator application"
value = juju_application.nginx_ingress_integrator.name
}

output "nginx_ingress_integrator_requires" {
value = {}
}

output "nginx_ingress_integrator_provides" {
output "applications" {
value = {
nginx_route = "nginx-route"
hardware_api = module.hardware_api
traefik_k8s = juju_application.traefik_k8s
lego = juju_application.lego
}
}
14 changes: 11 additions & 3 deletions server/terraform/product/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ variable "model" {

variable "hardware_api" {
type = object({
app_name = optional(string, "api")
app_name = optional(string, "hwapi")
channel = optional(string, "latest/edge")
config = optional(map(string), {})
constraints = optional(string, "arch=amd64")
Expand All @@ -17,12 +17,20 @@ variable "hardware_api" {
})
}

variable "nginx_ingress_integrator" {
variable "traefik_k8s" {
type = object({
app_name = optional(string, "ingress")
channel = optional(string, "latest/stable")
config = optional(map(string), {})
revision = optional(number)
units = optional(number, 1)
})
}

variable "lego" {
type = object({
app_name = optional(string, "certificates")
channel = optional(string, "latest/stable")
config = optional(map(string), {})
revision = optional(number)
})
}