Skip to content

Commit 0f80de0

Browse files
authored
feat: initial commit (#2)
1 parent 3ae72c8 commit 0f80de0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+1588
-373
lines changed

.github/settings.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,9 @@ repository:
1414

1515
# By changing this field, you rename the repository.
1616

17-
# Uncomment this name property and set the name to the current repo name.
18-
# name: ""
17+
name: "terraform-ibm-observability-agents"
1918

2019
# The description is displayed under the repository name on the
2120
# organization page and in the 'About' section of the repository.
2221

23-
# Uncomment this description property
24-
# and update the description to the current repo description.
25-
# description: ""
22+
description: "Deploys the LogDNA agent and SysDig agents to a cluster"

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,6 @@ jobs:
1515
call-terraform-ci-pipeline:
1616
uses: terraform-ibm-modules/common-pipeline-assets/.github/workflows/[email protected]
1717
secrets: inherit
18+
with:
19+
craTarget: "examples/basic"
20+
craGoalIgnoreFile: "cra-tf-validate-ignore-goals.json"

README.md

Lines changed: 97 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -1,162 +1,139 @@
11
<!-- BEGIN MODULE HOOK -->
22

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+
65
[![Incubating (Not yet consumable)](https://img.shields.io/badge/status-Incubating%20(Not%20yet%20consumable)-red)](https://terraform-ibm-modules.github.io/documentation/#/badge-status)
76
[![Build status](https://github.com/terraform-ibm-modules/terraform-ibm-module-template/actions/workflows/ci.yml/badge.svg)](https://github.com/terraform-ibm-modules/terraform-ibm-module-template/actions/workflows/ci.yml)
87
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)
98
[![latest release](https://img.shields.io/github/v/release/terraform-ibm-modules/terraform-ibm-module-template?logo=GitHub&sort=semver)](https://github.com/terraform-ibm-modules/terraform-ibm-module-template/releases/latest)
109
[![Renovate enabled](https://img.shields.io/badge/renovate-enabled-brightgreen.svg)](https://renovatebot.com/)
1110
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
1211

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-
&emsp;&emsp;&emsp;&emsp;<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-
&emsp;&emsp;&emsp;&emsp;<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-
&emsp;&emsp;&emsp;&emsp;<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:
6013

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
9216

9317
## Usage
9418

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-
10219
```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+
}
10472
```
10573

10674
## 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-
<!--
11775
You need the following permissions to run this module.
11876

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+
13491
<!-- END MODULE HOOK -->
13592
<!-- BEGIN EXAMPLES HOOK -->
13693
## Examples
13794

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)
14196
<!-- END EXAMPLES HOOK -->
14297
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
14398
## Requirements
14499

145100
| Name | Version |
146101
|------|---------|
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 |
148105

149106
## Modules
150107

151108
No modules.
152109

153110
## Resources
154111

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 |
156120

157121
## Inputs
158122

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 |
160137

161138
## Outputs
162139

chart/logdna-agent/Chart.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
apiVersion: v2
2+
name: logdna-agent
3+
description: A Helm chart for a logdna or activity tracker agent
4+
5+
type: application
6+
7+
version: 0.1.0
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
kind: ClusterRole
2+
apiVersion: rbac.authorization.k8s.io/v1
3+
metadata:
4+
name: "{{ .Values.metadata.name }}"
5+
labels:
6+
app.kubernetes.io/name: {{ .Values.metadata.name }}
7+
app.kubernetes.io/instance: {{ .Values.metadata.name }}
8+
app.kubernetes.io/version: {{ .Values.image.version }}
9+
rules:
10+
- apiGroups: [""]
11+
resources: ["events"]
12+
verbs: ["get","list", "create", "watch"]
13+
- apiGroups: [""]
14+
resources: ["pods"]
15+
verbs: ["get","list", "watch"]
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: ClusterRoleBinding
3+
metadata:
4+
name: "{{ .Values.metadata.name }}"
5+
namespace: {{ .Release.Namespace }}
6+
labels:
7+
app.kubernetes.io/name: "{{ .Values.metadata.name }}"
8+
app.kubernetes.io/instance: "{{ .Values.metadata.name }}"
9+
app.kubernetes.io/version: {{ .Values.image.version }}
10+
roleRef:
11+
apiGroup: rbac.authorization.k8s.io
12+
kind: ClusterRole
13+
name: "{{ .Values.metadata.name }}"
14+
subjects:
15+
- kind: ServiceAccount
16+
name: "{{ .Values.metadata.name }}"
17+
namespace: {{ .Release.Namespace }}

0 commit comments

Comments
 (0)