diff --git a/customer-master-data-management-mock/base/deployment.yaml b/customer-master-data-management-mock/base/deployment.yaml index 0ceb798..c448767 100644 --- a/customer-master-data-management-mock/base/deployment.yaml +++ b/customer-master-data-management-mock/base/deployment.yaml @@ -29,10 +29,10 @@ spec: - "--verbose" resources: requests: - cpu: 100m + cpu: 500m memory: "128Mi" limits: - cpu: 100m + cpu: 500m memory: "128Mi" readinessProbe: httpGet: diff --git a/customer-master-data-management-mock/random-delay/mappings.json b/customer-master-data-management-mock/random-delay/mappings.json index 2a2c428..98f8f07 100644 --- a/customer-master-data-management-mock/random-delay/mappings.json +++ b/customer-master-data-management-mock/random-delay/mappings.json @@ -5,11 +5,6 @@ }, "response": { "status": 200, - "delayDistribution": { - "type": "lognormal", - "median": 80, - "sigma": 0.4 - }, "bodyFileName":"responses/luke_response.json", "headers":{ "Content-Type":"application/json" diff --git a/load-test/README.md b/load-test/README.md index 0dd6494..8398647 100644 --- a/load-test/README.md +++ b/load-test/README.md @@ -4,4 +4,5 @@ ```bash docker run --rm -i grafana/k6 run - <{PATH_TO_SCENARIO}/load-script.js -``` \ No newline at end of file +``` +When using Github Action to run the load scenario, a timeout could happen when starting the pod ... This will end up in a failing Github Action run \ No newline at end of file diff --git a/load-test/scenario-user-flow/load-script.js b/load-test/scenario-user-flow/load-script.js index ea5e6c2..3f78e76 100644 --- a/load-test/scenario-user-flow/load-script.js +++ b/load-test/scenario-user-flow/load-script.js @@ -2,33 +2,31 @@ import http from 'k6/http'; import { Rate } from 'k6/metrics'; import { sleep } from 'k6'; -const creditApplicationCreationRate = new Rate('failed credit application creation'); -const creditApplicationAcceptanceRate = new Rate('failed credit application acceptance'); +const creditApplicationCreationRate = new Rate('failed_credit_application_creation'); +const creditApplicationAcceptanceRate = new Rate('failed_credit_application_acceptance'); export const options = { vus: 10, - duration: '30s', + duration: '60s', thresholds: { - 'failed credit application creation': ['rate<0.1'], - 'failed credit application acceptance': ['rate<0.1'], + 'failed_credit_application_creation': ['rate<0.1'], + 'failed_credit_application_acceptance': ['rate<0.1'], 'http_req_duration': ['p(95)<400'], }, }; export default function () { - const creditApplicationCreation = http.post('http://creditapplication-service.lpt.svc.cluster.local:8080/api/credit-applications', { - "creditAmount":10000.00, - "firstName":"Harry", - "lastName":"Potter", - "zipCode":"12345", - "occupation":"IT", - "monthlyNetIncome":3000.00, - "monthlyExpenses":2500.00 + const creditApplicationCreation = http.post('http://creditapplication-k8s-service.lpt.svc.cluster.local:8080/api/credit-applications', JSON.stringify({"creditAmount":10000.00,"firstName":"Jim","lastName":"Beam","zipCode":"12345","occupation":"IT","monthlyNetIncome":5000.00,"monthlyExpenses":2500.00}), { + headers: { 'Content-Type': 'application/json' }, }); - creditApplicationCreationRate.add(creditApplicationCreation.status !== 201); + console.log(creditApplicationCreation.status) + console.log(creditApplicationCreation.body) + creditApplicationCreationRate.add(creditApplicationCreation.status !== 200); const applicationId = creditApplicationCreation.body.id; // after receiving the credit decision, the customer decides within 5 seconds to accept or decline the credit application sleep(5); - const creditApplicationAcceptance = http.post(`http://creditapplication-service.lpt.svc.cluster.local:8080/api/credit-applications/${applicationId}`, {}); - creditApplicationAcceptanceRate.add(creditApplicationAcceptance.status !== 200); + const creditApplicationAcceptance = http.post(`http://creditapplication-k8s-service.lpt.svc.cluster.local:8080/api/credit-applications/${applicationId}`, JSON.stringify({}), { + headers: { 'Content-Type': 'application/json' }, + }); + creditApplicationAcceptanceRate.add(creditApplicationAcceptance.status !== 202); } \ No newline at end of file diff --git a/monitoring/grafana/grafana.deployment.yaml b/monitoring/grafana/grafana.deployment.yaml new file mode 100644 index 0000000..0389502 --- /dev/null +++ b/monitoring/grafana/grafana.deployment.yaml @@ -0,0 +1,56 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + app: grafana + name: grafana +spec: + selector: + matchLabels: + app: grafana + template: + metadata: + labels: + app: grafana + spec: + securityContext: + fsGroup: 472 + supplementalGroups: + - 0 + containers: + - name: grafana + image: grafana/grafana:latest + imagePullPolicy: IfNotPresent + ports: + - containerPort: 3000 + name: http-grafana + protocol: TCP + readinessProbe: + failureThreshold: 3 + httpGet: + path: /robots.txt + port: 3000 + scheme: HTTP + initialDelaySeconds: 10 + periodSeconds: 30 + successThreshold: 1 + timeoutSeconds: 2 + livenessProbe: + failureThreshold: 3 + initialDelaySeconds: 30 + periodSeconds: 10 + successThreshold: 1 + tcpSocket: + port: 3000 + timeoutSeconds: 1 + resources: + requests: + cpu: 250m + memory: 750Mi + volumeMounts: + - mountPath: /var/lib/grafana + name: grafana-pv + volumes: + - name: grafana-pv + emptyDir: + sizeLimit: 1Gi diff --git a/monitoring/grafana/grafana.service.yaml b/monitoring/grafana/grafana.service.yaml new file mode 100644 index 0000000..4dbd24c --- /dev/null +++ b/monitoring/grafana/grafana.service.yaml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: Service +metadata: + name: grafana +spec: + ports: + - port: 3000 + protocol: TCP + targetPort: http-grafana + selector: + app: grafana + sessionAffinity: None + type: LoadBalancer \ No newline at end of file diff --git a/monitoring/grafana/kustomization.yaml b/monitoring/grafana/kustomization.yaml new file mode 100644 index 0000000..afbfd1e --- /dev/null +++ b/monitoring/grafana/kustomization.yaml @@ -0,0 +1,8 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +namespace: monitoring + +resources: + - grafana.deployment.yaml + - grafana.service.yaml \ No newline at end of file diff --git a/monitoring/monitoring.namespace.yaml b/monitoring/monitoring.namespace.yaml new file mode 100644 index 0000000..3335b6a --- /dev/null +++ b/monitoring/monitoring.namespace.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: monitoring \ No newline at end of file diff --git a/monitoring/prometheus-operator/install.md b/monitoring/prometheus-operator/install.md new file mode 100644 index 0000000..712063a --- /dev/null +++ b/monitoring/prometheus-operator/install.md @@ -0,0 +1 @@ +kubectl create -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/master/bundle.yaml \ No newline at end of file diff --git a/monitoring/prometheus-operator/operator.clusterrole.yaml b/monitoring/prometheus-operator/operator.clusterrole.yaml new file mode 100644 index 0000000..875c949 --- /dev/null +++ b/monitoring/prometheus-operator/operator.clusterrole.yaml @@ -0,0 +1,107 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + labels: + app.kubernetes.io/component: controller + app.kubernetes.io/name: prometheus-operator + app.kubernetes.io/version: 0.77.2 + name: prometheus-operator +rules: + - apiGroups: + - monitoring.coreos.com + resources: + - alertmanagers + - alertmanagers/finalizers + - alertmanagers/status + - alertmanagerconfigs + - prometheuses + - prometheuses/finalizers + - prometheuses/status + - prometheusagents + - prometheusagents/finalizers + - prometheusagents/status + - thanosrulers + - thanosrulers/finalizers + - thanosrulers/status + - scrapeconfigs + - servicemonitors + - podmonitors + - probes + - prometheusrules + verbs: + - '*' + - apiGroups: + - apps + resources: + - statefulsets + verbs: + - '*' + - apiGroups: + - "" + resources: + - configmaps + - secrets + verbs: + - '*' + - apiGroups: + - "" + resources: + - pods + verbs: + - list + - delete + - apiGroups: + - "" + resources: + - services + - services/finalizers + verbs: + - get + - create + - update + - delete + - apiGroups: + - "" + resources: + - nodes + verbs: + - list + - watch + - apiGroups: + - "" + resources: + - namespaces + verbs: + - get + - list + - watch + - apiGroups: + - "" + resources: + - events + verbs: + - patch + - create + - apiGroups: + - networking.k8s.io + resources: + - ingresses + verbs: + - get + - list + - watch + - apiGroups: + - storage.k8s.io + resources: + - storageclasses + verbs: + - get + - apiGroups: + - "" + resources: + - endpoints + verbs: + - get + - create + - update + - delete \ No newline at end of file diff --git a/monitoring/prometheus-operator/operator.clusterrolebinding.yaml b/monitoring/prometheus-operator/operator.clusterrolebinding.yaml new file mode 100644 index 0000000..be1be33 --- /dev/null +++ b/monitoring/prometheus-operator/operator.clusterrolebinding.yaml @@ -0,0 +1,16 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + labels: + app.kubernetes.io/component: controller + app.kubernetes.io/name: prometheus-operator + app.kubernetes.io/version: 0.77.2 + name: prometheus-operator +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: prometheus-operator +subjects: + - kind: ServiceAccount + name: prometheus-operator + namespace: default \ No newline at end of file diff --git a/monitoring/prometheus-operator/operator.deployment.yaml b/monitoring/prometheus-operator/operator.deployment.yaml new file mode 100644 index 0000000..3ae02e1 --- /dev/null +++ b/monitoring/prometheus-operator/operator.deployment.yaml @@ -0,0 +1,60 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + app.kubernetes.io/component: controller + app.kubernetes.io/name: prometheus-operator + app.kubernetes.io/version: 0.77.2 + name: prometheus-operator + namespace: default +spec: + replicas: 1 + selector: + matchLabels: + app.kubernetes.io/component: controller + app.kubernetes.io/name: prometheus-operator + template: + metadata: + annotations: + kubectl.kubernetes.io/default-container: prometheus-operator + labels: + app.kubernetes.io/component: controller + app.kubernetes.io/name: prometheus-operator + app.kubernetes.io/version: 0.77.2 + spec: + automountServiceAccountToken: true + containers: + - args: + - --kubelet-service=kube-system/kubelet + - --prometheus-config-reloader=europe-west1-docker.pkg.dev/vbdev-436712/lpt-quay-proxy/prometheus-operator/prometheus-config-reloader:v0.77.2 + - --kubelet-endpoints=true + - --kubelet-endpointslice=false + env: + - name: GOGC + value: "30" + image: europe-west1-docker.pkg.dev/vbdev-436712/lpt-quay-proxy/prometheus-operator/prometheus-operator:v0.77.2 + name: prometheus-operator + ports: + - containerPort: 8080 + name: http + resources: + limits: + cpu: 200m + memory: 200Mi + requests: + cpu: 100m + memory: 100Mi + securityContext: + allowPrivilegeEscalation: false + capabilities: + drop: + - ALL + readOnlyRootFilesystem: true + nodeSelector: + kubernetes.io/os: linux + securityContext: + runAsNonRoot: true + runAsUser: 65534 + seccompProfile: + type: RuntimeDefault + serviceAccountName: prometheus-operator \ No newline at end of file diff --git a/monitoring/prometheus/kustomization.yaml b/monitoring/prometheus/kustomization.yaml new file mode 100644 index 0000000..c8de176 --- /dev/null +++ b/monitoring/prometheus/kustomization.yaml @@ -0,0 +1,13 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +namespace: monitoring + +resources: + - prometheus.clusterrole.yaml + - prometheus.clusterrolebinding.yaml + - prometheus.serviceaccount.yaml + - prometheus.coreos.yaml + - prometheus.service.yaml + - prometheus.servicemonitor.yaml + - spring.servicemonitor.yaml \ No newline at end of file diff --git a/monitoring/prometheus/prometheus.clusterrole.yaml b/monitoring/prometheus/prometheus.clusterrole.yaml new file mode 100644 index 0000000..8a0b312 --- /dev/null +++ b/monitoring/prometheus/prometheus.clusterrole.yaml @@ -0,0 +1,24 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: prometheus +rules: + - apiGroups: [""] + resources: + - nodes + - nodes/metrics + - services + - endpoints + - pods + verbs: ["get", "list", "watch"] + - apiGroups: [""] + resources: + - configmaps + verbs: ["get"] + - apiGroups: + - networking.k8s.io + resources: + - ingresses + verbs: ["get", "list", "watch"] + - nonResourceURLs: ["/metrics"] + verbs: ["get"] diff --git a/monitoring/prometheus/prometheus.clusterrolebinding.yaml b/monitoring/prometheus/prometheus.clusterrolebinding.yaml new file mode 100644 index 0000000..986694c --- /dev/null +++ b/monitoring/prometheus/prometheus.clusterrolebinding.yaml @@ -0,0 +1,11 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: prometheus +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: prometheus +subjects: + - kind: ServiceAccount + name: prometheus \ No newline at end of file diff --git a/monitoring/prometheus/prometheus.coreos.yaml b/monitoring/prometheus/prometheus.coreos.yaml new file mode 100644 index 0000000..79b76c5 --- /dev/null +++ b/monitoring/prometheus/prometheus.coreos.yaml @@ -0,0 +1,21 @@ +apiVersion: monitoring.coreos.com/v1 +kind: Prometheus +metadata: + name: prometheus + labels: + app: prometheus +spec: + image: quay.io/prometheus/prometheus:v2.22.1 + nodeSelector: + kubernetes.io/os: linux + replicas: 1 + resources: + requests: + memory: 400Mi + securityContext: + fsGroup: 2000 + runAsNonRoot: true + runAsUser: 1000 + serviceAccountName: prometheus + version: v2.22.1 + serviceMonitorSelector: {} \ No newline at end of file diff --git a/monitoring/prometheus/prometheus.service.yaml b/monitoring/prometheus/prometheus.service.yaml new file mode 100644 index 0000000..6a218d0 --- /dev/null +++ b/monitoring/prometheus/prometheus.service.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: Service +metadata: + name: prometheus +spec: + ports: + - name: web + port: 9090 + targetPort: web + selector: + app.kubernetes.io/name: prometheus + sessionAffinity: ClientIP \ No newline at end of file diff --git a/monitoring/prometheus/prometheus.serviceaccount.yaml b/monitoring/prometheus/prometheus.serviceaccount.yaml new file mode 100644 index 0000000..fc2477d --- /dev/null +++ b/monitoring/prometheus/prometheus.serviceaccount.yaml @@ -0,0 +1,6 @@ +apiVersion: v1 +kind: ServiceAccount +metadata: + annotations: + iam.gke.io/gcp-service-account: lpt-application@vbdev-436712.iam.gserviceaccount.com + name: prometheus \ No newline at end of file diff --git a/monitoring/prometheus/prometheus.servicemonitor.yaml b/monitoring/prometheus/prometheus.servicemonitor.yaml new file mode 100644 index 0000000..36082e9 --- /dev/null +++ b/monitoring/prometheus/prometheus.servicemonitor.yaml @@ -0,0 +1,13 @@ +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: prometheus-self + labels: + app: prometheus +spec: + endpoints: + - interval: 30s + port: web + selector: + matchLabels: + app: prometheus \ No newline at end of file diff --git a/monitoring/prometheus/spring.servicemonitor.yaml b/monitoring/prometheus/spring.servicemonitor.yaml new file mode 100644 index 0000000..a7d360b --- /dev/null +++ b/monitoring/prometheus/spring.servicemonitor.yaml @@ -0,0 +1,16 @@ +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: spring-monitor + labels: + app: prometheus +spec: + endpoints: + - interval: 15s + path: /actuator/prometheus + port: "8080" + selector: + matchLabels: + monitoring: spring + namespaceSelector: + any: true \ No newline at end of file