Skip to content

Commit 22d9a64

Browse files
aatreyee2506Aatreyee MukherjeeAk-skyAatreyee Mukherjeeaatreyee257
authored
feat: add support to pass image pull credentials (#448) <br> - Added support for passing image pull credentials when deploying Kibana from a private registry
--------- Co-authored-by: Aatreyee Mukherjee <[email protected]> Co-authored-by: Akash Kumar <[email protected]> Co-authored-by: Aatreyee Mukherjee <[email protected]> Co-authored-by: aatreyee257 <[email protected]> Co-authored-by: whoffler <[email protected]> Co-authored-by: shemau <[email protected]> Co-authored-by: Akash Kumar <[email protected]>
1 parent 58d6029 commit 22d9a64

File tree

5 files changed

+99
-12
lines changed

5 files changed

+99
-12
lines changed

.secrets.baseline

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"files": "go.sum|^.secrets.baseline$",
44
"lines": null
55
},
6-
"generated_at": "2025-07-24T21:11:38Z",
6+
"generated_at": "2025-07-31T19:33:02Z",
77
"plugins_used": [
88
{
99
"name": "AWSKeyDetector"
@@ -110,7 +110,7 @@
110110
"hashed_secret": "8c7c51db5075ebd0369c51e9f14737d9b4c1c21d",
111111
"is_secret": false,
112112
"is_verified": false,
113-
"line_number": 380,
113+
"line_number": 379,
114114
"type": "Base64 High Entropy String",
115115
"verified_result": null
116116
}

ibm_catalog.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,9 @@
433433
{
434434
"key": "existing_code_engine_project_id"
435435
},
436+
{
437+
"key": "use_existing_registry_secret"
438+
},
436439
{
437440
"key": "kibana_registry_namespace_image"
438441
},
@@ -442,6 +445,21 @@
442445
{
443446
"key": "kibana_image_port"
444447
},
448+
{
449+
"key": "kibana_image_secret"
450+
},
451+
{
452+
"key": "kibana_registry_personal_access_token"
453+
},
454+
{
455+
"key": "kibana_registry_server"
456+
},
457+
{
458+
"key": "kibana_registry_username"
459+
},
460+
{
461+
"key": "use_private_registry"
462+
},
445463
{
446464
"key": "kibana_visibility",
447465
"options": [

solutions/fully-configurable/main.tf

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -432,19 +432,32 @@ module "code_engine_kibana" {
432432
resource_group_id = module.resource_group.resource_group_id
433433
project_name = local.code_engine_project_name
434434
existing_project_id = local.code_engine_project_id
435-
secrets = {
436-
"es-secret" = {
437-
format = "generic"
438-
data = {
439-
"ELASTICSEARCH_PASSWORD" = local.admin_pass
435+
secrets = merge(
436+
{
437+
"es-secret" = {
438+
format = "generic"
439+
data = {
440+
"ELASTICSEARCH_PASSWORD" = local.admin_pass
441+
}
440442
}
441-
}
442-
}
443+
},
444+
var.use_private_registry && !var.use_existing_registry_secret ? {
445+
"registry-secret" = {
446+
format = "registry"
447+
data = {
448+
username = var.kibana_registry_username
449+
password = var.kibana_registry_personal_access_token
450+
server = var.kibana_registry_server
451+
}
452+
}
453+
} : {}
454+
)
443455

444456
apps = {
445457
(local.code_engine_app_name) = {
446458
image_reference = var.kibana_image_digest != null ? "${var.kibana_registry_namespace_image}@${var.kibana_image_digest}" : "${var.kibana_registry_namespace_image}:${local.kibana_version}"
447459
image_port = var.kibana_image_port
460+
image_secret = var.use_private_registry ? (var.use_existing_registry_secret ? var.kibana_image_secret : "registry-secret") : null
448461
run_env_variables = [{
449462
type = "literal"
450463
name = "ELASTICSEARCH_HOSTS"

solutions/fully-configurable/variables.tf

Lines changed: 59 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,12 @@ variable "admin_pass_secrets_manager_secret_name" {
443443
}
444444
}
445445

446+
variable "use_existing_registry_secret" {
447+
description = "Set to true to use an existing image registry secret instead of creating a new one."
448+
type = bool
449+
default = false
450+
}
451+
446452
##############################################################
447453
# Kibana Configuration
448454
##############################################################
@@ -471,12 +477,31 @@ variable "enable_kibana_dashboard" {
471477
default = false
472478
}
473479

480+
variable "use_private_registry" {
481+
description = "Set to true if the Kibana image is being pulled from a private registry."
482+
type = bool
483+
default = false
484+
}
485+
474486
variable "kibana_registry_namespace_image" {
475487
type = string
476488
description = "The Kibana image reference in the format of `[registry-url]/[namespace]/[image]`. This value is used only when `enable_kibana_dashboard` is set to true."
477489
default = "docker.elastic.co/kibana/kibana"
478490
}
479491

492+
variable "kibana_registry_server" {
493+
type = string
494+
description = "The server URL of the container registry used to pull the Kibana image."
495+
default = "https://index.docker.io/v1/"
496+
validation {
497+
condition = (
498+
!(var.use_private_registry && !var.use_existing_registry_secret)
499+
|| (var.kibana_registry_server != null && var.kibana_registry_server != "")
500+
)
501+
error_message = "The `kibana_registry_server` must not be null or empty when `use_private_registry` is true and `use_existing_registry_secret` is false."
502+
}
503+
}
504+
480505
variable "kibana_image_digest" {
481506
type = string
482507
description = "When `enable_kibana_dashboard` is set to true, Kibana is deployed using an image tag compatible with the Elasticsearch version. Alternatively, an image digest in the format `sha256:xxxxx...` can also be specified but it must correspond to a version compatible with the Elasticsearch instance."
@@ -485,15 +510,20 @@ variable "kibana_image_digest" {
485510
condition = var.kibana_image_digest == null || can(regex("^sha256:", var.kibana_image_digest))
486511
error_message = "If provided, the value of kibana_image_digest must start with 'sha256:'."
487512
}
488-
489-
490513
}
514+
491515
variable "kibana_image_port" {
492516
description = "Specify the port number used to connect to the Kibana service exposed by the container image. Default port is 5601 and it is only applicable if `enable_kibana_dashboard` is true"
493517
type = number
494518
default = 5601
495519
}
496520

521+
variable "kibana_image_secret" {
522+
description = "The name of the image registry access secret."
523+
type = string
524+
default = null
525+
}
526+
497527
variable "kibana_visibility" {
498528
description = "Specify the visibility of Kibana application in order to define which endpoint is available for receiving the requests. Valid values are 'local_public', 'local_private' and 'local' and it is only applicable if `enable_kibana_dashboard` is true. [Learn more](https://github.com/terraform-ibm-modules/terraform-ibm-icd-elasticsearch/blob/main/solutions/fully-configurable/DA-types.md#options-for-kibana_visibility)."
499529
type = string
@@ -504,6 +534,33 @@ variable "kibana_visibility" {
504534
}
505535
}
506536

537+
variable "kibana_registry_username" {
538+
description = "Username for the for the container registry."
539+
type = string
540+
default = null
541+
validation {
542+
condition = (
543+
!(var.use_private_registry && !var.use_existing_registry_secret)
544+
|| (var.kibana_registry_username != null && var.kibana_registry_username != "")
545+
)
546+
error_message = "The `kibana_registry_username` must not be null or empty when `use_private_registry` is true and `use_existing_registry_secret` is false."
547+
}
548+
}
549+
550+
variable "kibana_registry_personal_access_token" {
551+
description = "Pesonal access token for the container registry."
552+
type = string
553+
default = null
554+
sensitive = true
555+
validation {
556+
condition = (
557+
!(var.use_private_registry && !var.use_existing_registry_secret)
558+
|| (var.kibana_registry_personal_access_token != null && var.kibana_registry_personal_access_token != "")
559+
)
560+
error_message = "The `kibana_registry_personal_access_token` must not be null or empty when `use_private_registry` is true and `use_existing_registry_secret` is false."
561+
}
562+
}
563+
507564
##############################################################
508565
# Context-based restriction (CBR)
509566
##############################################################

tests/pr_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ func TestRunFullyConfigurableSolutionSchematics(t *testing.T) {
9393
},
9494
},
9595
}
96-
9796
options.TerraformVars = []testschematic.TestSchematicTerraformVar{
9897
{Name: "ibmcloud_api_key", Value: options.RequiredEnvironmentVars["TF_VAR_ibmcloud_api_key"], DataType: "string", Secure: true},
9998
{Name: "access_tags", Value: permanentResources["accessTags"], DataType: "list(string)"},

0 commit comments

Comments
 (0)