From e1662a5873abd458dc973613700f45f03f45b5c9 Mon Sep 17 00:00:00 2001 From: Paritosh Paliwal Date: Wed, 20 Nov 2024 19:29:11 +0530 Subject: [PATCH] Custom Domain Input; OKE Status check; Optional Custom input before helm install (#98) Custom Domain Input; OKE Status check; Optional Custom input before helm install --- CHANGELOG.md | 6 ++ charts/logan/Chart.yaml | 2 +- charts/logan/templates/discovery-cronjob.yaml | 8 ++- .../logan/templates/ekscp-logs-configmap.yaml | 3 + charts/logan/templates/logs-configmap.yaml | 3 + charts/logan/values.yaml | 7 +- charts/oci-onm/Chart.yaml | 2 +- charts/oci-onm/values.yaml | 6 +- terraform/modules/helm/helm-inputs.tf | 10 +++ terraform/modules/helm/helm-outputs.tf | 6 +- terraform/modules/helm/helm.tf | 10 +-- terraform/modules/logan/logan.tf | 2 +- terraform/modules/main/developer-options.tf | 6 -- terraform/modules/main/main-inputs.tf | 6 ++ terraform/modules/main/main.tf | 17 +---- terraform/oke/providers.tf | 5 +- terraform/oke/resources/metadata.sh | 12 ++++ terraform/oke/resources/oke-status-check.sh | 50 ++++++++++++++ terraform/oke/ruby_sdk_regions.tf | 69 +++++++++++++++++++ terraform/oke/schema.yaml | 15 +++- terraform/oke/stack-inputs.tf | 11 +++ terraform/oke/stack-required-providers.tf | 8 +++ terraform/oke/stack.tf | 44 +++++++++++- terraform/oke/version.auto.tfvars | 2 +- util/build_stack.sh | 20 ++++-- 25 files changed, 285 insertions(+), 45 deletions(-) create mode 100644 terraform/oke/resources/metadata.sh create mode 100644 terraform/oke/resources/oke-status-check.sh create mode 100644 terraform/oke/ruby_sdk_regions.tf diff --git a/CHANGELOG.md b/CHANGELOG.md index 71813f9..42b3d30 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Change Log +## 2024-11-20 +### Added +- Support for new OCI Regions which are not yet supported through OCI Ruby SDK by default. +- Status check for OKE lifecycle state to be active before installing helm chart, when installed using RMS. +- An option to apply a static delay before installing helm chart, when installed using RMS. + ## 2024-11-05 ### Added - Support of extraEnv for Management Agent diff --git a/charts/logan/Chart.yaml b/charts/logan/Chart.yaml index 1feeada..9c51ec7 100644 --- a/charts/logan/Chart.yaml +++ b/charts/logan/Chart.yaml @@ -5,7 +5,7 @@ apiVersion: v2 name: oci-onm-logan description: Charts for sending Kubernetes platform logs, compute logs, and Kubernetes Objects information to OCI Logging Analytics. type: application -version: 3.5.1 +version: 3.5.2 appVersion: "3.0.0" dependencies: diff --git a/charts/logan/templates/discovery-cronjob.yaml b/charts/logan/templates/discovery-cronjob.yaml index ccd595f..85969fc 100644 --- a/charts/logan/templates/discovery-cronjob.yaml +++ b/charts/logan/templates/discovery-cronjob.yaml @@ -71,12 +71,18 @@ spec: {{- end }} {{- end }} {{- /* optional discovery job configuration */}} - {{- if and .Values.ociLAClusterEntityID $resourceNamePrefix }} + {{- if .Values.ociLAClusterEntityID }} - --oci_la_cluster_entity_id - {{ .Values.ociLAClusterEntityID }} + {{- end }} + {{- if $resourceNamePrefix }} - --kubernetes_resourcename_prefix - {{ $resourceNamePrefix }} {{- end }} + {{- if .Values.ociDomain }} + - --oci_domain + - {{ .Values.ociDomain }} + {{- end }} {{- if .Values.k8sDiscovery.objects.discoveryMode }} - --discovery - {{ .Values.k8sDiscovery.objects.discoveryMode }} diff --git a/charts/logan/templates/ekscp-logs-configmap.yaml b/charts/logan/templates/ekscp-logs-configmap.yaml index a6b170d..fd74756 100644 --- a/charts/logan/templates/ekscp-logs-configmap.yaml +++ b/charts/logan/templates/ekscp-logs-configmap.yaml @@ -290,6 +290,9 @@ data: config_file_location {{ $.Values.oci.path }}/{{ $.Values.oci.file }} profile_name "{{ $.Values.fluentd.ociLoggingAnalyticsOutputPlugin.profile_name }}" {{- end }} + {{- if $.Values.ociDomain }} + oci_domain "{{ $.Values.ociDomain }}" + {{- end }} plugin_log_location "{{ $.Values.fluentd.baseDir }}" plugin_log_level "{{ $.Values.fluentd.ociLoggingAnalyticsOutputPlugin.plugin_log_level }}" plugin_log_file_size "{{ $.Values.fluentd.ociLoggingAnalyticsOutputPlugin.plugin_log_file_size }}" diff --git a/charts/logan/templates/logs-configmap.yaml b/charts/logan/templates/logs-configmap.yaml index 513e64d..210ecac 100644 --- a/charts/logan/templates/logs-configmap.yaml +++ b/charts/logan/templates/logs-configmap.yaml @@ -609,6 +609,9 @@ data: config_file_location {{ $.Values.oci.path }}/{{ $.Values.oci.file }} profile_name "{{ $.Values.fluentd.ociLoggingAnalyticsOutputPlugin.profile_name }}" {{- end }} + {{- if $.Values.ociDomain }} + oci_domain "{{ $.Values.ociDomain }}" + {{- end }} plugin_log_location "{{ $.Values.fluentd.baseDir }}" plugin_log_level "{{ $.Values.fluentd.ociLoggingAnalyticsOutputPlugin.plugin_log_level }}" plugin_log_file_size "{{ $.Values.fluentd.ociLoggingAnalyticsOutputPlugin.plugin_log_file_size }}" diff --git a/charts/logan/values.yaml b/charts/logan/values.yaml index dd4e959..8da87c0 100644 --- a/charts/logan/values.yaml +++ b/charts/logan/values.yaml @@ -35,6 +35,11 @@ runtime: cri # -- Allowed values: InstancePrincipal, config authtype: InstancePrincipal +# This parameter is required only for realms where the OCI Ruby SDK is not supported. +# Format: .oci. +# Example: us-ashburn-1.oci.oraclecloud.com +ociDomain: + # -- Kubernetes Namespace for deploying monitoring resources deployed by this chart. namespace: "{{ .Values.global.namespace }}" @@ -48,7 +53,7 @@ image: # Image pull secrets for. Secret must be in the namespace defined by namespace imagePullSecrets: # -- Replace this value with actual docker image url - url: container-registry.oracle.com/oci_observability_management/oci-la-fluentd-collector:1.5.1 + url: container-registry.oracle.com/oci_observability_management/oci-la-fluentd-collector:1.5.2 # -- Image pull policy imagePullPolicy: Always diff --git a/charts/oci-onm/Chart.yaml b/charts/oci-onm/Chart.yaml index 166cec9..bcd728a 100644 --- a/charts/oci-onm/Chart.yaml +++ b/charts/oci-onm/Chart.yaml @@ -32,7 +32,7 @@ dependencies: repository: "file://../common" condition: oci-onm-common.enabled - name: oci-onm-logan - version: "3.5.1" + version: "3.5.2" repository: "file://../logan" condition: oci-onm-logan.enabled - name: oci-onm-mgmt-agent diff --git a/charts/oci-onm/values.yaml b/charts/oci-onm/values.yaml index 33bb6b3..09f6106 100644 --- a/charts/oci-onm/values.yaml +++ b/charts/oci-onm/values.yaml @@ -31,13 +31,17 @@ oci-onm-logan: kubernetesClusterID: "{{ .Values.global.kubernetesClusterID }}" kubernetesClusterName: "{{ .Values.global.kubernetesClusterName }}" image: - url: container-registry.oracle.com/oci_observability_management/oci-la-fluentd-collector:1.5.1 + url: container-registry.oracle.com/oci_observability_management/oci-la-fluentd-collector:1.5.2 # Go to OCI Logging Analytics Administration, click Service Details, and note the namespace value. ociLANamespace: # OCI Logging Analytics Default Log Group OCID ociLALogGroupID: # OCI Logging Analytics Entity OCID representing the target cluster ociLAClusterEntityID: + # This parameter is required only for realms where the OCI Ruby SDK is not supported. + # Format: .oci. + # Example: us-ashburn-1.oci.oraclecloud.com + ociDomain: oci-onm-mgmt-agent: oci-onm-common: diff --git a/terraform/modules/helm/helm-inputs.tf b/terraform/modules/helm/helm-inputs.tf index 0a3f442..0b1097a 100644 --- a/terraform/modules/helm/helm-inputs.tf +++ b/terraform/modules/helm/helm-inputs.tf @@ -109,6 +109,16 @@ variable "livelab_service_account" { default = "" } +#### +## OCI Client Config +#### + +# OCI domain +variable "oci_domain" { + type = string + default = null +} + #### ## Others #### diff --git a/terraform/modules/helm/helm-outputs.tf b/terraform/modules/helm/helm-outputs.tf index 0225c48..ccfdeb7 100644 --- a/terraform/modules/helm/helm-outputs.tf +++ b/terraform/modules/helm/helm-outputs.tf @@ -5,7 +5,7 @@ locals { cmd_1_helm_repo_add = "helm repo add oci-onm https://oracle-quickstart.github.io/oci-kubernetes-monitoring" cmd_2_helm_repo_update = "helm repo update" - cmd_3_helm_install = join(" ", [ + cmd_3_layer_0 = join(" ", [ "helm install oci-kubernetes-monitoring oci-onm/oci-onm", "--set global.namespace=${var.kubernetes_namespace}", "--set global.kubernetesClusterID=${var.kubernetes_cluster_id}", @@ -16,6 +16,10 @@ locals { "--set oci-onm-mgmt-agent.deployMetricServer=${var.opt_deploy_metric_server}", "--set oci-onm-mgmt-agent.mgmtagent.installKeyFileContent=${var.mgmt_agent_install_key_content}" ]) + + cmd_3_layer_1 = var.oci_domain == null ? local.cmd_3_layer_0 : "${local.cmd_3_layer_0} --set oci-onm-logan.ociDomain=${var.oci_domain}" + + cmd_3_helm_install = local.cmd_3_layer_1 } # Helm release artifacts for local testing and validation. diff --git a/terraform/modules/helm/helm.tf b/terraform/modules/helm/helm.tf index 5aa1d0e..bf35a51 100644 --- a/terraform/modules/helm/helm.tf +++ b/terraform/modules/helm/helm.tf @@ -29,12 +29,6 @@ locals { "oci-onm-mgmt-agent.mgmtagent.installKeyFileContent" = var.mgmt_agent_install_key_content "oci-onm-mgmt-agent.deployMetricServer" = var.opt_deploy_metric_server } - - mushop_helm_inputs = { - # oci-onm-logan - "createServiceAccount" = false - "serviceAccount" = var.livelab_service_account - } } # Create helm release @@ -59,7 +53,7 @@ resource "helm_release" "oci-kubernetes-monitoring" { } dynamic "set" { - for_each = var.deploy_mushop_config ? local.mushop_helm_inputs : {} + for_each = var.oci_domain == null ? {} : { "oci-onm-logan.ociDomain" = var.oci_domain } content { name = set.key value = set.value @@ -90,7 +84,7 @@ data "helm_template" "oci-kubernetes-monitoring" { } dynamic "set" { - for_each = var.deploy_mushop_config ? local.mushop_helm_inputs : {} + for_each = var.oci_domain == null ? {} : { "oci-onm-logan.ociDomain" = var.oci_domain } content { name = set.key value = set.value diff --git a/terraform/modules/logan/logan.tf b/terraform/modules/logan/logan.tf index d9adfc4..656ff25 100644 --- a/terraform/modules/logan/logan.tf +++ b/terraform/modules/logan/logan.tf @@ -87,7 +87,7 @@ resource "oci_log_analytics_log_analytics_entity" "oke_entity" { freeform_tags = var.tags.freeformTags lifecycle { - ignore_changes = [name, metadata, defined_tags, freeform_tags, ] + ignore_changes = [name, metadata, defined_tags, freeform_tags] # Not a User Facing Error precondition { condition = !(var.new_entity_name == null && var.oke_entity_ocid == null) diff --git a/terraform/modules/main/developer-options.tf b/terraform/modules/main/developer-options.tf index 2dcf4eb..e28de3d 100644 --- a/terraform/modules/main/developer-options.tf +++ b/terraform/modules/main/developer-options.tf @@ -6,12 +6,6 @@ ## Leave it to default for production use #### -# Enable/Disable livelab module -variable "toggle_livelab_module" { - type = bool - default = true -} - # Enable/Disable helm module variable "toggle_helm_module" { type = bool diff --git a/terraform/modules/main/main-inputs.tf b/terraform/modules/main/main-inputs.tf index d5cf547..d1e1345 100644 --- a/terraform/modules/main/main-inputs.tf +++ b/terraform/modules/main/main-inputs.tf @@ -124,6 +124,12 @@ variable "kubernetes_namespace" { default = "oci-onm" } +# OCI domain +variable "oci_domain" { + type = string + default = null +} + # Kubernetes Cluster OCID variable "kubernetes_cluster_id" { type = string diff --git a/terraform/modules/main/main.tf b/terraform/modules/main/main.tf index 2958beb..68a4491 100644 --- a/terraform/modules/main/main.tf +++ b/terraform/modules/main/main.tf @@ -128,7 +128,7 @@ module "helm_release" { mgmt_agent_install_key_content = module.management_agent[0].mgmt_agent_install_key_content opt_deploy_metric_server = var.opt_deploy_metric_server fluentd_base_dir_path = var.fluentd_base_dir_path - # livelab_service_account = local.livelab_service_account + oci_domain = var.oci_domain } # Import Kubernetes Dashboards @@ -140,18 +140,3 @@ module "import_kubernetes_dashboards" { debug = var.debug tags = var.tags } - -# // Only execute for livelab stack -# // livelab module only supports local users -# // it will error out when an identity domain user is used and livelab_switch is set as true -# module "livelab" { -# source = "./modules/livelab" -# current_user_ocid = var.current_user_ocid -# debug = var.debug - -# count = local.module_controls_enable_livelab_module ? 1 : 0 - -# /* providers = { -# oci = oci.home_region -# } */ -# } \ No newline at end of file diff --git a/terraform/oke/providers.tf b/terraform/oke/providers.tf index 5022aed..6ac31fe 100644 --- a/terraform/oke/providers.tf +++ b/terraform/oke/providers.tf @@ -41,6 +41,7 @@ data "oci_identity_regions" "region_map" { data "oci_containerengine_cluster_kube_config" "oke" { cluster_id = var.oke_cluster_ocid + depends_on = [null_resource.wait-for-oke-active-status[0]] } provider "oci" { @@ -74,4 +75,6 @@ provider "helm" { } } -provider "local" {} \ No newline at end of file +provider "local" {} + +provider "external" {} diff --git a/terraform/oke/resources/metadata.sh b/terraform/oke/resources/metadata.sh new file mode 100644 index 0000000..a8407f5 --- /dev/null +++ b/terraform/oke/resources/metadata.sh @@ -0,0 +1,12 @@ +#!/bin/bash +# Copyright (c) 2024, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v1.0 as shown at https://oss.oracle.com/licenses/upl. +set -e +curl -H "Authorization: Bearer Oracle" -sL http://169.254.169.254/opc/v2/instance/ | jq .regionInfo +# example output => +# echo '{ +# "realmDomainComponent": "oraclecloud.com", +# "realmKey": "oc1", +# "regionIdentifier": "us-phoenix-1", +# "regionKey": "PHX" +# }' \ No newline at end of file diff --git a/terraform/oke/resources/oke-status-check.sh b/terraform/oke/resources/oke-status-check.sh new file mode 100644 index 0000000..7236777 --- /dev/null +++ b/terraform/oke/resources/oke-status-check.sh @@ -0,0 +1,50 @@ +#!/bin/bash +# Copyright (c) 2024, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v1.0 as shown at https://oss.oracle.com/licenses/upl. + +############################################################ +## +## Check the lifecycle-state of OKE cluster [$OKE_OCID] +## every $CHECK_INTERVAL seconds +## untill +## - lifecycle state is "ACTIVE" +## or +## - time limit $WAIT_TIME is breached +## +## exit with status 0, iff lifecycle-state is "ACTIVE", +## otherwise exit with status 1 +## +############################################################ + +# Exit on error +set -e + +# Inputs from ENV is preferred over CLI +if [ -z "${WAIT_TIME}" ]; then WAIT_TIME=$1; fi +if [ -z "${CHECK_INTERVAL}" ]; then CHECK_INTERVAL=$2; fi +if [ -z "${OKE_OCID}" ]; then OKE_OCID=$3; fi + +timer=0 + +while true; +do + oke_status=$(oci ce cluster get --cluster-id "$OKE_OCID" --query 'data."lifecycle-state"' --raw-output) + echo -e "OKE status: $oke_status" + + if [[ "$oke_status" == "ACTIVE" ]]; then + echo -e "Returning with success." + break; + fi + + echo -e "Next check scheduled after seconds: $CHECK_INTERVAL" + sleep "$CHECK_INTERVAL" + + (( timer = timer + CHECK_INTERVAL )) + if [ $timer -ge "$WAIT_TIME" ]; then + echo -e "Timeout limit breached: $WAIT_TIME" + echo -e "ERROR: OKE status is not ACTIVE." + exit 1 + fi +done + +exit 0 \ No newline at end of file diff --git a/terraform/oke/ruby_sdk_regions.tf b/terraform/oke/ruby_sdk_regions.tf new file mode 100644 index 0000000..0e34a71 --- /dev/null +++ b/terraform/oke/ruby_sdk_regions.tf @@ -0,0 +1,69 @@ + +# source: https://github.com/oracle/oci-ruby-sdk/blob/v2.21.1/lib/oci/regions_definitions.rb +# ruby SDK version: 2.21.1 +locals { + ruby_sdk_supported_regions = [ + "ap-chuncheon-1", + "ap-hyderabad-1", + "ap-melbourne-1", + "ap-mumbai-1", + "ap-osaka-1", + "ap-seoul-1", + "ap-sydney-1", + "ap-tokyo-1", + "ca-montreal-1", + "ca-toronto-1", + "eu-amsterdam-1", + "eu-frankfurt-1", + "eu-zurich-1", + "me-jeddah-1", + "me-dubai-1", + "sa-saopaulo-1", + "uk-cardiff-1", + "uk-london-1", + "us-ashburn-1", + "us-phoenix-1", + "us-sanjose-1", + "sa-vinhedo-1", + "sa-santiago-1", + "il-jerusalem-1", + "eu-marseille-1", + "ap-singapore-1", + "me-abudhabi-1", + "eu-milan-1", + "eu-stockholm-1", + "af-johannesburg-1", + "eu-paris-1", + "mx-queretaro-1", + "eu-madrid-1", + "us-chicago-1", + "mx-monterrey-1", + "us-saltlake-2", + "sa-bogota-1", + "sa-valparaiso-1", + "us-langley-1", + "us-luke-1", + "us-gov-ashburn-1", + "us-gov-chicago-1", + "us-gov-phoenix-1", + "uk-gov-london-1", + "uk-gov-cardiff-1", + "ap-chiyoda-1", + "ap-ibaraki-1", + "me-dcc-muscat-1", + "ap-dcc-canberra-1", + "eu-dcc-milan-1", + "eu-dcc-milan-2", + "eu-dcc-dublin-2", + "eu-dcc-rating-2", + "eu-dcc-rating-1", + "eu-dcc-dublin-1", + "ap-dcc-gazipur-1", + "eu-madrid-2", + "eu-frankfurt-2", + "eu-jovanovac-1", + "me-dcc-doha-1", + "eu-dcc-zurich-1", + "me-abudhabi-3" + ] +} \ No newline at end of file diff --git a/terraform/oke/schema.yaml b/terraform/oke/schema.yaml index cf19150..2d1bef8 100644 --- a/terraform/oke/schema.yaml +++ b/terraform/oke/schema.yaml @@ -29,7 +29,8 @@ variableGroups: - ${boat_tenancy_ocid} - ${compartment_ocid} - ${current_user_ocid} - - ${oke_cluster_name} + - ${oke_cluster_name} + - ${toggle_use_local_helm_chart} visible: false # These variables are utilized for QA validation and testing. They are not meant to be used in production. @@ -67,9 +68,11 @@ variableGroups: - ${opt_deploy_metric_server} - ${helm_chart_version} - ${fluentd_base_dir_path} + - ${delay_in_seconds} - ${tags} - ${template_id} + variables: #### [Section] @@ -287,6 +290,16 @@ variables: and: - ${show_advanced_options} + # Delay in seconds + delay_in_seconds: + type: number + title: Delay in seconds + description: |- + Adds custom delay in seconds before creating resources + visible: + and: + - ${show_advanced_options} + # OCI tags tags: description: |- diff --git a/terraform/oke/stack-inputs.tf b/terraform/oke/stack-inputs.tf index acb6eef..b6f2a29 100644 --- a/terraform/oke/stack-inputs.tf +++ b/terraform/oke/stack-inputs.tf @@ -222,6 +222,12 @@ variable "tags" { default = { "freeformTags" = {}, "definedTags" = {} } } +# delay - adds wait (seconds) before creating resources +variable "delay_in_seconds" { + type = number + default = 0 +} + # This var is not used in stack # Purpose: to display stack version on UI without being able to execute it variable "template_id" { @@ -233,6 +239,11 @@ variable "template_id" { ## Development Options #### +variable "toggle_use_local_helm_chart" { + type = string + default = false +} + # Ref - https://confluence.oci.oraclecorp.com/display/TERSI/FAQs#FAQs-Q.HowdoItestonPre-ProdenvironmentORHowdoImakeTerraformproviderpointtocustomControlPlane(CP)endpoint variable "CLIENT_HOST_OVERRIDES" { diff --git a/terraform/oke/stack-required-providers.tf b/terraform/oke/stack-required-providers.tf index cd71552..8de3357 100644 --- a/terraform/oke/stack-required-providers.tf +++ b/terraform/oke/stack-required-providers.tf @@ -16,5 +16,13 @@ terraform { source = "hashicorp/local" version = "~> 2.5.1" } + time = { + source = "hashicorp/time" + version = "0.12.0" + } + external = { + source = "hashicorp/external" + version = "2.3.4" + } } } \ No newline at end of file diff --git a/terraform/oke/stack.tf b/terraform/oke/stack.tf index 3be5847..11c8cef 100644 --- a/terraform/oke/stack.tf +++ b/terraform/oke/stack.tf @@ -2,6 +2,11 @@ # Licensed under the Universal Permissive License v1.0 as shown at https://oss.oracle.com/licenses/upl. locals { + # OKE Status Check Script Params + oke_status_check = true + timeout = 600 + interval = 60 + # Resolve Null string --> "" inputs oke_cluster_entity_ocid = var.oke_cluster_entity_ocid == "" ? null : var.oke_cluster_entity_ocid helm_chart_version = var.helm_chart_version == "" ? null : var.helm_chart_version @@ -30,12 +35,43 @@ locals { all_clusters_in_compartment = data.oci_containerengine_clusters.oke_clusters.clusters cluster_data = [for c in local.all_clusters_in_compartment : c if c.id == var.oke_cluster_ocid][0] + + # Dev Only Input; Keep it - false in production + ruby_sdk_not_available_test = false + + is_ruby_sdk_supported = local.ruby_sdk_not_available_test ? false : contains(local.ruby_sdk_supported_regions, var.region) + + domain = local.is_ruby_sdk_supported ? null : data.external.metadata[0].result.realmDomainComponent + oci_domain = local.is_ruby_sdk_supported ? null : "${var.region}.oci.${local.domain}" } data "oci_containerengine_clusters" "oke_clusters" { compartment_id = var.oke_compartment_ocid } +data "external" "metadata" { + count = local.is_ruby_sdk_supported ? 0 : 1 + program = ["bash", "${path.module}/resources/metadata.sh"] +} + +resource "null_resource" "wait-for-oke-active-status" { + count = local.oke_status_check ? 1 : 0 + provisioner "local-exec" { + command = "bash ${path.module}/resources/oke-status-check.sh" + environment = { + WAIT_TIME = local.timeout + CHECK_INTERVAL = local.interval + OKE_OCID = var.oke_cluster_ocid + } + working_dir = path.module + } +} + +resource "time_sleep" "wait" { + depends_on = [null_resource.wait-for-oke-active-status] + create_duration = "${floor(var.delay_in_seconds)}s" +} + # Create a new private endpoint or uses an existing one # Returns a reachable ip address to access private OKE cluster module "rms_private_endpoint" { @@ -50,6 +86,8 @@ module "rms_private_endpoint" { tags = var.tags debug = false + + depends_on = [time_sleep.wait] } # Create OCI resources for the helm chart @@ -90,7 +128,9 @@ module "main" { fluentd_base_dir_path = var.fluentd_base_dir_path kubernetes_cluster_id = var.oke_cluster_ocid kubernetes_cluster_name = local.oke_cluster_name - path_to_local_onm_helm_chart = "../../../charts/oci-onm/" + path_to_local_onm_helm_chart = "${path.module}/charts/oci-onm/" + oci_domain = local.oci_domain + toggle_use_local_helm_chart = var.toggle_use_local_helm_chart # As two sets of OCI providers are required in child module (main), we must pass all providers explicitly # Ref - https://developer.hashicorp.com/terraform/language/modules/develop/providers#passing-providers-explicitly @@ -100,4 +140,6 @@ module "main" { local = local helm = helm } + + depends_on = [time_sleep.wait] } diff --git a/terraform/oke/version.auto.tfvars b/terraform/oke/version.auto.tfvars index cc365b8..d514ce9 100644 --- a/terraform/oke/version.auto.tfvars +++ b/terraform/oke/version.auto.tfvars @@ -4,4 +4,4 @@ # The "template_id" is only to identity the version of template in a particular production region. # This version does not control the version of the template to be used by the stack. # TODO: This must be incremented with every release of stack to OCI RMS template. -template_id = "0007" \ No newline at end of file +template_id = "0008" \ No newline at end of file diff --git a/util/build_stack.sh b/util/build_stack.sh index 1167388..2c5ad90 100755 --- a/util/build_stack.sh +++ b/util/build_stack.sh @@ -8,6 +8,7 @@ set -e SILENT_MODE=false +GENERATE_BASE64_ARTIFACT=false function log { if [ "$SILENT_MODE" = false ]; then @@ -46,7 +47,7 @@ MODULES_SYMLINK="$STACK_BUILD_PATH/modules" # Usage Instructions usage=" -$(basename "$0") [-h][-n name][-l][-d][-s] -- program to build OCI RMS stack zip file using oracle-quickstart/oci-kubernetes-monitoring repo. +$(basename "$0") [-h][-n name][-l][-d][-s][-b] -- program to build OCI RMS stack zip file using oracle-quickstart/oci-kubernetes-monitoring repo. where: -h show this help text @@ -54,12 +55,13 @@ where: -l flag to generate livelab build; otherwise oke build is generated -d flag to generate dev build; contains local helm chart -s flag to turn-off output; only final build file path is printed to stdout + -b flag to generate additional base64 string of stack The zip artifacts shall be stored at - $RELEASE_PATH" # Parse inputs -while getopts "hn:lds" option; do +while getopts "hn:ldsb" option; do case $option in h) # display Help echo "$usage" @@ -77,6 +79,9 @@ while getopts "hn:lds" option; do s) # Run SILENT_MODE SILENT_MODE=true ;; + b) # Run SILENT_MODE + GENERATE_BASE64_ARTIFACT=true + ;; :) printf "missing argument for -%s\n" "$OPTARG" >&2 echo "$usage" >&2 exit 1 @@ -110,6 +115,7 @@ if test -z "${release_name}"; then fi RELEASE_ZIP="${RELEASE_PATH}/${release_name}.zip" +BASE64_ARTIFACT="${RELEASE_PATH}/${release_name}.base64" # Disclaimer log "\nDisclaimers - \n" @@ -135,8 +141,9 @@ if test ! -d "$RELEASE_PATH"; then log "Created release direcotory - \$PROJECT_HOME/releases" fi -# Clean up old zip -rm "${RELEASE_ZIP}" 2>/dev/null && log "Removed old stack - ${RELEASE_ZIP}" +# Clean up old artifacts +rm "${RELEASE_ZIP}" 2>/dev/null && log "Removed old zip artifact - ${RELEASE_ZIP}" +rm "${BASE64_ARTIFACT}" 2>/dev/null && log "Removed old base64 artifact - ${BASE64_ARTIFACT}" # Switch to project's root for git archive cd "$ROOT_DIR" || error_and_exit "ERROR: cd $ROOT_DIR" @@ -190,6 +197,11 @@ cd "$RELEASE_PATH" || error_and_exit "ERROR: cd $RELEASE_PATH" rm "$BUILD_ZIP" 2>/dev/null || error_and_exit "ERROR: rm $BUILD_ZIP" rm -rf "$BUILD_DIR" 2>/dev/null || error_and_exit "ERROR: rm -rf $BUILD_DIR" +if [[ $GENERATE_BASE64_ARTIFACT = true ]]; then + base64 -i "$RELEASE_ZIP" > "$BASE64_ARTIFACT" + log "Base64 Artifact - $BASE64_ARTIFACT" # stdout +fi + if [[ $SILENT_MODE = true ]]; then echo "$RELEASE_ZIP" # stdout fi