diff --git a/user-skel/ansible_collections/ace_box/ace_box/roles/app-hipstershop/files/(ORIGINAL)microservices-demo-dynatrace/patches/loadgenerator.yaml b/user-skel/ansible_collections/ace_box/ace_box/roles/app-hipstershop/files/(ORIGINAL)microservices-demo-dynatrace/patches/loadgenerator.yaml index e7d6426a9..9ad8b1a57 100644 --- a/user-skel/ansible_collections/ace_box/ace_box/roles/app-hipstershop/files/(ORIGINAL)microservices-demo-dynatrace/patches/loadgenerator.yaml +++ b/user-skel/ansible_collections/ace_box/ace_box/roles/app-hipstershop/files/(ORIGINAL)microservices-demo-dynatrace/patches/loadgenerator.yaml @@ -34,11 +34,11 @@ spec: fi env: - name: FRONTEND_ADDR - value: "{{ ingress_protocol }}://{{ hipstershop_domain }}" + value: "frontend:80" containers: - name: main args: - 'locust --host="${FRONTEND_ADDR}" --headless -u "${USERS}" 2>&1' env: - name: FRONTEND_ADDR - value: "{{ ingress_protocol }}://{{ hipstershop_domain }}" + value: "frontend:80" diff --git a/user-skel/ansible_collections/ace_box/ace_box/roles/app-hipstershop/tasks/main.yml b/user-skel/ansible_collections/ace_box/ace_box/roles/app-hipstershop/tasks/main.yml index d8db4d482..e26d8b84a 100644 --- a/user-skel/ansible_collections/ace_box/ace_box/roles/app-hipstershop/tasks/main.yml +++ b/user-skel/ansible_collections/ace_box/ace_box/roles/app-hipstershop/tasks/main.yml @@ -38,6 +38,14 @@ group: "{{ ace_box_user }}" mode: '0644' +- name: Template Hipsterhop Loadgenerator + template: + src: "{{ role_path }}/templates/loadgenerator.yaml.j2" + dest: "{{ role_path }}/files/kustomize/patches/loadgenerator.yaml" + owner: "{{ ace_box_user }}" + group: "{{ ace_box_user }}" + mode: '0644' + - name: Kustomize Build set_fact: resources: "{{ lookup('kubernetes.core.kustomize', dir=role_path+'/files/kustomize') }}" diff --git a/user-skel/ansible_collections/ace_box/ace_box/roles/app-hipstershop/templates/loadgenerator.yaml.j2 b/user-skel/ansible_collections/ace_box/ace_box/roles/app-hipstershop/templates/loadgenerator.yaml.j2 new file mode 100644 index 000000000..5b2df3548 --- /dev/null +++ b/user-skel/ansible_collections/ace_box/ace_box/roles/app-hipstershop/templates/loadgenerator.yaml.j2 @@ -0,0 +1,44 @@ +# Copyright 2024 Dynatrace LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# vscode-kubernetes-tools:exclude +apiVersion: apps/v1 +kind: Deployment +metadata: + name: loadgenerator +spec: + template: + spec: + initContainers: + - name: frontend-check + command: + - /bin/sh + - -exc + - | + echo "Init container pinging frontend: ${FRONTEND_ADDR}..." + STATUSCODE=$(wget --server-response ${FRONTEND_ADDR} 2>&1 | awk '/^ HTTP/{print $2}') + if test $STATUSCODE -ne 200; then + echo "Error: Could not reach frontend - Status code: ${STATUSCODE}" + exit 1 + fi + env: + - name: FRONTEND_ADDR + value: "{{ ingress_protocol }}://{{ hipstershop_domain }}" + containers: + - name: main + args: + - 'locust --host="${FRONTEND_ADDR}" --headless -u "${USERS}" 2>&1' + env: + - name: FRONTEND_ADDR + value: "{{ ingress_protocol }}://{{ hipstershop_domain }}" \ No newline at end of file