diff --git a/bundle/manifests/operators.ibm.com_stocktraders.yaml b/bundle/manifests/operators.ibm.com_stocktraders.yaml index 09b1bea..b81b89b 100644 --- a/bundle/manifests/operators.ibm.com_stocktraders.yaml +++ b/bundle/manifests/operators.ibm.com_stocktraders.yaml @@ -456,20 +456,27 @@ spec: type: string type: object mq: - description: IBM MQ settings (optional) + description: MQ settings (optional) properties: + kind: + description: Kind of MQ Provider + enum: + - ibm-mq + - amazon-mq-apache-mq + type: string channel: description: Channel type: string + url: + description: >- + Connection string with protocol(s) and port + type: string host: description: Host name (or IP address) type: string id: description: User ID type: string - kind: - description: MQ vendor - type: string password: description: Password format: password diff --git a/bundle/manifests/operators_v1_stocktrader.yaml b/bundle/manifests/operators_v1_stocktrader.yaml index 9436395..45574da 100644 --- a/bundle/manifests/operators_v1_stocktrader.yaml +++ b/bundle/manifests/operators_v1_stocktrader.yaml @@ -187,6 +187,7 @@ spec: mq: kind: ibm-mq host: mqtrader1-mqtrader1 + url: ssl://mqtrader-amazonaws.com:61617 port: 1414 id: app password: pwd diff --git a/bundle/manifests/stocktrader-operator.clusterserviceversion.yaml b/bundle/manifests/stocktrader-operator.clusterserviceversion.yaml index bf1087c..18640eb 100644 --- a/bundle/manifests/stocktrader-operator.clusterserviceversion.yaml +++ b/bundle/manifests/stocktrader-operator.clusterserviceversion.yaml @@ -245,6 +245,7 @@ metadata: "mq": { "kind": "ibm-mq", "host": "mqtrader1-mqtrader1", + "url": "ssl://mqtrader-amazonaws.com:61617", "port": 1414, "id": "app", "password": "pwd", @@ -1335,7 +1336,7 @@ spec: # Section for MQ settings - path: mq - displayName: IBM MQ settings + displayName: MQ settings - path: mq.kind description: This controls which JMS resource adapter (.rar file) gets loaded and how it is configured displayName: Select the appropriate MQ vendor for point-to-point messaging @@ -1348,6 +1349,12 @@ spec: x-descriptors: - urn:alm:descriptor:com.tectonic.ui:text - urn:alm:descriptor:com.tectonic.ui:fieldGroup:mq + - path: mq.url + description: Connection string for MQ + displayName: MQ connection string [ssl:// or failover://(ssl://..)] + x-descriptors: + - urn:alm:descriptor:com.tectonic.ui:text + - urn:alm:descriptor:com.tectonic.ui:fieldGroup:mq - path: mq.port description: Use the local port number (not the node port or Ingress port) if using an intra-cluster deployment of MQ displayName: Port number for MQ diff --git a/config/crd/bases/operators.ibm.com_stocktraders.yaml b/config/crd/bases/operators.ibm.com_stocktraders.yaml index 09b1bea..46dc18e 100644 --- a/config/crd/bases/operators.ibm.com_stocktraders.yaml +++ b/config/crd/bases/operators.ibm.com_stocktraders.yaml @@ -456,13 +456,18 @@ spec: type: string type: object mq: - description: IBM MQ settings (optional) + description: MQ settings (optional) properties: channel: description: Channel type: string + url: + description: >- + Connection string with protocol(s) and port + type: string host: - description: Host name (or IP address) + description: >- + Host name, connection string, or IP address type: string id: description: User ID diff --git a/config/manifests/bases/stocktrader-operator.clusterserviceversion.yaml b/config/manifests/bases/stocktrader-operator.clusterserviceversion.yaml index bf1087c..9156b14 100644 --- a/config/manifests/bases/stocktrader-operator.clusterserviceversion.yaml +++ b/config/manifests/bases/stocktrader-operator.clusterserviceversion.yaml @@ -243,7 +243,6 @@ metadata: "url": "http://odmtrader1-ibm-odm-dev:9060/DecisionService/rest/ICP_Trader_Dev_1/determineLoyalty" }, "mq": { - "kind": "ibm-mq", "host": "mqtrader1-mqtrader1", "port": 1414, "id": "app", @@ -1335,7 +1334,7 @@ spec: # Section for MQ settings - path: mq - displayName: IBM MQ settings + displayName: MQ settings - path: mq.kind description: This controls which JMS resource adapter (.rar file) gets loaded and how it is configured displayName: Select the appropriate MQ vendor for point-to-point messaging @@ -1348,6 +1347,12 @@ spec: x-descriptors: - urn:alm:descriptor:com.tectonic.ui:text - urn:alm:descriptor:com.tectonic.ui:fieldGroup:mq + - path: mq.url + description: Connection string for MQ + displayName: MQ connection string [ssl:// or failover://(ssl://..)] + x-descriptors: + - urn:alm:descriptor:com.tectonic.ui:text + - urn:alm:descriptor:com.tectonic.ui:fieldGroup:mq - path: mq.port description: Use the local port number (not the node port or Ingress port) if using an intra-cluster deployment of MQ displayName: Port number for MQ diff --git a/config/samples/operators_v1_stocktrader.yaml b/config/samples/operators_v1_stocktrader.yaml index 9436395..9243131 100644 --- a/config/samples/operators_v1_stocktrader.yaml +++ b/config/samples/operators_v1_stocktrader.yaml @@ -188,6 +188,7 @@ spec: kind: ibm-mq host: mqtrader1-mqtrader1 port: 1414 + url: ssl://mqtrader-amazonaws.com:61617 id: app password: pwd queueManager: stocktrader diff --git a/helm-charts/stocktrader/templates/account.yaml b/helm-charts/stocktrader/templates/account.yaml index a6e569e..3bc7c0f 100644 --- a/helm-charts/stocktrader/templates/account.yaml +++ b/helm-charts/stocktrader/templates/account.yaml @@ -59,6 +59,18 @@ spec: sidecar.istio.io/inject: 'true' {{- end }} spec: + affinity: + podAntiAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - weight: 1 + podAffinityTerm: + labelSelector: + matchExpressions: + - key: app + operator: In + values: + - account + topologyKey: "kubernetes.io/hostname" {{- if .Values.global.pullSecret }} imagePullSecrets: - name: {{ tpl .Values.global.pullSecretName . }} @@ -146,6 +158,11 @@ spec: configMapKeyRef: name: {{ tpl .Values.global.configMapName . }} key: mq.kind + - name: MQ_URL + valueFrom: + configMapKeyRef: + name: {{ tpl .Values.global.configMapName . }} + key: mq.url - name: MQ_HOST valueFrom: configMapKeyRef: @@ -288,6 +305,49 @@ spec: {{- if .Values.account.autoscale }} --- #Deploy the autoscaler +{{- if .Capabilities.APIVersions.Has "autoscaling/v2" }} +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ .Release.Name }}-account-hpa + labels: + app: stock-trader +spec: + behavior: + scaleUp: + stabilizationWindowSeconds: 0 + selectPolicy: Min + policies: + - type: Pods + value: 1 + periodSeconds: 15 + scaleDown: + stabilizationWindowSeconds: 300 + selectPolicy: Max + policies: + - type: Percent + value: 100 + periodSeconds: 120 + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ .Release.Name }}-account + minReplicas: {{ .Values.account.replicas }} + maxReplicas: {{ .Values.account.maxReplicas }} + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.account.cpuThreshold }} + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: 80 +{{- else }} apiVersion: autoscaling/v2beta2 kind: HorizontalPodAutoscaler metadata: @@ -316,7 +376,14 @@ spec: name: {{ .Release.Name }}-account minReplicas: {{ .Values.account.replicas }} maxReplicas: {{ .Values.account.maxReplicas }} - targetCPUUtilizationPercentage: {{ .Values.account.cpuThreshold }} + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.account.cpuThreshold }} +{{- end }} {{- end }} --- #Deploy the service diff --git a/helm-charts/stocktrader/templates/broker-query.yaml b/helm-charts/stocktrader/templates/broker-query.yaml index 8d9bf28..7675817 100644 --- a/helm-charts/stocktrader/templates/broker-query.yaml +++ b/helm-charts/stocktrader/templates/broker-query.yaml @@ -53,6 +53,18 @@ spec: sidecar.istio.io/inject: 'true' {{- end }} spec: + affinity: + podAntiAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - weight: 1 + podAffinityTerm: + labelSelector: + matchExpressions: + - key: app + operator: In + values: + - broker-query + topologyKey: "kubernetes.io/hostname" {{- if .Values.global.pullSecret }} imagePullSecrets: - name: {{ tpl .Values.global.pullSecretName . }} @@ -192,6 +204,49 @@ spec: {{- if .Values.brokerCQRS.autoscale }} --- #Deploy the autoscaler +{{- if .Capabilities.APIVersions.Has "autoscaling/v2" }} +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ .Release.Name }}-broker-query-hpa + labels: + app: stock-trader +spec: + behavior: + scaleUp: + stabilizationWindowSeconds: 0 + selectPolicy: Min + policies: + - type: Pods + value: 1 + periodSeconds: 15 + scaleDown: + stabilizationWindowSeconds: 300 + selectPolicy: Max + policies: + - type: Percent + value: 100 + periodSeconds: 120 + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ .Release.Name }}-broker-query + minReplicas: {{ .Values.brokerCQRS.replicas }} + maxReplicas: {{ .Values.brokerCQRS.maxReplicas }} + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.brokerCQRS.cpuThreshold }} + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: 80 +{{- else }} apiVersion: autoscaling/v2beta2 kind: HorizontalPodAutoscaler metadata: @@ -220,7 +275,14 @@ spec: name: {{ .Release.Name }}-broker-query minReplicas: {{ .Values.brokerCQRS.replicas }} maxReplicas: {{ .Values.brokerCQRS.maxReplicas }} - targetCPUUtilizationPercentage: {{ .Values.brokerCQRS.cpuThreshold }} + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.brokerCQRS.cpuThreshold }} +{{- end }} {{- end }} --- #Deploy the service diff --git a/helm-charts/stocktrader/templates/broker.yaml b/helm-charts/stocktrader/templates/broker.yaml index 276e71a..c0655e7 100644 --- a/helm-charts/stocktrader/templates/broker.yaml +++ b/helm-charts/stocktrader/templates/broker.yaml @@ -42,6 +42,18 @@ spec: sidecar.istio.io/inject: 'true' {{- end }} spec: + affinity: + podAntiAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - weight: 1 + podAffinityTerm: + labelSelector: + matchExpressions: + - key: app + operator: In + values: + - broker + topologyKey: "kubernetes.io/hostname" {{- if .Values.global.pullSecret }} imagePullSecrets: - name: {{ tpl .Values.global.pullSecretName . }} @@ -158,6 +170,49 @@ spec: {{- if .Values.broker.autoscale }} --- #Deploy the autoscaler +{{- if .Capabilities.APIVersions.Has "autoscaling/v2" }} +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ .Release.Name }}-broker-hpa + labels: + app: stock-trader +spec: + behavior: + scaleUp: + stabilizationWindowSeconds: 0 + selectPolicy: Min + policies: + - type: Pods + value: 1 + periodSeconds: 15 + scaleDown: + stabilizationWindowSeconds: 300 + selectPolicy: Max + policies: + - type: Percent + value: 100 + periodSeconds: 120 + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ .Release.Name }}-broker + minReplicas: {{ .Values.broker.replicas }} + maxReplicas: {{ .Values.broker.maxReplicas }} + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.broker.cpuThreshold }} + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: 80 +{{- else }} apiVersion: autoscaling/v2beta2 kind: HorizontalPodAutoscaler metadata: @@ -186,7 +241,14 @@ spec: name: {{ .Release.Name }}-broker minReplicas: {{ .Values.broker.replicas }} maxReplicas: {{ .Values.broker.maxReplicas }} - targetCPUUtilizationPercentage: {{ .Values.broker.cpuThreshold }} + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.broker.cpuThreshold }} +{{- end }} {{- end }} --- #Deploy the service diff --git a/helm-charts/stocktrader/templates/collector.yaml b/helm-charts/stocktrader/templates/collector.yaml index 06bcbea..d65968a 100644 --- a/helm-charts/stocktrader/templates/collector.yaml +++ b/helm-charts/stocktrader/templates/collector.yaml @@ -52,6 +52,18 @@ spec: sidecar.istio.io/inject: 'true' {{- end }} spec: + affinity: + podAntiAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - weight: 1 + podAffinityTerm: + labelSelector: + matchExpressions: + - key: app + operator: In + values: + - collector + topologyKey: "kubernetes.io/hostname" {{- if .Values.global.pullSecret }} imagePullSecrets: - name: {{ tpl .Values.global.pullSecretName . }} @@ -166,6 +178,49 @@ spec: {{- if .Values.collector.autoscale }} --- #Deploy the autoscaler +{{- if .Capabilities.APIVersions.Has "autoscaling/v2" }} +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ .Release.Name }}-collector-hpa + labels: + app: stock-trader +spec: + behavior: + scaleUp: + stabilizationWindowSeconds: 0 + selectPolicy: Min + policies: + - type: Pods + value: 1 + periodSeconds: 15 + scaleDown: + stabilizationWindowSeconds: 300 + selectPolicy: Max + policies: + - type: Percent + value: 100 + periodSeconds: 120 + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ .Release.Name }}-collector + minReplicas: {{ .Values.collector.replicas }} + maxReplicas: {{ .Values.collector.maxReplicas }} + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.collector.cpuThreshold }} + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: 80 + {{- else }} apiVersion: autoscaling/v2beta2 kind: HorizontalPodAutoscaler metadata: @@ -194,7 +249,14 @@ spec: name: {{ .Release.Name }}-collector minReplicas: {{ .Values.collector.replicas }} maxReplicas: {{ .Values.collector.maxReplicas }} - targetCPUUtilizationPercentage: {{ .Values.collector.cpuThreshold }} + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.collector.cpuThreshold }} + {{- end }} {{- end }} --- #Deploy the service diff --git a/helm-charts/stocktrader/templates/config.yaml b/helm-charts/stocktrader/templates/config.yaml index 8f3d90f..9d01870 100644 --- a/helm-charts/stocktrader/templates/config.yaml +++ b/helm-charts/stocktrader/templates/config.yaml @@ -46,6 +46,7 @@ data: database.db: {{ .Values.database.db }} database.ssl: "{{ .Values.database.ssl }}" mq.host: {{ .Values.mq.host }} + mq.url: {{ .Values.mq.url }} mq.kind: {{ .Values.mq.kind }} mq.port: "{{ .Values.mq.port }}" mq.queueManager: {{ .Values.mq.queueManager }} diff --git a/helm-charts/stocktrader/templates/looper.yaml b/helm-charts/stocktrader/templates/looper.yaml index 9c46e43..7e4f5c5 100644 --- a/helm-charts/stocktrader/templates/looper.yaml +++ b/helm-charts/stocktrader/templates/looper.yaml @@ -43,6 +43,18 @@ spec: sidecar.istio.io/inject: 'true' {{- end }} spec: + affinity: + podAntiAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - weight: 1 + podAffinityTerm: + labelSelector: + matchExpressions: + - key: app + operator: In + values: + - looper + topologyKey: "kubernetes.io/hostname" {{- if .Values.global.pullSecret }} imagePullSecrets: - name: {{ tpl .Values.global.pullSecretName . }} @@ -141,6 +153,49 @@ spec: {{- if .Values.looper.autoscale }} --- #Deploy the autoscaler +{{- if .Capabilities.APIVersions.Has "autoscaling/v2" }} +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ .Release.Name }}-looper-hpa + labels: + app: stock-trader +spec: + behavior: + scaleUp: + stabilizationWindowSeconds: 0 + selectPolicy: Min + policies: + - type: Pods + value: 1 + periodSeconds: 15 + scaleDown: + stabilizationWindowSeconds: 300 + selectPolicy: Max + policies: + - type: Percent + value: 100 + periodSeconds: 120 + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ .Release.Name }}-looper + minReplicas: {{ .Values.looper.replicas }} + maxReplicas: {{ .Values.looper.maxReplicas }} + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.looper.cpuThreshold }} + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: 80 +{{- else }} apiVersion: autoscaling/v2beta2 kind: HorizontalPodAutoscaler metadata: @@ -169,7 +224,14 @@ spec: name: {{ .Release.Name }}-looper minReplicas: {{ .Values.looper.replicas }} maxReplicas: {{ .Values.looper.maxReplicas }} - targetCPUUtilizationPercentage: {{ .Values.looper.cpuThreshold }} + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.looper.cpuThreshold }} +{{- end }} {{- end }} --- #Deploy the service diff --git a/helm-charts/stocktrader/templates/messaging.yaml b/helm-charts/stocktrader/templates/messaging.yaml index 5ab3dad..a6da906 100644 --- a/helm-charts/stocktrader/templates/messaging.yaml +++ b/helm-charts/stocktrader/templates/messaging.yaml @@ -53,6 +53,18 @@ spec: sidecar.istio.io/inject: 'true' {{- end }} spec: + affinity: + podAntiAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - weight: 1 + podAffinityTerm: + labelSelector: + matchExpressions: + - key: app + operator: In + values: + - messaging + topologyKey: "kubernetes.io/hostname" {{- if .Values.global.pullSecret }} imagePullSecrets: - name: {{ tpl .Values.global.pullSecretName . }} @@ -95,6 +107,11 @@ spec: configMapKeyRef: name: {{ tpl .Values.global.configMapName . }} key: mq.kind + - name: MQ_URL + valueFrom: + configMapKeyRef: + name: {{ tpl .Values.global.configMapName . }} + key: mq.url - name: MQ_HOST valueFrom: configMapKeyRef: @@ -169,6 +186,49 @@ spec: {{- if .Values.messaging.autoscale }} --- #Deploy the autoscaler +{{- if .Capabilities.APIVersions.Has "autoscaling/v2" }} +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ .Release.Name }}-messaging-hpa + labels: + app: stock-trader +spec: + behavior: + scaleUp: + stabilizationWindowSeconds: 0 + selectPolicy: Min + policies: + - type: Pods + value: 1 + periodSeconds: 15 + scaleDown: + stabilizationWindowSeconds: 300 + selectPolicy: Max + policies: + - type: Percent + value: 100 + periodSeconds: 120 + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ .Release.Name }}-messaging + minReplicas: {{ .Values.messaging.replicas }} + maxReplicas: {{ .Values.messaging.maxReplicas }} + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.messaging.cpuThreshold }} + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: 80 +{{- else }} apiVersion: autoscaling/v2beta2 kind: HorizontalPodAutoscaler metadata: @@ -197,6 +257,13 @@ spec: name: {{ .Release.Name }}-messaging minReplicas: {{ .Values.messaging.replicas }} maxReplicas: {{ .Values.messaging.maxReplicas }} - targetCPUUtilizationPercentage: {{ .Values.messaging.cpuThreshold }} + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.messaging.cpuThreshold }} +{{- end }} {{- end }} {{- end }} diff --git a/helm-charts/stocktrader/templates/notification-slack.yaml b/helm-charts/stocktrader/templates/notification-slack.yaml index d73ce92..cf7cc85 100644 --- a/helm-charts/stocktrader/templates/notification-slack.yaml +++ b/helm-charts/stocktrader/templates/notification-slack.yaml @@ -51,6 +51,18 @@ spec: sidecar.istio.io/inject: 'true' {{- end }} spec: + affinity: + podAntiAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - weight: 1 + podAffinityTerm: + labelSelector: + matchExpressions: + - key: app + operator: In + values: + - notification-slack + topologyKey: "kubernetes.io/hostname" {{- if .Values.global.pullSecret }} imagePullSecrets: - name: {{ tpl .Values.global.pullSecretName . }} @@ -164,7 +176,8 @@ spec: {{- if .Values.notificationSlack.autoscale }} --- #Deploy the autoscaler -apiVersion: autoscaling/v2beta2 +{{- if .Capabilities.APIVersions.Has "autoscaling/v2" }} +apiVersion: autoscaling/v2 kind: HorizontalPodAutoscaler metadata: name: {{ .Release.Name }}-notification-slack-hpa @@ -192,6 +205,55 @@ spec: name: {{ .Release.Name }}-notification-slack minReplicas: {{ .Values.notificationSlack.replicas }} maxReplicas: {{ .Values.notificationSlack.maxReplicas }} - targetCPUUtilizationPercentage: {{ .Values.notificationSlack.cpuThreshold }} + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.notificationSlack.cpuThreshold }} + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: 80 +{{- else }} +apiVersion: autoscaling/v2beta2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ .Release.Name }}-notificationSlack-hpa + labels: + app: stock-trader +spec: + behavior: + scaleUp: + stabilizationWindowSeconds: 0 + selectPolicy: Min + policies: + - type: Pods + value: 1 + periodSeconds: 15 + scaleDown: + stabilizationWindowSeconds: 300 + selectPolicy: Max + policies: + - type: Percent + value: 100 + periodSeconds: 120 + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ .Release.Name }}-notificationSlack + minReplicas: {{ .Values.notificationSlack.replicas }} + maxReplicas: {{ .Values.notificationSlack.maxReplicas }} + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.notificationSlack.cpuThreshold }} +{{- end }} {{- end }} {{- end }} diff --git a/helm-charts/stocktrader/templates/notification-twitter.yaml b/helm-charts/stocktrader/templates/notification-twitter.yaml index 4238180..0909d15 100644 --- a/helm-charts/stocktrader/templates/notification-twitter.yaml +++ b/helm-charts/stocktrader/templates/notification-twitter.yaml @@ -53,6 +53,18 @@ spec: sidecar.istio.io/inject: 'true' {{- end }} spec: + affinity: + podAntiAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - weight: 1 + podAffinityTerm: + labelSelector: + matchExpressions: + - key: app + operator: In + values: + - notification-twitter + topologyKey: "kubernetes.io/hostname" {{- if .Values.global.pullSecret }} imagePullSecrets: - name: {{ tpl .Values.global.pullSecretName . }} @@ -167,6 +179,49 @@ spec: {{- if .Values.notificationTwitter.autoscale }} --- #Deploy the autoscaler +{{- if .Capabilities.APIVersions.Has "autoscaling/v2" }} +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ .Release.Name }}-notification-twitter-hpa + labels: + app: stock-trader +spec: + behavior: + scaleUp: + stabilizationWindowSeconds: 0 + selectPolicy: Min + policies: + - type: Pods + value: 1 + periodSeconds: 15 + scaleDown: + stabilizationWindowSeconds: 300 + selectPolicy: Max + policies: + - type: Percent + value: 100 + periodSeconds: 120 + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ .Release.Name }}-notification-twitter + minReplicas: {{ .Values.notificationTwitter.replicas }} + maxReplicas: {{ .Values.notificationTwitter.maxReplicas }} + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.notificationTwitter.cpuThreshold }} + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: 80 +{{- else }} apiVersion: autoscaling/v2beta2 kind: HorizontalPodAutoscaler metadata: @@ -195,6 +250,13 @@ spec: name: {{ .Release.Name }}-notification-twitter minReplicas: {{ .Values.notificationTwitter.replicas }} maxReplicas: {{ .Values.notificationTwitter.maxReplicas }} - targetCPUUtilizationPercentage: {{ .Values.notificationTwitter.cpuThreshold }} + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.notificationTwitter.cpuThreshold }} +{{- end }} {{- end }} {{- end }} diff --git a/helm-charts/stocktrader/templates/portfolio.yaml b/helm-charts/stocktrader/templates/portfolio.yaml index 5c201ae..7702e41 100644 --- a/helm-charts/stocktrader/templates/portfolio.yaml +++ b/helm-charts/stocktrader/templates/portfolio.yaml @@ -53,6 +53,18 @@ spec: sidecar.istio.io/inject: 'true' {{- end }} spec: + affinity: + podAntiAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - weight: 1 + podAffinityTerm: + labelSelector: + matchExpressions: + - key: app + operator: In + values: + - portfolio + topologyKey: "kubernetes.io/hostname" {{- if .Values.global.pullSecret }} imagePullSecrets: - name: {{ tpl .Values.global.pullSecretName . }} @@ -220,6 +232,49 @@ spec: {{- if .Values.portfolio.autoscale }} --- #Deploy the autoscaler + {{- if .Capabilities.APIVersions.Has "autoscaling/v2" }} +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ .Release.Name }}-portfolio-hpa + labels: + app: stock-trader +spec: + behavior: + scaleUp: + stabilizationWindowSeconds: 0 + selectPolicy: Min + policies: + - type: Pods + value: 1 + periodSeconds: 15 + scaleDown: + stabilizationWindowSeconds: 300 + selectPolicy: Max + policies: + - type: Percent + value: 100 + periodSeconds: 120 + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ .Release.Name }}-portfolio + minReplicas: {{ .Values.portfolio.replicas }} + maxReplicas: {{ .Values.portfolio.maxReplicas }} + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.portfolio.cpuThreshold }} + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: 80 +{{- else }} apiVersion: autoscaling/v2beta2 kind: HorizontalPodAutoscaler metadata: @@ -248,7 +303,14 @@ spec: name: {{ .Release.Name }}-portfolio minReplicas: {{ .Values.portfolio.replicas }} maxReplicas: {{ .Values.portfolio.maxReplicas }} - targetCPUUtilizationPercentage: {{ .Values.portfolio.cpuThreshold }} + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.portfolio.cpuThreshold }} +{{- end }} {{- end }} --- #Deploy the service diff --git a/helm-charts/stocktrader/templates/stock-quote.yaml b/helm-charts/stocktrader/templates/stock-quote.yaml index a650598..94a3e2d 100644 --- a/helm-charts/stocktrader/templates/stock-quote.yaml +++ b/helm-charts/stocktrader/templates/stock-quote.yaml @@ -52,6 +52,18 @@ spec: sidecar.istio.io/inject: 'true' {{- end }} spec: + affinity: + podAntiAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - weight: 1 + podAffinityTerm: + labelSelector: + matchExpressions: + - key: app + operator: In + values: + - stock-quote + topologyKey: "kubernetes.io/hostname" {{- if .Values.global.pullSecret }} imagePullSecrets: - name: {{ tpl .Values.global.pullSecretName . }} @@ -189,6 +201,49 @@ spec: {{- if .Values.stockQuote.autoscale }} --- #Deploy the autoscaler +{{- if .Capabilities.APIVersions.Has "autoscaling/v2" }} +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ .Release.Name }}-stock-quote-hpa + labels: + app: stock-trader +spec: + behavior: + scaleUp: + stabilizationWindowSeconds: 0 + selectPolicy: Min + policies: + - type: Pods + value: 1 + periodSeconds: 15 + scaleDown: + stabilizationWindowSeconds: 300 + selectPolicy: Max + policies: + - type: Percent + value: 100 + periodSeconds: 120 + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ .Release.Name }}-stock-quote + minReplicas: {{ .Values.stockQuote.replicas }} + maxReplicas: {{ .Values.stockQuote.maxReplicas }} + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.stockQuote.cpuThreshold }} + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: 80 +{{- else }} apiVersion: autoscaling/v2beta2 kind: HorizontalPodAutoscaler metadata: @@ -217,7 +272,14 @@ spec: name: {{ .Release.Name }}-stock-quote minReplicas: {{ .Values.stockQuote.replicas }} maxReplicas: {{ .Values.stockQuote.maxReplicas }} - targetCPUUtilizationPercentage: {{ .Values.stockQuote.cpuThreshold }} + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.stockQuote.cpuThreshold }} +{{- end }} {{- end }} --- #Deploy the service diff --git a/helm-charts/stocktrader/templates/trade-history.yaml b/helm-charts/stocktrader/templates/trade-history.yaml index 4808d65..ecd9d2e 100644 --- a/helm-charts/stocktrader/templates/trade-history.yaml +++ b/helm-charts/stocktrader/templates/trade-history.yaml @@ -53,6 +53,18 @@ spec: sidecar.istio.io/inject: 'true' {{- end }} spec: + affinity: + podAntiAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - weight: 1 + podAffinityTerm: + labelSelector: + matchExpressions: + - key: app + operator: In + values: + - trade-history + topologyKey: "kubernetes.io/hostname" {{- if .Values.global.pullSecret }} imagePullSecrets: - name: {{ tpl .Values.global.pullSecretName . }} @@ -214,6 +226,49 @@ spec: {{- if .Values.tradeHistory.autoscale }} --- #Deploy the autoscaler +{{- if .Capabilities.APIVersions.Has "autoscaling/v2" }} +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ .Release.Name }}-trade-history-hpa + labels: + app: stock-trader +spec: + behavior: + scaleUp: + stabilizationWindowSeconds: 0 + selectPolicy: Min + policies: + - type: Pods + value: 1 + periodSeconds: 15 + scaleDown: + stabilizationWindowSeconds: 300 + selectPolicy: Max + policies: + - type: Percent + value: 100 + periodSeconds: 120 + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ .Release.Name }}-trade-history + minReplicas: {{ .Values.tradeHistory.replicas }} + maxReplicas: {{ .Values.tradeHistory.maxReplicas }} + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.tradeHistory.cpuThreshold }} + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: 80 +{{- else }} apiVersion: autoscaling/v2beta2 kind: HorizontalPodAutoscaler metadata: @@ -242,7 +297,14 @@ spec: name: {{ .Release.Name }}-trade-history minReplicas: {{ .Values.tradeHistory.replicas }} maxReplicas: {{ .Values.tradeHistory.maxReplicas }} - targetCPUUtilizationPercentage: {{ .Values.tradeHistory.cpuThreshold }} + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.tradeHistory.cpuThreshold }} +{{- end }} {{- end }} --- #Deploy the service diff --git a/helm-charts/stocktrader/templates/trader.yaml b/helm-charts/stocktrader/templates/trader.yaml index f1809c4..4bd9b50 100644 --- a/helm-charts/stocktrader/templates/trader.yaml +++ b/helm-charts/stocktrader/templates/trader.yaml @@ -54,6 +54,18 @@ spec: sidecar.istio.io/inject: 'true' {{- end }} spec: + affinity: + podAntiAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - weight: 1 + podAffinityTerm: + labelSelector: + matchExpressions: + - key: app + operator: In + values: + - trader + topologyKey: "kubernetes.io/hostname" {{- if .Values.global.pullSecret }} imagePullSecrets: - name: {{ tpl .Values.global.pullSecretName . }} @@ -236,6 +248,49 @@ spec: {{- if .Values.trader.autoscale }} --- #Deploy the autoscaler +{{- if .Capabilities.APIVersions.Has "autoscaling/v2" }} +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ .Release.Name }}-trader-hpa + labels: + app: stock-trader +spec: + behavior: + scaleUp: + stabilizationWindowSeconds: 0 + selectPolicy: Min + policies: + - type: Pods + value: 1 + periodSeconds: 15 + scaleDown: + stabilizationWindowSeconds: 300 + selectPolicy: Max + policies: + - type: Percent + value: 100 + periodSeconds: 120 + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ .Release.Name }}-trader + minReplicas: {{ .Values.trader.replicas }} + maxReplicas: {{ .Values.trader.maxReplicas }} + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.trader.cpuThreshold }} + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: 80 +{{- else }} apiVersion: autoscaling/v2beta2 kind: HorizontalPodAutoscaler metadata: @@ -264,7 +319,14 @@ spec: name: {{ .Release.Name }}-trader minReplicas: {{ .Values.trader.replicas }} maxReplicas: {{ .Values.trader.maxReplicas }} - targetCPUUtilizationPercentage: {{ .Values.trader.cpuThreshold }} + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.trader.cpuThreshold }} +{{- end }} {{- end }} --- #Deploy the service diff --git a/helm-charts/stocktrader/templates/tradr.yaml b/helm-charts/stocktrader/templates/tradr.yaml index 46c31a8..3bbc59f 100644 --- a/helm-charts/stocktrader/templates/tradr.yaml +++ b/helm-charts/stocktrader/templates/tradr.yaml @@ -51,6 +51,18 @@ spec: sidecar.istio.io/inject: 'true' {{- end }} spec: + affinity: + podAntiAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - weight: 1 + podAffinityTerm: + labelSelector: + matchExpressions: + - key: app + operator: In + values: + - tradr + topologyKey: "kubernetes.io/hostname" {{- if .Values.global.pullSecret }} imagePullSecrets: - name: {{ tpl .Values.global.pullSecretName . }} @@ -143,6 +155,49 @@ spec: {{- if .Values.tradr.autoscale }} --- #Deploy the autoscaler +{{- if .Capabilities.APIVersions.Has "autoscaling/v2" }} +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ .Release.Name }}-tradr-hpa + labels: + app: stock-trader +spec: + behavior: + scaleUp: + stabilizationWindowSeconds: 0 + selectPolicy: Min + policies: + - type: Pods + value: 1 + periodSeconds: 15 + scaleDown: + stabilizationWindowSeconds: 300 + selectPolicy: Max + policies: + - type: Percent + value: 100 + periodSeconds: 120 + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ .Release.Name }}-tradr + minReplicas: {{ .Values.tradr.replicas }} + maxReplicas: {{ .Values.tradr.maxReplicas }} + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.tradr.cpuThreshold }} + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: 80 +{{- else }} apiVersion: autoscaling/v2beta2 kind: HorizontalPodAutoscaler metadata: @@ -171,7 +226,14 @@ spec: name: {{ .Release.Name }}-tradr minReplicas: {{ .Values.tradr.replicas }} maxReplicas: {{ .Values.tradr.maxReplicas }} - targetCPUUtilizationPercentage: {{ .Values.tradr.cpuThreshold }} + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.tradr.cpuThreshold }} +{{- end }} {{- end }} --- #Deploy the service diff --git a/helm-charts/stocktrader/values-metadata.yaml b/helm-charts/stocktrader/values-metadata.yaml index 116dfae..db9ac76 100644 --- a/helm-charts/stocktrader/values-metadata.yaml +++ b/helm-charts/stocktrader/values-metadata.yaml @@ -908,6 +908,11 @@ mq: value: "ibm-mq" - label: "Amazon MQ (Apache ActiveMQ)" value: "amazon-mq-apache-mq" + url: + __metadata: + label: "URL" + description: "Connection string with protocol(s) and port" + type: string host: __metadata: label: "Host" diff --git a/helm-charts/stocktrader/values.yaml b/helm-charts/stocktrader/values.yaml index b6f8802..29f6947 100644 --- a/helm-charts/stocktrader/values.yaml +++ b/helm-charts/stocktrader/values.yaml @@ -200,6 +200,7 @@ mq: kind: ibm-mq host: mqtrader1-mqtrader1 port: 1414 + url: ssl://mqtrader-amazonaws.com:61617 id: app password: "" queueManager: stocktrader diff --git a/old/deploy/crds/operators.ibm.com_stocktraders_crd.yaml b/old/deploy/crds/operators.ibm.com_stocktraders_crd.yaml index cf426e5..a46a8a6 100644 --- a/old/deploy/crds/operators.ibm.com_stocktraders_crd.yaml +++ b/old/deploy/crds/operators.ibm.com_stocktraders_crd.yaml @@ -427,11 +427,16 @@ spec: description: URL type: string mq: - description: IBM MQ settings (optional) + description: MQ settings (optional) type: object properties: + url: + description: >- + Connection string with protocol(s) and port + type: string host: - description: Host name (or IP address) + description: >- + Host name, connection string, or IP address type: string port: description: Port number diff --git a/old/deploy/crds/operators.ibm.com_v1_stocktrader_cr.yaml b/old/deploy/crds/operators.ibm.com_v1_stocktrader_cr.yaml index d602915..8d52f1d 100644 --- a/old/deploy/crds/operators.ibm.com_v1_stocktrader_cr.yaml +++ b/old/deploy/crds/operators.ibm.com_v1_stocktrader_cr.yaml @@ -119,6 +119,7 @@ spec: mq: host: mqtrader1-mqtrader1 port: 1414 + url: ssl://mqtrader-amazonaws.com:61617 id: app password: pwd queueManager: stocktrader diff --git a/old/deploy/olm-catalog/stocktrader-operator/0.1.0/stocktrader-operator.v0.1.0.clusterserviceversion.yaml b/old/deploy/olm-catalog/stocktrader-operator/0.1.0/stocktrader-operator.v0.1.0.clusterserviceversion.yaml index 777d91c..f4238db 100644 --- a/old/deploy/olm-catalog/stocktrader-operator/0.1.0/stocktrader-operator.v0.1.0.clusterserviceversion.yaml +++ b/old/deploy/olm-catalog/stocktrader-operator/0.1.0/stocktrader-operator.v0.1.0.clusterserviceversion.yaml @@ -165,6 +165,7 @@ metadata: "mq": { "host": "mqtrader1-mqtrader1", "port": 1414, + "url": "ssl://mqtrader-amazonaws.com:61617", "id": "app", "password": "pwd", "queueManager": "stocktrader", @@ -755,6 +756,12 @@ spec: x-descriptors: - urn:alm:descriptor:com.tectonic.ui:text - urn:alm:descriptor:com.tectonic.ui:fieldGroup:mq + - path: mq.url + description: Connection string for MQ + displayName: MQ connection string + x-descriptors: + - urn:alm:descriptor:com.tectonic.ui:text + - urn:alm:descriptor:com.tectonic.ui:fieldGroup:mq - path: mq.port description: Use the local port number (not the node port or Ingress port) if using an intra-cluster deployment of MQ displayName: Port number for MQ diff --git a/old/helm-charts/stocktrader/templates/account.yaml b/old/helm-charts/stocktrader/templates/account.yaml index ff669fa..4ae0c01 100644 --- a/old/helm-charts/stocktrader/templates/account.yaml +++ b/old/helm-charts/stocktrader/templates/account.yaml @@ -60,6 +60,11 @@ spec: configMapKeyRef: name: {{ .Release.Name }}-config key: mq.host + - name: MQ_URL + valueFrom: + configMapKeyRef: + name: {{ .Release.Name }}-config + key: mq.url - name: MQ_PORT valueFrom: configMapKeyRef: diff --git a/old/helm-charts/stocktrader/templates/config.yaml b/old/helm-charts/stocktrader/templates/config.yaml index 8f5e75c..677470f 100644 --- a/old/helm-charts/stocktrader/templates/config.yaml +++ b/old/helm-charts/stocktrader/templates/config.yaml @@ -41,6 +41,7 @@ data: database.port: "{{ .Values.database.port }}" database.db: {{ .Values.database.db }} mq.host: {{ .Values.mq.host }} + mq.url: "{{ .Values.mq.url }}" mq.port: "{{ .Values.mq.port }}" mq.queueManager: {{ .Values.mq.queueManager }} mq.queue: {{ .Values.mq.queue }} diff --git a/old/helm-charts/stocktrader/templates/messaging.yaml b/old/helm-charts/stocktrader/templates/messaging.yaml index e21628d..697a4d6 100644 --- a/old/helm-charts/stocktrader/templates/messaging.yaml +++ b/old/helm-charts/stocktrader/templates/messaging.yaml @@ -56,6 +56,11 @@ spec: configMapKeyRef: name: {{ .Release.Name }}-config key: mq.host + - name: MQ_URL + valueFrom: + configMapKeyRef: + name: {{ .Release.Name }}-config + key: mq.url - name: MQ_PORT valueFrom: configMapKeyRef: diff --git a/old/helm-charts/stocktrader/values-metadata.yaml b/old/helm-charts/stocktrader/values-metadata.yaml index ae24515..a114452 100644 --- a/old/helm-charts/stocktrader/values-metadata.yaml +++ b/old/helm-charts/stocktrader/values-metadata.yaml @@ -518,12 +518,17 @@ odm: type: string mq: __metadata: - label: "IBM MQ settings (optional)" + label: "MQ settings (optional)" description: "Configuration for MQ. Can be in-cluster, or external. Needed only if you want to receive notifications about changes in loyalty level" + url: + __metadata: + label: "URL" + description: "Connection string with protocol(s) and port" + type: string host: __metadata: label: "Host" - description: "Host name, or IP address, for MQ. Use the Kube DNS service name if using an intra-cluster deployment of MQ" + description: "Host name, connection string, or IP address" type: string port: __metadata: diff --git a/old/helm-charts/stocktrader/values.yaml b/old/helm-charts/stocktrader/values.yaml index 7c6dac5..1292454 100644 --- a/old/helm-charts/stocktrader/values.yaml +++ b/old/helm-charts/stocktrader/values.yaml @@ -123,6 +123,7 @@ odm: mq: host: mqtrader1-mqtrader1 port: 1414 + url: ssl://mqtrader-amazonaws.com:61617 id: app password: "" queueManager: stocktrader