Skip to content

Commit 492bada

Browse files
robo-caphyder
authored andcommitted
Add k8sgpt support for the operator host
1 parent 83cb0ea commit 492bada

File tree

4 files changed

+27
-0
lines changed

4 files changed

+27
-0
lines changed

module-operator.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ module "operator" {
6464
install_helm_from_repo = var.operator_install_helm_from_repo
6565
install_oci_cli_from_repo = var.operator_install_oci_cli_from_repo
6666
install_istioctl = var.operator_install_istioctl
67+
install_k8sgpt = var.operator_install_k8sgpt
6768
install_k9s = var.operator_install_k9s
6869
install_kubectx = var.operator_install_kubectx
6970
install_kubectl_from_repo = var.operator_install_kubectl_from_repo

modules/operator/cloudinit.tf

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,25 @@ data "cloudinit_config" "operator" {
137137
}
138138
}
139139

140+
# k8sgpt installation
141+
dynamic "part" {
142+
for_each = var.install_k8sgpt ? [1] : []
143+
content {
144+
content_type = "text/cloud-config"
145+
content = jsonencode({
146+
runcmd = [
147+
"CLI_ARCH='${local.arch_amd}'",
148+
"if [ \"$(uname -m)\" = ${local.arch_arm} ]; then CLI_ARCH='arm64'; fi",
149+
"if [ -f /etc/os-release ]; then os_id=$(grep '^ID=' /etc/os-release | awk -F= '{print $2}' | tr -d '\"'); fi",
150+
"if [ \"$os_id\" == \"ubuntu\" ]; then curl -LO https://github.com/k8sgpt-ai/k8sgpt/releases/latest/download/k8sgpt_$CLI_ARCH.deb; dpkg -i k8sgpt_$CLI_ARCH.deb; rm k8sgpt_$CLI_ARCH.deb; fi",
151+
"if [ \"$os_id\" == \"ol\" ]; then while fuser /var/lib/rpm/.rpm.lock >/dev/null 2>&1; do sleep 5; done; rpm -ivh https://github.com/k8sgpt-ai/k8sgpt/releases/latest/download/k8sgpt_$CLI_ARCH.rpm; fi"
152+
]
153+
})
154+
filename = "20-k8sgpt.yml"
155+
merge_type = local.default_cloud_init_merge_type
156+
}
157+
}
158+
140159
# kubectx/kubens installation
141160
dynamic "part" {
142161
for_each = var.install_kubectx ? [1] : []

modules/operator/variables.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ variable "install_oci_cli_from_repo" { type = bool }
2020
variable "install_helm" { type = bool }
2121
variable "install_helm_from_repo" { type = bool }
2222
variable "install_istioctl" { type = bool }
23+
variable "install_k8sgpt" { type = bool }
2324
variable "install_k9s" { type = bool }
2425
variable "install_kubectl_from_repo" {
2526
type = bool

variables-operator.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,12 @@ variable "operator_install_istioctl" {
8383
type = bool
8484
}
8585

86+
variable "operator_install_k8sgpt" {
87+
default = false
88+
description = "Whether to install k8sgpt on the created operator host. NOTE: Provided only as a convenience and not supported by or sourced from Oracle - use at your own risk."
89+
type = bool
90+
}
91+
8692
variable "operator_install_k9s" {
8793
default = false
8894
description = "Whether to install k9s on the created operator host. NOTE: Provided only as a convenience and not supported by or sourced from Oracle - use at your own risk."

0 commit comments

Comments
 (0)