Skip to content

Commit 38c0187

Browse files
authored
feat: Added support to use image SHA instead of image tag. The default will now use SHA instead of tag. A new input logs_agent_init_image_version was added to differentiate between the initContainer image and the main container image (which is passed with logs_agent_image_version) (#154)
1 parent d368482 commit 38c0187

File tree

8 files changed

+40
-7
lines changed

8 files changed

+40
-7
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,8 @@ No modules.
130130
| <a name="input_logs_agent_iam_api_key"></a> [logs\_agent\_iam\_api\_key](#input\_logs\_agent\_iam\_api\_key) | The IBM Cloud API key for the Logs agent to authenticate and communicate with the IBM Cloud Logs. It is required if `logs_agent_iam_mode` is set to `IAMAPIKey`. | `string` | `null` | no |
131131
| <a name="input_logs_agent_iam_environment"></a> [logs\_agent\_iam\_environment](#input\_logs\_agent\_iam\_environment) | IAM authentication Environment: `Production` or `PrivateProduction` or `Staging` or `PrivateStaging`. `Production` specifies the public endpoint & `PrivateProduction` specifies the private endpoint. | `string` | `"PrivateProduction"` | no |
132132
| <a name="input_logs_agent_iam_mode"></a> [logs\_agent\_iam\_mode](#input\_logs\_agent\_iam\_mode) | IAM authentication mode: `TrustedProfile` or `IAMAPIKey`. | `string` | `"TrustedProfile"` | no |
133-
| <a name="input_logs_agent_image_version"></a> [logs\_agent\_image\_version](#input\_logs\_agent\_image\_version) | The version of the Logs agent image to deploy. | `string` | `"1.6.1"` | no |
133+
| <a name="input_logs_agent_image_version"></a> [logs\_agent\_image\_version](#input\_logs\_agent\_image\_version) | The version of the Logs agent image to deploy. | `string` | `"1.6.1@sha256:0265b85c698e74dfd9e21ad0332a430a3b398c4f0e590dad314c43b3cd796bce"` | no |
134+
| <a name="input_logs_agent_init_image_version"></a> [logs\_agent\_init\_image\_version](#input\_logs\_agent\_init\_image\_version) | The version of the Logs agent init container image to deploy. | `string` | `"1.6.1@sha256:d2c1bb5a97c0d8950d3dfee016cec4347a6cfa8a43123d9c2eecbdee70500f8b"` | no |
134135
| <a name="input_logs_agent_log_source_namespaces"></a> [logs\_agent\_log\_source\_namespaces](#input\_logs\_agent\_log\_source\_namespaces) | The list of namespaces from which logs should be forwarded by agent. If namespaces are not listed, logs from all namespaces will be sent. | `list(string)` | `[]` | no |
135136
| <a name="input_logs_agent_name"></a> [logs\_agent\_name](#input\_logs\_agent\_name) | The name of the Logs agent. The name is used in all Kubernetes and Helm resources in the cluster. | `string` | `"logs-agent"` | no |
136137
| <a name="input_logs_agent_namespace"></a> [logs\_agent\_namespace](#input\_logs\_agent\_namespace) | The namespace where the Logs agent is deployed. The default value is `ibm-observe`. | `string` | `"ibm-observe"` | no |

examples/logs-agent-ocp/version.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ terraform {
33
required_version = ">= 1.9.0"
44

55
# Ensure that there is always 1 example locked into the lowest provider version of the range defined in the main
6-
# module's version.tf (logs-agent-iks), and 1 example that will always use the latest provider version (this exammple).
6+
# module's version.tf (logs-agent-iks), and 1 example that will always use the latest provider version (this example).
77
required_providers {
88
ibm = {
99
source = "ibm-cloud/ibm"

ibm_catalog.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,9 @@
147147
{
148148
"key": "logs_agent_image_version"
149149
},
150+
{
151+
"key": "logs_agent_init_image_version"
152+
},
150153
{
151154
"key": "logs_agent_resources"
152155
},

main.tf

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ locals {
3232
for metadata in var.logs_agent_additional_metadata : {
3333
(metadata.key) = metadata.value
3434
}]...) : {} # DO NOT REMOVE "...", it is used to convert list of objects into a single object
35-
cluster_name = var.is_vpc_cluster ? data.ibm_container_vpc_cluster.cluster[0].resource_name : data.ibm_container_cluster.cluster[0].resource_name # Not publically documented in provider. See https://github.com/IBM-Cloud/terraform-provider-ibm/issues/4485
35+
cluster_name = var.is_vpc_cluster ? data.ibm_container_vpc_cluster.cluster[0].resource_name : data.ibm_container_cluster.cluster[0].resource_name # Not publicly documented in provider. See https://github.com/IBM-Cloud/terraform-provider-ibm/issues/4485
3636
}
3737

3838
resource "helm_release" "logs_agent" {
@@ -55,7 +55,17 @@ resource "helm_release" "logs_agent" {
5555
set {
5656
name = "image.version"
5757
type = "string"
58-
value = var.logs_agent_image_version
58+
value = split("@", var.logs_agent_image_version)[0]
59+
}
60+
set {
61+
name = "image.containerSha"
62+
type = "string"
63+
value = strcontains(var.logs_agent_image_version, "@") ? split("@", var.logs_agent_image_version)[1] : ""
64+
}
65+
set {
66+
name = "image.initContainerSha"
67+
type = "string"
68+
value = strcontains(var.logs_agent_init_image_version, "@") ? split("@", var.logs_agent_init_image_version)[1] : ""
5969
}
6070
set {
6171
name = "env.ingestionHost"

renovate.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"fileMatch": ["variables.tf$"],
99
"datasourceTemplate": "docker",
1010
"matchStrings": [
11-
"default\\s*=\\s*\"(?<currentValue>.*)\"\\s*# datasource: (?<depName>[^\\s]+)"
11+
"default\\s*=\\s*\"(?<currentValue>[\\w.-]+)@(?<currentDigest>sha256:[a-f0-9]+)\"\\s*# datasource: (?<depName>[^\\s]+)"
1212
]
1313
}
1414
]

solutions/fully-configurable/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ module "logs_agent" {
2424
logs_agent_chart_location = var.logs_agent_chart_location
2525
logs_agent_chart_version = var.logs_agent_chart_version
2626
logs_agent_image_version = var.logs_agent_image_version
27+
logs_agent_init_image_version = var.logs_agent_init_image_version
2728
logs_agent_name = var.logs_agent_name
2829
logs_agent_namespace = var.logs_agent_namespace
2930
logs_agent_trusted_profile_id = var.logs_agent_trusted_profile_id

solutions/fully-configurable/variables.tf

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,17 @@ variable "logs_agent_chart_version" {
6868
nullable = false
6969
}
7070

71+
variable "logs_agent_init_image_version" {
72+
description = "The version of the Logs agent init container image to deploy."
73+
type = string
74+
default = "1.6.1@sha256:d2c1bb5a97c0d8950d3dfee016cec4347a6cfa8a43123d9c2eecbdee70500f8b" # datasource: icr.io/ibm/observe/logs-router-agent-init
75+
nullable = false
76+
}
77+
7178
variable "logs_agent_image_version" {
7279
description = "The version of the Logs agent image to deploy."
7380
type = string
74-
default = "1.6.1" # datasource: icr.io/ibm/observe/logs-agent-helm
81+
default = "1.6.1@sha256:0265b85c698e74dfd9e21ad0332a430a3b398c4f0e590dad314c43b3cd796bce" # datasource: icr.io/ibm/observe/logs-router-agent
7582
nullable = false
7683
}
7784

variables.tf

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,22 @@ variable "logs_agent_chart_version" {
7676
nullable = false
7777
}
7878

79+
variable "logs_agent_init_image_version" {
80+
description = "The version of the Logs agent init container image to deploy."
81+
type = string
82+
default = "1.6.1@sha256:d2c1bb5a97c0d8950d3dfee016cec4347a6cfa8a43123d9c2eecbdee70500f8b" # datasource: icr.io/ibm/observe/logs-router-agent-init
83+
nullable = false
84+
}
85+
7986
variable "logs_agent_image_version" {
8087
description = "The version of the Logs agent image to deploy."
8188
type = string
82-
default = "1.6.1" # datasource: icr.io/ibm/observe/logs-agent-helm
89+
default = "1.6.1@sha256:0265b85c698e74dfd9e21ad0332a430a3b398c4f0e590dad314c43b3cd796bce" # datasource: icr.io/ibm/observe/logs-router-agent
8390
nullable = false
91+
validation {
92+
condition = split("@", var.logs_agent_image_version)[0] == split("@", var.logs_agent_init_image_version)[0]
93+
error_message = "The image tags for `logs_agent_init_image_version` and `logs_agent_image_version` should be same."
94+
}
8495
}
8596

8697
variable "logs_agent_name" {

0 commit comments

Comments
 (0)