|
| 1 | +# Module openshift-route |
| 2 | + |
| 3 | +This module is used to provision a route to an openshift cluster. An [OpenShift route](https://docs.openshift.com/enterprise/3.0/architecture/core_concepts/routes.html) is a way to expose a service by giving it an externally-reachable hostname like www.example.com. |
| 4 | + |
| 5 | + |
| 6 | +## Example Usage |
| 7 | + |
| 8 | +``` terraform |
| 9 | +provider "ibm" { |
| 10 | +} |
| 11 | +
|
| 12 | +locals { |
| 13 | + # get json |
| 14 | + data = jsondecode(var.route_data) |
| 15 | +} |
| 16 | +
|
| 17 | +data "ibm_satellite_cluster" "cluster" { |
| 18 | + name = var.cluster |
| 19 | +} |
| 20 | +
|
| 21 | +module "openshift_cluster_route" { |
| 22 | + source = "github.com/terraform-ibm-modules/terraform-ibm-cluster//modules/openshift-route" |
| 23 | +
|
| 24 | + ibmcloud_api_key = var.ibmcloud_api_key |
| 25 | + cluster_service_url = data.ibm_satellite_cluster.cluster.server_url |
| 26 | + namespace = var.namespace |
| 27 | + route_data = var.route_data |
| 28 | +} |
| 29 | +``` |
| 30 | + |
| 31 | +## Note |
| 32 | + |
| 33 | +* To update a openshift route, users has to get the "resourceVersion" parameter value from terraform.tfstate or openshift console file, And add it to 'route_data' variable as a route specification. |
| 34 | + |
| 35 | +``` Route Specfication |
| 36 | +{ |
| 37 | + "kind":"Route", |
| 38 | + "apiVersion":"route.openshift.io/v1", |
| 39 | + "metadata":{ |
| 40 | + "name":"route-01", |
| 41 | + "resourceVersion": "<resourceVersion>" |
| 42 | + }, |
| 43 | + ..... |
| 44 | + ..... |
| 45 | +} |
| 46 | +``` |
| 47 | +* All optional fields are given value `null` in varaible.tf file. User can configure the same by overwriting with appropriate values. |
| 48 | +* Provide `version` attribute in terraform block in versions.tf file to use specific version of terraform provider. |
| 49 | + |
| 50 | + |
| 51 | +<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK --> |
| 52 | +## Inputs |
| 53 | + |
| 54 | +| Name | Description | Type |Default |Required | |
| 55 | +|--------------------------|----------------------------------------------------------------|:-------|:--------|:--------| |
| 56 | +| ibmcloud_api_key | IBM Cloud IAM API key |`string`| n/a | yes | |
| 57 | +| cluster | Cluster Name |`string`| n/a | yes | |
| 58 | +| namespace | Openshift namespace name |`string`| default | no | |
| 59 | +| route_data | Route specification |`string`| n/a | no | |
| 60 | + |
| 61 | +## Outputs |
| 62 | + |
| 63 | +| Name | Description | |
| 64 | +|--------------------------|----------------------------| |
| 65 | +| route_response | Route response | |
| 66 | + |
| 67 | +<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK --> |
| 68 | + |
| 69 | +## Usage |
| 70 | + |
| 71 | +Initialising Provider |
| 72 | + |
| 73 | +Make sure you declare a required providers ibm block to make use of IBM-Cloud Terraform Provider |
| 74 | + |
| 75 | +```terraform |
| 76 | +terraform { |
| 77 | + required_providers { |
| 78 | + restapi = { |
| 79 | + source = "fmontezuma/restapi" |
| 80 | + version = "1.14.1" |
| 81 | + } |
| 82 | + ibm = { |
| 83 | + source = "IBM-Cloud/ibm" |
| 84 | + } |
| 85 | + } |
| 86 | +} |
| 87 | +``` |
| 88 | + |
| 89 | +```bash |
| 90 | +terraform init |
| 91 | +terraform plan |
| 92 | +terraform apply |
| 93 | +``` |
| 94 | + |
| 95 | +Run `terraform destroy` when you don't need these resources. |
0 commit comments