|
1 | 1 | <!-- BEGIN MODULE HOOK --> |
2 | 2 |
|
3 | | -<!-- Update the title to match the module name and add a description --> |
4 | | -# Terraform Modules Template Project |
5 | | -<!-- UPDATE BADGE: Update the link for the following badge--> |
| 3 | +# Terraform IBM Observability agents module |
| 4 | + |
6 | 5 | [-red)](https://terraform-ibm-modules.github.io/documentation/#/badge-status) |
7 | 6 | [](https://github.com/terraform-ibm-modules/terraform-ibm-module-template/actions/workflows/ci.yml) |
8 | 7 | [](https://github.com/pre-commit/pre-commit) |
9 | 8 | [](https://github.com/terraform-ibm-modules/terraform-ibm-module-template/releases/latest) |
10 | 9 | [](https://renovatebot.com/) |
11 | 10 | [](https://github.com/semantic-release/semantic-release) |
12 | 11 |
|
13 | | -<!-- Remove the content in this H2 heading after completing the steps --> |
14 | | - |
15 | | -## Submit a new module |
16 | | - |
17 | | -:+1::tada: Thank you for taking the time to contribute! :tada::+1: |
18 | | - |
19 | | -This template repository exists to help you create Terraform modules for IBM Cloud. |
20 | | - |
21 | | -The default structure includes the following files: |
22 | | - |
23 | | -- `README.md`: A description of the module |
24 | | -- `main.tf`: The logic for the module |
25 | | -- `version.tf`: The required terraform and provider versions |
26 | | -- `variables.tf`: The input variables for the module |
27 | | -- `outputs.tf`: The values that are output from the module |
28 | | -For more information, see [Module structure](https://terraform-ibm-modules.github.io/documentation/#/module-structure) in the project documentation. |
29 | | - |
30 | | -You can add other content to support what your module does and how it works. For example, you might add a `scripts/` directory that contains shell scripts that are run by a `local-exec` `null_resource` in the Terraform module. |
31 | | - |
32 | | -Follow this process to create and submit a Terraform module. |
33 | | - |
34 | | -### Create a repo from this repo template |
35 | | - |
36 | | -1. Create a repository from this repository template by clicking `Use this template` in the upper right of the GitHub UI. |
37 | | -    <br>For more information about creating a repository from a template, see the [GitHub docs](https://docs.github.com/en/repositories/creating-and-managing-repositories/creating-a-repository-from-a-template). |
38 | | -1. Select `terraform-ibm-modules` as the owner. |
39 | | -1. Enter a name for the module in format `terraform-ibm-<NAME>`, where `<NAME>` reflects the type of infrastructure that the module manages. |
40 | | -    <br>Use hyphens as delimiters for names with multiple words (for example, terraform-ibm-`activity-tracker`). |
41 | | -1. Provide a short description of the module. |
42 | | -    <br>The description is displayed under the repository name on the [organization page](https://github.com/terraform-ibm-modules) and in the **About** section of the repository. Use the description to help users understand the purpose of your module. For more information, see [module names and descriptions](https://terraform-ibm-modules.github.io/documentation/#/implementation-guidelines?id=module-names-and-descriptions) in the docs. |
43 | | - |
44 | | -### Clone the repo and set up your development environment |
45 | | - |
46 | | -Locally clone the new repository and set up your development environment by completing the tasks in [Local development setup](https://terraform-ibm-modules.github.io/documentation/#/local-dev-setup) in the project documentation. |
47 | | - |
48 | | -### Update the repo name and description in source control |
49 | | - |
50 | | -To help make sure that the repo name and description are not changed except through pull requests, they are defined in the `settings.yml` file. |
51 | | - |
52 | | -Check to make sure that values are uncommented and correct: |
53 | | - |
54 | | -1. Open the [settings.yml](.github/settings.yml) file. |
55 | | -1. If not already updated, uncomment the `name` and `description` properties and set the values to what you specified when you requested the repo. |
56 | | - |
57 | | -### Update the Terraform files |
58 | | - |
59 | | -Implement the logic for your module by updating the `main.tf`, `version.tf`, `variables.tf`, and `outputs.tf` Terraform files. For more information, see [Creating Terraform on IBM Cloud templates](https://cloud.ibm.com/docs/ibm-cloud-provider-for-terraform?topic=ibm-cloud-provider-for-terraform-create-tf-config). |
| 12 | +This module supports deploying the following observability agents to the provided OCP cluster: |
60 | 13 |
|
61 | | -### Create examples and tests |
62 | | - |
63 | | -Add one or more examples in the `examples` directory that consume your new module, and configure tests for them in the `tests` directory. For more information about tests, see [Tests](https://terraform-ibm-modules.github.io/documentation/#/tests). |
64 | | - |
65 | | -### Update the content in the readme file |
66 | | - |
67 | | -After you implement the logic for your module and create examples and tests, update this readme file in your repository by following these steps: |
68 | | - |
69 | | -1. Update the title heading and add a description about your module. |
70 | | -1. Update the badge links. |
71 | | -1. Remove all the content in this H2 heading section. |
72 | | -1. Complete the [Usage](#usage) and [Required IAM access policies](#required-iam-access-policies) sections. The [Examples](#examples) and [Requirements](#requirements) section are populated by a pre-commit hook. |
73 | | - |
74 | | -### Commit your code and submit your module for review |
75 | | - |
76 | | -1. Before you commit any code, review [Contributing to the IBM Cloud Terraform modules project](https://terraform-ibm-modules.github.io/documentation/#/contribute-module) in the project documentation. |
77 | | -1. Create a pull request for review. |
78 | | - |
79 | | -### Post-merge steps |
80 | | - |
81 | | -After the first PR for your module is merged, follow these post-merge steps: |
82 | | - |
83 | | -1. Create a PR to enable the upgrade test by removing the `t.Skip` line in `tests/pr_test.go`. |
84 | | - |
85 | | -<!-- Remove the content in this previous H2 heading --> |
86 | | -## Reference architectures |
87 | | - |
88 | | -<!-- |
89 | | -Add links to any reference architectures for this module. |
90 | | -(Usually in the `/reference-architectures` directory.) |
91 | | ---> |
| 14 | +* Logging (LogDNA) agent |
| 15 | +* Monitoring (SysDig) agent |
92 | 16 |
|
93 | 17 | ## Usage |
94 | 18 |
|
95 | | -<!-- |
96 | | -Add an example of the use of the module in the following code block. |
97 | | -
|
98 | | -Use real values instead of "var.<var_name>" or other placeholder values |
99 | | -unless real values don't help users know what to change. |
100 | | ---> |
101 | | - |
102 | 19 | ```hcl |
103 | | -
|
| 20 | +# ############################################################################ |
| 21 | +terraform { |
| 22 | + required_providers { |
| 23 | + ibm = { |
| 24 | + source = "IBM-Cloud/ibm" |
| 25 | + version = "~> 1.38.0" |
| 26 | + } |
| 27 | + } |
| 28 | +} |
| 29 | +# ############################################################################ |
| 30 | +# Init cluster config for helm |
| 31 | +# ############################################################################ |
| 32 | +
|
| 33 | +data "ibm_container_cluster_config" "cluster_config" { |
| 34 | + # update this value with the Id of the cluster where these agents will be provisioned |
| 35 | + cluster_name_id = "cluster_id" |
| 36 | +} |
| 37 | +
|
| 38 | +# ############################################################################ |
| 39 | +# Config providers |
| 40 | +# ############################################################################ |
| 41 | +
|
| 42 | +provider "ibm" { |
| 43 | + # update this value with your IBM Cloud API key value |
| 44 | + ibmcloud_api_key = "api key value" # pragma: allowlist secret |
| 45 | +} |
| 46 | +
|
| 47 | +provider "helm" { |
| 48 | + kubernetes { |
| 49 | + host = data.ibm_container_cluster_config.cluster_config.host |
| 50 | + token = data.ibm_container_cluster_config.cluster_config.token |
| 51 | + cluster_ca_certificate = data.ibm_container_cluster_config.cluster_config.ca_certificate |
| 52 | + } |
| 53 | +} |
| 54 | +
|
| 55 | +# ############################################################################ |
| 56 | +# Install observability agents |
| 57 | +# ############################################################################ |
| 58 | +
|
| 59 | +# Replace "main" with a GIT release version to lock into a specific release |
| 60 | +module "observability_agents" { |
| 61 | + source = "git::https://github.com/terraform-ibm-modules/terraform-ibm-observability-agents?ref=main" |
| 62 | + # update this with your cluster id where the agents will be installed |
| 63 | + cluster_id = "cluster id" |
| 64 | + # update this with the Id of your IBM Cloud resource group |
| 65 | + cluster_resource_group_id = "resource group id" |
| 66 | + # update these values with names and keys from the observability instances provisioning |
| 67 | + logdna_instance_name = "logdna instance name" |
| 68 | + logdna_ingestion_key = "logdna ingestion key" |
| 69 | + sysdig_instance_name = "sysdig name" |
| 70 | + sysdig_access_key = "sysdig access key" |
| 71 | +} |
104 | 72 | ``` |
105 | 73 |
|
106 | 74 | ## Required IAM access policies |
107 | | - |
108 | | -<!-- PERMISSIONS REQUIRED TO RUN MODULE |
109 | | -If this module requires permissions, uncomment the following block and update |
110 | | -the sample permissions, following the format. |
111 | | -Replace the sample Account and IBM Cloud service names and roles with the |
112 | | -information in the console at |
113 | | -Manage > Access (IAM) > Access groups > Access policies. |
114 | | ---> |
115 | | - |
116 | | -<!-- |
117 | 75 | You need the following permissions to run this module. |
118 | 76 |
|
119 | | -- Account Management |
120 | | - - **Sample Account Service** service |
121 | | - - `Editor` platform access |
122 | | - - `Manager` service access |
123 | | - - IAM Services |
124 | | - - **Sample Cloud Service** service |
125 | | - - `Administrator` platform access |
126 | | ---> |
127 | | - |
128 | | -<!-- NO PERMISSIONS FOR MODULE |
129 | | -If no permissions are required for the module, uncomment the following |
130 | | -statement instead the previous block. |
131 | | ---> |
132 | | - |
133 | | -<!-- No permissions are needed to run this module.--> |
| 77 | +- IAM Services |
| 78 | + - **IBM Cloud Activity Tracker** service |
| 79 | + - `Viewer` platform access |
| 80 | + - `Reader` service access |
| 81 | + - **IBM Cloud Monitoring** service |
| 82 | + - `Viewer` platform access |
| 83 | + - `Reader` service access |
| 84 | + - **IBM Log Analysis** service |
| 85 | + - `Viewer` platform access |
| 86 | + - `Reader` service access |
| 87 | + - **Kubernetes** service |
| 88 | + - `Viewer` platform access |
| 89 | + - `Manager` service access |
| 90 | + |
134 | 91 | <!-- END MODULE HOOK --> |
135 | 92 | <!-- BEGIN EXAMPLES HOOK --> |
136 | 93 | ## Examples |
137 | 94 |
|
138 | | -- [ Default example](examples/default) |
139 | | -- [ Example that uses existing resources](examples/existing-resources) |
140 | | -- [ Non default example](examples/non-default) |
| 95 | +- [ Deploy basic observability agents](examples/basic) |
141 | 96 | <!-- END EXAMPLES HOOK --> |
142 | 97 | <!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK --> |
143 | 98 | ## Requirements |
144 | 99 |
|
145 | 100 | | Name | Version | |
146 | 101 | |------|---------| |
147 | | -| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0.0 | |
| 102 | +| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.1.0 | |
| 103 | +| <a name="requirement_helm"></a> [helm](#requirement\_helm) | >= 2.8.0 | |
| 104 | +| <a name="requirement_ibm"></a> [ibm](#requirement\_ibm) | >= 1.49.0 | |
148 | 105 |
|
149 | 106 | ## Modules |
150 | 107 |
|
151 | 108 | No modules. |
152 | 109 |
|
153 | 110 | ## Resources |
154 | 111 |
|
155 | | -No resources. |
| 112 | +| Name | Type | |
| 113 | +|------|------| |
| 114 | +| [helm_release.logdna_agent](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) | resource | |
| 115 | +| [helm_release.sysdig_agent](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) | resource | |
| 116 | +| [ibm_container_cluster_config.cluster_config](https://registry.terraform.io/providers/ibm-cloud/ibm/latest/docs/data-sources/container_cluster_config) | data source | |
| 117 | +| [ibm_container_vpc_cluster.cluster](https://registry.terraform.io/providers/ibm-cloud/ibm/latest/docs/data-sources/container_vpc_cluster) | data source | |
| 118 | +| [ibm_resource_instance.logdna_instance](https://registry.terraform.io/providers/ibm-cloud/ibm/latest/docs/data-sources/resource_instance) | data source | |
| 119 | +| [ibm_resource_instance.sysdig_instance](https://registry.terraform.io/providers/ibm-cloud/ibm/latest/docs/data-sources/resource_instance) | data source | |
156 | 120 |
|
157 | 121 | ## Inputs |
158 | 122 |
|
159 | | -No inputs. |
| 123 | +| Name | Description | Type | Default | Required | |
| 124 | +|------|-------------|------|---------|:--------:| |
| 125 | +| <a name="input_cluster_id"></a> [cluster\_id](#input\_cluster\_id) | Cluster id to add to agents to | `string` | n/a | yes | |
| 126 | +| <a name="input_cluster_resource_group_id"></a> [cluster\_resource\_group\_id](#input\_cluster\_resource\_group\_id) | Resource group of the cluster | `string` | n/a | yes | |
| 127 | +| <a name="input_logdna_agent_version"></a> [logdna\_agent\_version](#input\_logdna\_agent\_version) | Version of the agent to deploy. To lookup version run: `ibmcloud cr images --restrict ext/logdna-agent`. If null, the default value is used. | `string` | `"3.8.0-20230206.cbc937fa5513f636"` | no | |
| 128 | +| <a name="input_logdna_enabled"></a> [logdna\_enabled](#input\_logdna\_enabled) | Deploy IBM Cloud Logging agent | `bool` | `true` | no | |
| 129 | +| <a name="input_logdna_ingestion_key"></a> [logdna\_ingestion\_key](#input\_logdna\_ingestion\_key) | Ingestion key for the IBM Cloud Logging agent to communicate with the instance | `string` | `null` | no | |
| 130 | +| <a name="input_logdna_instance_name"></a> [logdna\_instance\_name](#input\_logdna\_instance\_name) | IBM Cloud Logging instance to use. Required if LogDNA is enabled | `string` | `null` | no | |
| 131 | +| <a name="input_logdna_resource_group_id"></a> [logdna\_resource\_group\_id](#input\_logdna\_resource\_group\_id) | Resource group the IBM Cloud Logging instance is in. Defaults to Clusters group | `string` | `null` | no | |
| 132 | +| <a name="input_sysdig_access_key"></a> [sysdig\_access\_key](#input\_sysdig\_access\_key) | Access key used by the IBM Cloud Monitoring agent to communicate with the instance | `string` | `null` | no | |
| 133 | +| <a name="input_sysdig_agent_version"></a> [sysdig\_agent\_version](#input\_sysdig\_agent\_version) | IBM Cloud Monitoring Agent Version. To lookup version run: `ibmcloud cr images --restrict ext/sysdig/agent`. If null, the default value is used. | `string` | `"12.10.1"` | no | |
| 134 | +| <a name="input_sysdig_enabled"></a> [sysdig\_enabled](#input\_sysdig\_enabled) | Deploy IBM Cloud Monitoring agent | `bool` | `true` | no | |
| 135 | +| <a name="input_sysdig_instance_name"></a> [sysdig\_instance\_name](#input\_sysdig\_instance\_name) | The name of the IBM Cloud Monitoring instance to use. Required if Sysdig is enabled | `string` | `null` | no | |
| 136 | +| <a name="input_sysdig_resource_group_id"></a> [sysdig\_resource\_group\_id](#input\_sysdig\_resource\_group\_id) | Resource group that the IBM Cloud Monitoring is in. Defaults to Clusters group | `string` | `null` | no | |
160 | 137 |
|
161 | 138 | ## Outputs |
162 | 139 |
|
|
0 commit comments