-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #493 from gatici/Deploy-applications-with-custom-r…
…esources #493 ## Description This PR provides to use custom (OCI image) charm resources with applications. The application resource could be a charm revision or a custom OCI image which needs to be pulled from a repository. The following "juju_application" resource definition becomes valid within this PR. This PR both works with all the Juju versions which are supported by Juju Terraform provider. (Tested with Juju 2.9.x and 3.4.x versions) ``` resource "juju_application" "ausf" { name = "ausf" model = var.model_name charm { name = "sdcore-ausf-k8s" channel = var.channel } resources = { ausf-image = "gatici/sdcore-ausf:1.4.0" // ausf-image = "2" } units = 1 trust = true } ``` Design Spec: https://docs.google.com/document/d/1i236ntmw-qXyqifmEtk_rcszWXcXSUhXkeJ6ByKXIeE/edit Fixes: #460 ## Type of change - Change existing resource - Change in the tests (one or several tests have been changed) - Requires a documentation update ## Environment The following steps are performed to prepare the environment. Install Microk8s: ``` sudo snap install microk8s --channel=1.29-strict/stable sudo usermod -a -G snap_microk8s jenkins newgrp snap_microk8s sudo microk8s enable hostpath-storage ``` Install Juju: ``` sudo snap install juju --channel=3.4/stable juju bootstrap microk8s ``` Install Terraform: ``` sudo snap install --classic terraform ``` Create `terraformrc` file with following contents. Write the path of `terraform.d/plugins` directory if it is in a different path. ``` touch .terraformrc ``` ``` provider_installation { filesystem_mirror { path = "~/.terraform.d/plugins" include = ["juju/juju"] } direct { exclude = ["juju/juju"] } } ``` ## QA steps Manual QA steps should be done to test this PR. Create a folder to store the Terraform files for testing. mkdir testing cd testing Create a `main.tf` file with following contents: ``` resource "juju_application" "ausf" { name = "ausf" model = var.model_name charm { name = "sdcore-ausf-k8s" channel = var.channel } resources = { ausf-image = "gatici/sdcore-ausf:1.4.0" } units = 1 trust = true } ``` Create a `terraform.tf ` file with following contents: ``` terraform { required_providers { juju = { source = "juju/juju" version = "0.12.0" } } } ``` Create a `terraform.tfvars ` file with following contents: ``` model_name ="test40" ``` Create a `variables.tf ` file with following contents: ``` 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.4/edge" } variable "db_application_name" { description = "The name of the application providing the `database` endpoint." type = string default = "mongodb-k8s" } variable "certs_application_name" { description = "Name of the application providing the `certificates` integration endpoint." type = string default = "self-signed-certificates" } variable "nrf_application_name" { description = "The name of the application providing the `fiveg_nrf` endpoint." type = string default = "nrf" } ``` Fetch the PR and run following commads to install it. ``` make go-install make install ``` Create a juju model: ``` juju add-model test40 ``` Initialise the provider: ``` terraform init ``` Run Terraform plan by providing a var-file: ``` terraform plan -var-file="terraform.tfvars" ``` Deploy the application: ``` terraform apply -auto-approve ``` Check the pod to see the attached image. ``` microk8s.kubectl describe pod ausf-0 -n test40 ``` ## Additional notes Test with changing the resources part with different image versions. Using a revision as string: ``` resources = { ausf-image = "30" } ```
- Loading branch information
Showing
12 changed files
with
951 additions
and
113 deletions.
There are no files selected for viewing
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
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
Oops, something went wrong.