From 2a71f0d6787cea88a8a99699b8172875a3f098a1 Mon Sep 17 00:00:00 2001 From: dmitchsplunk Date: Wed, 20 Dec 2023 14:21:31 -0800 Subject: [PATCH] updated merge logic --- splunk/opentelemetry-demo.yaml | 154 ++++++++++++++++----------------- splunk/update-demos.sh | 35 ++------ 2 files changed, 85 insertions(+), 104 deletions(-) diff --git a/splunk/opentelemetry-demo.yaml b/splunk/opentelemetry-demo.yaml index 369dce24e8..f49ecaede4 100644 --- a/splunk/opentelemetry-demo.yaml +++ b/splunk/opentelemetry-demo.yaml @@ -8616,6 +8616,10 @@ spec: fieldRef: apiVersion: v1 fieldPath: metadata.labels['app.kubernetes.io/component'] + - name: NODE_IP + valueFrom: + fieldRef: + fieldPath: status.hostIP - name: OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE value: cumulative - name: KAFKA_SERVICE_ADDR @@ -8624,10 +8628,6 @@ spec: value: http://$(NODE_IP):4317 - name: OTEL_RESOURCE_ATTRIBUTES value: service.name=$(OTEL_SERVICE_NAME),service.namespace=opentelemetry-demo,deployment.environment=development - - name: NODE_IP - valueFrom: - fieldRef: - fieldPath: status.hostIP resources: limits: memory: 20Mi @@ -8678,6 +8678,10 @@ spec: fieldRef: apiVersion: v1 fieldPath: metadata.labels['app.kubernetes.io/component'] + - name: NODE_IP + valueFrom: + fieldRef: + fieldPath: status.hostIP - name: OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE value: cumulative - name: AD_SERVICE_PORT @@ -8690,10 +8694,6 @@ spec: value: otlp - name: OTEL_RESOURCE_ATTRIBUTES value: service.name=$(OTEL_SERVICE_NAME),service.namespace=opentelemetry-demo,deployment.environment=development - - name: NODE_IP - valueFrom: - fieldRef: - fieldPath: status.hostIP resources: limits: memory: 300Mi @@ -8737,6 +8737,10 @@ spec: fieldRef: apiVersion: v1 fieldPath: metadata.labels['app.kubernetes.io/component'] + - name: NODE_IP + valueFrom: + fieldRef: + fieldPath: status.hostIP - name: OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE value: cumulative - name: CART_SERVICE_PORT @@ -8751,10 +8755,6 @@ spec: value: http://$(NODE_IP):4317 - name: OTEL_RESOURCE_ATTRIBUTES value: service.name=$(OTEL_SERVICE_NAME),service.namespace=opentelemetry-demo,deployment.environment=development - - name: NODE_IP - valueFrom: - fieldRef: - fieldPath: status.hostIP resources: limits: memory: 160Mi @@ -8805,6 +8805,10 @@ spec: fieldRef: apiVersion: v1 fieldPath: metadata.labels['app.kubernetes.io/component'] + - name: NODE_IP + valueFrom: + fieldRef: + fieldPath: status.hostIP - name: OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE value: cumulative - name: CHECKOUT_SERVICE_PORT @@ -8827,10 +8831,6 @@ spec: value: http://$(NODE_IP):4317 - name: OTEL_RESOURCE_ATTRIBUTES value: service.name=$(OTEL_SERVICE_NAME),service.namespace=opentelemetry-demo,deployment.environment=development - - name: NODE_IP - valueFrom: - fieldRef: - fieldPath: status.hostIP resources: limits: memory: 20Mi @@ -8881,6 +8881,10 @@ spec: fieldRef: apiVersion: v1 fieldPath: metadata.labels['app.kubernetes.io/component'] + - name: NODE_IP + valueFrom: + fieldRef: + fieldPath: status.hostIP - name: OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE value: cumulative - name: CURRENCY_SERVICE_PORT @@ -8889,10 +8893,6 @@ spec: value: http://$(NODE_IP):4317 - name: OTEL_RESOURCE_ATTRIBUTES value: service.name=$(OTEL_SERVICE_NAME),service.namespace=opentelemetry-demo,deployment.environment=development - - name: NODE_IP - valueFrom: - fieldRef: - fieldPath: status.hostIP resources: limits: memory: 20Mi @@ -8936,6 +8936,10 @@ spec: fieldRef: apiVersion: v1 fieldPath: metadata.labels['app.kubernetes.io/component'] + - name: NODE_IP + valueFrom: + fieldRef: + fieldPath: status.hostIP - name: OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE value: cumulative - name: EMAIL_SERVICE_PORT @@ -8946,10 +8950,6 @@ spec: value: http://$(NODE_IP):4318/v1/traces - name: OTEL_RESOURCE_ATTRIBUTES value: service.name=$(OTEL_SERVICE_NAME),service.namespace=opentelemetry-demo,deployment.environment=development - - name: NODE_IP - valueFrom: - fieldRef: - fieldPath: status.hostIP resources: limits: memory: 100Mi @@ -8995,6 +8995,10 @@ spec: fieldRef: apiVersion: v1 fieldPath: metadata.labels['app.kubernetes.io/component'] + - name: NODE_IP + valueFrom: + fieldRef: + fieldPath: status.hostIP - name: OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE value: cumulative - name: FEATURE_FLAG_SERVICE_PORT @@ -9009,10 +9013,6 @@ spec: value: grpc - name: OTEL_RESOURCE_ATTRIBUTES value: service.name=$(OTEL_SERVICE_NAME),service.namespace=opentelemetry-demo,deployment.environment=development - - name: NODE_IP - valueFrom: - fieldRef: - fieldPath: status.hostIP resources: limits: memory: 175Mi @@ -9069,6 +9069,10 @@ spec: fieldRef: apiVersion: v1 fieldPath: metadata.labels['app.kubernetes.io/component'] + - name: NODE_IP + valueFrom: + fieldRef: + fieldPath: status.hostIP - name: OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE value: cumulative - name: POSTGRES_DB @@ -9079,10 +9083,6 @@ spec: value: ffs - name: OTEL_RESOURCE_ATTRIBUTES value: service.name=$(OTEL_SERVICE_NAME),service.namespace=opentelemetry-demo,deployment.environment=development - - name: NODE_IP - valueFrom: - fieldRef: - fieldPath: status.hostIP resources: limits: memory: 120Mi @@ -9127,6 +9127,10 @@ spec: fieldRef: apiVersion: v1 fieldPath: metadata.labels['app.kubernetes.io/component'] + - name: NODE_IP + valueFrom: + fieldRef: + fieldPath: status.hostIP - name: OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE value: cumulative - name: KAFKA_SERVICE_ADDR @@ -9135,10 +9139,6 @@ spec: value: http://$(NODE_IP):4317 - name: OTEL_RESOURCE_ATTRIBUTES value: service.name=$(OTEL_SERVICE_NAME),service.namespace=opentelemetry-demo,deployment.environment=development - - name: NODE_IP - valueFrom: - fieldRef: - fieldPath: status.hostIP resources: limits: memory: 200Mi @@ -9189,6 +9189,10 @@ spec: fieldRef: apiVersion: v1 fieldPath: metadata.labels['app.kubernetes.io/component'] + - name: NODE_IP + valueFrom: + fieldRef: + fieldPath: status.hostIP - name: OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE value: cumulative - name: FRONTEND_PORT @@ -9217,10 +9221,6 @@ spec: value: http://localhost:8080/otlp-http/v1/traces - name: OTEL_RESOURCE_ATTRIBUTES value: service.name=$(OTEL_SERVICE_NAME),service.namespace=opentelemetry-demo,deployment.environment=development - - name: NODE_IP - valueFrom: - fieldRef: - fieldPath: status.hostIP resources: limits: memory: 200Mi @@ -9268,6 +9268,10 @@ spec: fieldRef: apiVersion: v1 fieldPath: metadata.labels['app.kubernetes.io/component'] + - name: NODE_IP + valueFrom: + fieldRef: + fieldPath: status.hostIP - name: OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE value: cumulative - name: ENVOY_PORT @@ -9297,13 +9301,9 @@ spec: - name: OTEL_COLLECTOR_PORT_HTTP value: "4318" - name: OTEL_COLLECTOR_HOST - value: $(OTEL_COLLECTOR_NAME) + value: $(NODE_IP) - name: OTEL_RESOURCE_ATTRIBUTES value: service.name=$(OTEL_SERVICE_NAME),service.namespace=opentelemetry-demo,deployment.environment=development - - name: NODE_IP - valueFrom: - fieldRef: - fieldPath: status.hostIP resources: limits: memory: 50Mi @@ -9353,6 +9353,10 @@ spec: fieldRef: apiVersion: v1 fieldPath: metadata.labels['app.kubernetes.io/component'] + - name: NODE_IP + valueFrom: + fieldRef: + fieldPath: status.hostIP - name: OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE value: cumulative - name: KAFKA_ADVERTISED_LISTENERS @@ -9363,10 +9367,6 @@ spec: value: -Xmx200M -Xms200M - name: OTEL_RESOURCE_ATTRIBUTES value: service.name=$(OTEL_SERVICE_NAME),service.namespace=opentelemetry-demo,deployment.environment=development - - name: NODE_IP - valueFrom: - fieldRef: - fieldPath: status.hostIP resources: limits: memory: 500Mi @@ -9414,6 +9414,10 @@ spec: fieldRef: apiVersion: v1 fieldPath: metadata.labels['app.kubernetes.io/component'] + - name: NODE_IP + valueFrom: + fieldRef: + fieldPath: status.hostIP - name: OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE value: cumulative - name: LOCUST_WEB_PORT @@ -9434,10 +9438,6 @@ spec: value: http://$(NODE_IP):4317 - name: OTEL_RESOURCE_ATTRIBUTES value: service.name=$(OTEL_SERVICE_NAME),service.namespace=opentelemetry-demo,deployment.environment=development - - name: NODE_IP - valueFrom: - fieldRef: - fieldPath: status.hostIP resources: limits: memory: 120Mi @@ -9481,6 +9481,10 @@ spec: fieldRef: apiVersion: v1 fieldPath: metadata.labels['app.kubernetes.io/component'] + - name: NODE_IP + valueFrom: + fieldRef: + fieldPath: status.hostIP - name: OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE value: cumulative - name: PAYMENT_SERVICE_PORT @@ -9489,10 +9493,6 @@ spec: value: http://$(NODE_IP):4317 - name: OTEL_RESOURCE_ATTRIBUTES value: service.name=$(OTEL_SERVICE_NAME),service.namespace=opentelemetry-demo,deployment.environment=development - - name: NODE_IP - valueFrom: - fieldRef: - fieldPath: status.hostIP resources: limits: memory: 120Mi @@ -9540,6 +9540,10 @@ spec: fieldRef: apiVersion: v1 fieldPath: metadata.labels['app.kubernetes.io/component'] + - name: NODE_IP + valueFrom: + fieldRef: + fieldPath: status.hostIP - name: OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE value: cumulative - name: PRODUCT_CATALOG_SERVICE_PORT @@ -9550,10 +9554,6 @@ spec: value: http://$(NODE_IP):4317 - name: OTEL_RESOURCE_ATTRIBUTES value: service.name=$(OTEL_SERVICE_NAME),service.namespace=opentelemetry-demo,deployment.environment=development - - name: NODE_IP - valueFrom: - fieldRef: - fieldPath: status.hostIP resources: limits: memory: 20Mi @@ -9597,6 +9597,10 @@ spec: fieldRef: apiVersion: v1 fieldPath: metadata.labels['app.kubernetes.io/component'] + - name: NODE_IP + valueFrom: + fieldRef: + fieldPath: status.hostIP - name: OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE value: cumulative - name: QUOTE_SERVICE_PORT @@ -9607,10 +9611,6 @@ spec: value: http://$(NODE_IP):4318 - name: OTEL_RESOURCE_ATTRIBUTES value: service.name=$(OTEL_SERVICE_NAME),service.namespace=opentelemetry-demo,deployment.environment=development - - name: NODE_IP - valueFrom: - fieldRef: - fieldPath: status.hostIP resources: limits: memory: 40Mi @@ -9658,6 +9658,10 @@ spec: fieldRef: apiVersion: v1 fieldPath: metadata.labels['app.kubernetes.io/component'] + - name: NODE_IP + valueFrom: + fieldRef: + fieldPath: status.hostIP - name: OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE value: cumulative - name: RECOMMENDATION_SERVICE_PORT @@ -9674,10 +9678,6 @@ spec: value: http://$(NODE_IP):4317 - name: OTEL_RESOURCE_ATTRIBUTES value: service.name=$(OTEL_SERVICE_NAME),service.namespace=opentelemetry-demo,deployment.environment=development - - name: NODE_IP - valueFrom: - fieldRef: - fieldPath: status.hostIP resources: limits: memory: 500Mi @@ -9721,14 +9721,14 @@ spec: fieldRef: apiVersion: v1 fieldPath: metadata.labels['app.kubernetes.io/component'] - - name: OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE - value: cumulative - - name: OTEL_RESOURCE_ATTRIBUTES - value: service.name=$(OTEL_SERVICE_NAME),service.namespace=opentelemetry-demo,deployment.environment=development - name: NODE_IP valueFrom: fieldRef: fieldPath: status.hostIP + - name: OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE + value: cumulative + - name: OTEL_RESOURCE_ATTRIBUTES + value: service.name=$(OTEL_SERVICE_NAME),service.namespace=opentelemetry-demo,deployment.environment=development resources: limits: memory: 20Mi @@ -9776,6 +9776,10 @@ spec: fieldRef: apiVersion: v1 fieldPath: metadata.labels['app.kubernetes.io/component'] + - name: NODE_IP + valueFrom: + fieldRef: + fieldPath: status.hostIP - name: OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE value: cumulative - name: SHIPPING_SERVICE_PORT @@ -9786,10 +9790,6 @@ spec: value: http://$(NODE_IP):4317/v1/traces - name: OTEL_RESOURCE_ATTRIBUTES value: service.name=$(OTEL_SERVICE_NAME),service.namespace=opentelemetry-demo,deployment.environment=development - - name: NODE_IP - valueFrom: - fieldRef: - fieldPath: status.hostIP resources: limits: memory: 20Mi diff --git a/splunk/update-demos.sh b/splunk/update-demos.sh index 6c6449b0dd..3cee18dfa4 100755 --- a/splunk/update-demos.sh +++ b/splunk/update-demos.sh @@ -76,44 +76,25 @@ function update_otel_demo_k8s { yq eval -i 'select(.kind != "Service" or .metadata.name != "opentelemetry-demo-otelcol")' "$SPLUNK_K8S_PATH" yq eval -i 'select(.kind != "Deployment" or .metadata.name != "opentelemetry-demo-otelcol")' "$SPLUNK_K8S_PATH" - # delete the OTEL_COLLECTOR_NAME environment variable from all containers - yq eval -i 'del(.spec.template.spec.containers[].env[] | select(.name == "OTEL_COLLECTOR_NAME"))' "$SPLUNK_K8S_PATH" - - # add a NODE_IP environment variable for all containers + # replace the OTEL_COLLECTOR_NAME environment variable + # with a NODE_IP environment variable for all containers # - name: NODE_IP # valueFrom: # fieldRef: # fieldPath: status.hostIP + # start by replacing the environment variable name + yq eval -i ' (.. | select(tag == "!!str")) |= sub("OTEL_COLLECTOR_NAME", "NODE_IP")' "$SPLUNK_K8S_PATH" - # used due to a yq issue with the below command to do the same thing - SEARCH_VAL=service.namespace=opentelemetry-demo - REPLACE_VAL='service.namespace=opentelemetry-demo \ - - name: NODE_IP \ - valueFrom: \ + # then use sed to replace the value + # (yq was not used due to an issue that added extraneous elements to the file) + SEARCH_VAL="value: 'opentelemetry-demo-otelcol'" + REPLACE_VAL='valueFrom: \ fieldRef: \ fieldPath: status.hostIP' sed -i '' "s/${SEARCH_VAL}/${REPLACE_VAL}/g" "$SPLUNK_K8S_PATH" -# yq eval -i '(.spec.template.spec.containers[].env) += { -# "name": "NODE_IP", -# "valueFrom": { -# "fieldRef": { -# "fieldPath": "status.hostIP" -# } -# } -# } -# ' "$SPLUNK_K8S_PATH" - - # yq eval -i '(.spec.template.spec.containers[].env) += { "name": "NODE_IP" }' "$K8S_PATH" - # yq eval -i '(.spec.template.spec.containers[].env[] | select(.name == "NODE_IP") | .valueFrom.fieldRef.fieldPath) = "status.hostIP"' "$K8S_PATH" - - # update the values of the OTEL_EXPORTER_OTLP_ENDPOINT and OTEL_EXPORTER_OTLP_TRACES_ENDPOINT environment variables - # to use the NODE_IP instead of OTEL_COLLECTOR_NAME - # Reference: https://stackoverflow.com/questions/70032588/use-yq-to-substitute-string-in-a-yaml-file - yq eval -i ' (.. | select(tag == "!!str")) |= sub("http://\$\(OTEL_COLLECTOR_NAME\):", "http://$(NODE_IP):")' "$SPLUNK_K8S_PATH" - # append the deployment.environment resource attribute # - name: OTEL_RESOURCE_ATTRIBUTES # value: service.name=$(OTEL_SERVICE_NAME),service.namespace=opentelemetry-demo,deployment.environment=development