|
| 1 | +# Kubernetes API server audit logs |
| 2 | + |
| 3 | +To monitor user-initiated, Kubernetes administrative activity made within your cluster, you can collect and forward audit events that are passed through your Kubernetes API server to IBM Cloud Logs or an external server. |
| 4 | + |
| 5 | +This sub-module helps you to create a Kubernetes audit system by using the provided image and deployment in your existing cluster. [Learn more](https://cloud.ibm.com/docs/openshift?topic=openshift-health-audit) |
| 6 | + |
| 7 | +**Important**: The sub-module uses the `icr.io/ibm/ibmcloud-kube-audit-to-ibm-cloud-logs` image to forward logs to IBM Cloud Logs. This image is for demonstration purposes only. For a production solution, configure and maintain your own log forwarding image. |
| 8 | + |
| 9 | +### Usage |
| 10 | + |
| 11 | +```hcl |
| 12 | +# ############################################################################ |
| 13 | +# Init cluster config for helm |
| 14 | +# ############################################################################ |
| 15 | +
|
| 16 | +data "ibm_container_cluster_config" "cluster_config" { |
| 17 | + # update this value with the Id of the cluster where these agents will be provisioned |
| 18 | + cluster_name_id = "cluster_id" |
| 19 | +} |
| 20 | +
|
| 21 | +# ############################################################################ |
| 22 | +# Config providers |
| 23 | +# ############################################################################ |
| 24 | +
|
| 25 | +provider "ibm" { |
| 26 | + # update this value with your IBM Cloud API key value |
| 27 | + ibmcloud_api_key = "XXXXXXXXXXXXXXXXX" #pragma: allowlist secret |
| 28 | +} |
| 29 | +
|
| 30 | +provider "helm" { |
| 31 | + kubernetes { |
| 32 | + host = data.ibm_container_cluster_config.cluster_config.host |
| 33 | + token = data.ibm_container_cluster_config.cluster_config.token |
| 34 | + cluster_ca_certificate = data.ibm_container_cluster_config.cluster_config.ca_certificate |
| 35 | + } |
| 36 | +} |
| 37 | +
|
| 38 | +provider "kubernetes" { |
| 39 | + host = data.ibm_container_cluster_config.cluster_config.host |
| 40 | + token = data.ibm_container_cluster_config.cluster_config.token |
| 41 | + cluster_ca_certificate = data.ibm_container_cluster_config.cluster_config.ca_certificate |
| 42 | +} |
| 43 | +
|
| 44 | +module "kube_audit" { |
| 45 | + source = "terraform-ibm-modules/terraform-ibm-base-ocp-vpc/ibm//modules/kube-audit" |
| 46 | + version = "X.X.X" # Replace "X.X.X" with a release version to lock into a specific release |
| 47 | + cluster_id = "cluster_id" |
| 48 | + cluster_resource_group_id = "resource group id" |
| 49 | + region = "us-south" |
| 50 | +} |
| 51 | +``` |
| 52 | + |
| 53 | +<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK --> |
| 54 | +### Requirements |
| 55 | + |
| 56 | +| Name | Version | |
| 57 | +|------|---------| |
| 58 | +| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >=1.9.0 | |
| 59 | +| <a name="requirement_helm"></a> [helm](#requirement\_helm) | >= 2.15.0, <3.0.0 | |
| 60 | +| <a name="requirement_ibm"></a> [ibm](#requirement\_ibm) | >= 1.70.0, <2.0.0 | |
| 61 | +| <a name="requirement_null"></a> [null](#requirement\_null) | >= 3.2.1, < 4.0.0 | |
| 62 | +| <a name="requirement_time"></a> [time](#requirement\_time) | >= 0.9.1, < 1.0.0 | |
| 63 | + |
| 64 | +### Modules |
| 65 | + |
| 66 | +No modules. |
| 67 | + |
| 68 | +### Resources |
| 69 | + |
| 70 | +| Name | Type | |
| 71 | +|------|------| |
| 72 | +| [helm_release.kube_audit](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) | resource | |
| 73 | +| [null_resource.set_audit_log_policy](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource | |
| 74 | +| [null_resource.set_audit_webhook](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource | |
| 75 | +| [time_sleep.wait_for_kube_audit](https://registry.terraform.io/providers/hashicorp/time/latest/docs/resources/sleep) | resource | |
| 76 | +| [ibm_container_cluster_config.cluster_config](https://registry.terraform.io/providers/ibm-cloud/ibm/latest/docs/data-sources/container_cluster_config) | data source | |
| 77 | +| [ibm_container_vpc_cluster.cluster](https://registry.terraform.io/providers/ibm-cloud/ibm/latest/docs/data-sources/container_vpc_cluster) | data source | |
| 78 | + |
| 79 | +### Inputs |
| 80 | + |
| 81 | +| Name | Description | Type | Default | Required | |
| 82 | +|------|-------------|------|---------|:--------:| |
| 83 | +| <a name="input_audit_deployment_name"></a> [audit\_deployment\_name](#input\_audit\_deployment\_name) | The name of log collection deployement and service. | `string` | `"ibmcloud-kube-audit"` | no | |
| 84 | +| <a name="input_audit_log_policy"></a> [audit\_log\_policy](#input\_audit\_log\_policy) | Specify the amount of information that is logged to the API server audit logs by choosing the audit log policy profile to use. Supported values are `default` and `WriteRequestBodies`. | `string` | `"default"` | no | |
| 85 | +| <a name="input_audit_namespace"></a> [audit\_namespace](#input\_audit\_namespace) | The name of the namespace where log collection service and a deployment will be created. | `string` | `"ibm-kube-audit"` | no | |
| 86 | +| <a name="input_audit_webhook_listener_image"></a> [audit\_webhook\_listener\_image](#input\_audit\_webhook\_listener\_image) | The audit webhook listener image reference in the format of `[registry-url]/[namespace]/[image]`.The sub-module uses the `icr.io/ibm/ibmcloud-kube-audit-to-ibm-cloud-logs` image to forward logs to IBM Cloud Logs. This image is for demonstration purposes only. For a production solution, configure and maintain your own log forwarding image. | `string` | `"icr.io/ibm/ibmcloud-kube-audit-to-ibm-cloud-logs"` | no | |
| 87 | +| <a name="input_audit_webhook_listener_image_version"></a> [audit\_webhook\_listener\_image\_version](#input\_audit\_webhook\_listener\_image\_version) | The tag or digest for the audit webhook listener image to deploy. If changing the value, ensure it is compatible with `audit_webhook_listener_image`. | `string` | `"deaabcb8225e800385413ba420cf3f819d3b0671@sha256:acf123f4dba63534cbc104c6886abedff9d25a22a34ab7b549ede988ed6e7144"` | no | |
| 88 | +| <a name="input_cluster_config_endpoint_type"></a> [cluster\_config\_endpoint\_type](#input\_cluster\_config\_endpoint\_type) | Specify which type of endpoint to use for for cluster config access: 'default', 'private', 'vpe', 'link'. 'default' value will use the default endpoint of the cluster. | `string` | `"default"` | no | |
| 89 | +| <a name="input_cluster_id"></a> [cluster\_id](#input\_cluster\_id) | The ID of the cluster to deploy the log collection service in. | `string` | n/a | yes | |
| 90 | +| <a name="input_cluster_resource_group_id"></a> [cluster\_resource\_group\_id](#input\_cluster\_resource\_group\_id) | The resource group ID of the cluster. | `string` | n/a | yes | |
| 91 | +| <a name="input_ibmcloud_api_key"></a> [ibmcloud\_api\_key](#input\_ibmcloud\_api\_key) | The IBM Cloud api key to generate an IAM token. | `string` | n/a | yes | |
| 92 | +| <a name="input_region"></a> [region](#input\_region) | The IBM Cloud region where the cluster is provisioned. | `string` | n/a | yes | |
| 93 | +| <a name="input_use_private_endpoint"></a> [use\_private\_endpoint](#input\_use\_private\_endpoint) | Set this to true to force all api calls to use the IBM Cloud private endpoints. | `bool` | `false` | no | |
| 94 | +| <a name="input_wait_till"></a> [wait\_till](#input\_wait\_till) | To avoid long wait times when you run your Terraform code, you can specify the stage when you want Terraform to mark the cluster resource creation as completed. Depending on what stage you choose, the cluster creation might not be fully completed and continues to run in the background. However, your Terraform code can continue to run without waiting for the cluster to be fully created. Supported args are `MasterNodeReady`, `OneWorkerNodeReady`, `IngressReady` and `Normal` | `string` | `"IngressReady"` | no | |
| 95 | +| <a name="input_wait_till_timeout"></a> [wait\_till\_timeout](#input\_wait\_till\_timeout) | Timeout for wait\_till in minutes. | `number` | `90` | no | |
| 96 | + |
| 97 | +### Outputs |
| 98 | + |
| 99 | +No outputs. |
| 100 | +<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK --> |
0 commit comments