-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Updating Terraform module (#57)
- Loading branch information
Showing
6 changed files
with
76 additions
and
217 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,73 +1,55 @@ | ||
# SD-Core PCF K8s Terraform Module | ||
# SD-Core PCF K8s Terraform module | ||
|
||
This SD-Core PCF K8s Terraform module aims to deploy the [sdcore-pcf-k8s charm](https://charmhub.io/sdcore-pcf-k8s) via Terraform. | ||
This folder contains a base [Terraform][Terraform] module for the sdcore-pcf-k8s charm. | ||
|
||
## Getting Started | ||
The module uses the [Terraform Juju provider][Terraform Juju provider] to model the charm | ||
deployment onto any Kubernetes environment managed by [Juju][Juju]. | ||
|
||
### Prerequisites | ||
The base module is not intended to be deployed in separation (it is possible though), but should | ||
rather serve as a building block for higher level modules. | ||
|
||
The following software and tools needs to be installed and should be running in the local environment. | ||
## Module structure | ||
|
||
- `microk8s` | ||
- `juju 3.x` | ||
- `terrafom` | ||
- **main.tf** - Defines the Juju application to be deployed. | ||
- **variables.tf** - Allows customization of the deployment. Except for exposing the deployment | ||
options (Juju model name, channel or application name) also models the charm configuration. | ||
- **output.tf** - Responsible for integrating the module with other Terraform modules, primarily | ||
by defining potential integration endpoints (charm integrations), but also by exposing | ||
the application name. | ||
- **terraform.tf** - Defines the Terraform provider. | ||
|
||
### Deploy the sdcore-pcf-k8s charm using Terraform | ||
## Using sdcore-pcf-k8s base module in higher level modules | ||
|
||
Make sure that `storage` plugin is enabled for Microk8s: | ||
If you want to use `sdcore-pcf-k8s` base module as part of your Terraform module, import it | ||
like shown below: | ||
|
||
```console | ||
sudo microk8s enable hostpath-storage | ||
```text | ||
module "pcf" { | ||
source = "git::https://github.com/canonical/sdcore-pcf-k8s-operator//terraform" | ||
model_name = "juju_model_name" | ||
} | ||
``` | ||
|
||
Add a Juju model: | ||
Create integrations, for instance: | ||
|
||
```console | ||
juju add model <model-name> | ||
```text | ||
resource "juju_integration" "pcf-nrf" { | ||
model = var.model_name | ||
application { | ||
name = module.pcf.app_name | ||
endpoint = module.pcf.fiveg_nrf_endpoint | ||
} | ||
application { | ||
name = module.nrf.app_name | ||
endpoint = module.nrf.fiveg_nrf_endpoint | ||
} | ||
} | ||
``` | ||
|
||
Initialise the provider: | ||
The complete list of available integrations can be found [here][pcf-integrations]. | ||
|
||
```console | ||
terraform init | ||
``` | ||
|
||
Customize the configuration inputs under `terraform.tfvars` file according to requirement. | ||
|
||
Replace the values in the `terraform.tfvars` file: | ||
|
||
```yaml | ||
# Mandatory Config Options | ||
model_name = "put your model-name here" | ||
db_application_name = "put your MongoDB app name here" | ||
certs_application_name = "put your Self Signed Certificates app name here" | ||
nrf_application_name = "put your NRF app name here" | ||
``` | ||
|
||
Create the Terraform Plan: | ||
|
||
```console | ||
terraform plan -var-file="terraform.tfvars" | ||
``` | ||
|
||
Deploy the resources: | ||
|
||
```console | ||
terraform apply -auto-approve | ||
``` | ||
|
||
### Check the Output | ||
|
||
Run `juju switch <juju model>` to switch to the target Juju model and observe the status of the applications. | ||
|
||
```console | ||
juju status --relations | ||
``` | ||
|
||
### Clean up | ||
|
||
Destroy the deployment: | ||
|
||
```console | ||
terraform destroy -auto-approve | ||
``` | ||
[Terraform]: https://www.terraform.io/ | ||
[Terraform Juju provider]: https://registry.terraform.io/providers/juju/juju/latest | ||
[Juju]: https://juju.is | ||
[pcf-integrations]: https://charmhub.io/sdcore-pcf-k8s/integrations |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,24 @@ | ||
output "pcf_application_name" { | ||
# Copyright 2024 Canonical Ltd. | ||
# See LICENSE file for licensing details. | ||
|
||
output "app_name" { | ||
description = "Name of the deployed application." | ||
value = juju_application.pcf.name | ||
} | ||
} | ||
|
||
# Required integration endpoints | ||
|
||
output "fiveg_nrf_endpoint" { | ||
description = "Name of the endpoint used to integrate with the NRF." | ||
value = "fiveg-nrf" | ||
} | ||
|
||
output "database_endpoint" { | ||
description = "Name of the endpoint used to integrate with the database." | ||
value = "database" | ||
} | ||
|
||
output "certificates_endpoint" { | ||
description = "Name of the endpoint used to integrate with the TLS certificates provider." | ||
value = "certificates" | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,20 @@ | ||
# Copyright 2024 Canonical Ltd. | ||
# See LICENSE file for licensing details. | ||
|
||
variable "model_name" { | ||
description = "Name of Juju model to deploy application to." | ||
type = string | ||
default = "" | ||
} | ||
|
||
variable "channel" { | ||
description = "The channel to use when deploying a charm." | ||
type = string | ||
default = "1.3/edge" | ||
} | ||
|
||
variable "db_application_name" { | ||
description = "The name of the application providing the `database` endpoint." | ||
variable "app_name" { | ||
description = "Name of the application in the Juju model." | ||
type = string | ||
default = "" | ||
default = "pcf" | ||
} | ||
|
||
variable "certs_application_name" { | ||
description = "Name of the application providing the `certificates` integration endpoint." | ||
variable "channel" { | ||
description = "The channel to use when deploying a charm." | ||
type = string | ||
default = "" | ||
default = "1.3/edge" | ||
} | ||
|
||
variable "nrf_application_name" { | ||
description = "The name of the application providing the `fiveg_nrf` endpoint." | ||
type = string | ||
default = "" | ||
} |