From 99a3c474b9da1b3739659ca57d0fba7e2caa19b2 Mon Sep 17 00:00:00 2001 From: arshamparity Date: Wed, 28 Jul 2021 13:18:28 +0300 Subject: [PATCH] deploying the shard alongside the core --- helm/templates/NOTES.txt | 10 +-- .../{deployment.yaml => core-deployment.yaml} | 13 +++- helm/templates/core-service.yaml | 19 +++++ helm/templates/service.yaml | 15 ---- helm/templates/shard-deployment.yaml | 70 +++++++++++++++++++ helm/templates/shard-service.yaml | 20 ++++++ helm/values.yaml | 21 ++++-- 7 files changed, 141 insertions(+), 27 deletions(-) rename helm/templates/{deployment.yaml => core-deployment.yaml} (84%) create mode 100644 helm/templates/core-service.yaml delete mode 100644 helm/templates/service.yaml create mode 100644 helm/templates/shard-deployment.yaml create mode 100644 helm/templates/shard-service.yaml diff --git a/helm/templates/NOTES.txt b/helm/templates/NOTES.txt index dc2cac5..2100821 100644 --- a/helm/templates/NOTES.txt +++ b/helm/templates/NOTES.txt @@ -5,16 +5,16 @@ http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} {{- end }} {{- end }} -{{- else if contains "NodePort" .Values.service.type }} +{{- else if contains "NodePort" .Values.service.shard.type }} export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "substrate-telemetry.fullname" . }}) export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") echo http://$NODE_IP:$NODE_PORT -{{- else if contains "LoadBalancer" .Values.service.type }} +{{- else if contains "LoadBalancer" .Values.service.shard.type }} NOTE: It may take a few minutes for the LoadBalancer IP to be available. - You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "substrate-telemetry.fullname" . }}' + You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w telemetry-shard' export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "substrate-telemetry.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") - echo http://$SERVICE_IP:{{ .Values.service.port }} -{{- else if contains "ClusterIP" .Values.service.type }} + echo http://$SERVICE_IP:{{ .Values.service.shard.port }} +{{- else if contains "ClusterIP" .Values.service.shard.type }} export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "substrate-telemetry.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") echo "Visit http://127.0.0.1:8080 to use your application" diff --git a/helm/templates/deployment.yaml b/helm/templates/core-deployment.yaml similarity index 84% rename from helm/templates/deployment.yaml rename to helm/templates/core-deployment.yaml index 04a1205..e49eda4 100644 --- a/helm/templates/deployment.yaml +++ b/helm/templates/core-deployment.yaml @@ -1,12 +1,13 @@ apiVersion: apps/v1 kind: Deployment metadata: - name: {{ include "substrate-telemetry.fullname" . }} + name: telemetry-core labels: {{- include "substrate-telemetry.labels" . | nindent 4 }} + telemetry-component: core spec: {{- if not .Values.autoscaling.enabled }} - replicas: {{ .Values.replicaCount }} + replicas: {{ .Values.replicaCount.core }} {{- end }} selector: matchLabels: @@ -19,6 +20,7 @@ spec: {{- end }} labels: {{- include "substrate-telemetry.selectorLabels" . | nindent 8 }} + telemetry-component: core spec: {{- with .Values.imagePullSecrets }} imagePullSecrets: @@ -33,9 +35,14 @@ spec: {{- toYaml .Values.securityContext | nindent 12 }} image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" imagePullPolicy: {{ .Values.image.pullPolicy }} + command: + - "telemetry_core" + args: + - "--listen" + - "0.0.0.0:8000" ports: - name: http - containerPort: {{ .Values.service.targetPort }} + containerPort: {{ .Values.service.core.targetPort }} protocol: TCP #livenessProbe: # httpGet: diff --git a/helm/templates/core-service.yaml b/helm/templates/core-service.yaml new file mode 100644 index 0000000..c8472e2 --- /dev/null +++ b/helm/templates/core-service.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + name: telemetry-core + labels: + {{- include "substrate-telemetry.labels" . | nindent 4 }} + telemetry-component: core + annotations: + {{- toYaml .Values.service.core.annotations | nindent 4 }} +spec: + type: {{ .Values.service.core.type }} + ports: + - port: {{ .Values.service.core.port }} + targetPort: {{ .Values.service.core.targetPort }} + protocol: TCP + name: http + selector: + {{- include "substrate-telemetry.selectorLabels" . | nindent 4 }} + telemetry-component: core diff --git a/helm/templates/service.yaml b/helm/templates/service.yaml deleted file mode 100644 index 2ddb528..0000000 --- a/helm/templates/service.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: {{ include "substrate-telemetry.fullname" . }} - labels: - {{- include "substrate-telemetry.labels" . | nindent 4 }} -spec: - type: {{ .Values.service.type }} - ports: - - port: {{ .Values.service.port }} - targetPort: {{ .Values.service.targetPort }} - protocol: TCP - name: http - selector: - {{- include "substrate-telemetry.selectorLabels" . | nindent 4 }} diff --git a/helm/templates/shard-deployment.yaml b/helm/templates/shard-deployment.yaml new file mode 100644 index 0000000..c293721 --- /dev/null +++ b/helm/templates/shard-deployment.yaml @@ -0,0 +1,70 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: telemetry-shard + labels: + {{- include "substrate-telemetry.labels" . | nindent 4 }} + telemetry-component: shard +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount.shard }} + {{- end }} + selector: + matchLabels: + {{- include "substrate-telemetry.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "substrate-telemetry.selectorLabels" . | nindent 8 }} + telemetry-component: shard + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "substrate-telemetry.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + command: + - "telemetry_shard" + args: + - "--listen" + - "0.0.0.0:8000" + - "--core" + - "http://telemetry-core/shard_submit" + ports: + - name: http + containerPort: {{ .Values.service.shard.targetPort }} + protocol: TCP + #livenessProbe: + # httpGet: + # path: / + # port: http + #readinessProbe: + # httpGet: + # path: / + # port: http + resources: + {{- toYaml .Values.resources | nindent 12 }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/helm/templates/shard-service.yaml b/helm/templates/shard-service.yaml new file mode 100644 index 0000000..1149f84 --- /dev/null +++ b/helm/templates/shard-service.yaml @@ -0,0 +1,20 @@ +apiVersion: v1 +kind: Service +metadata: + name: telemetry-shard + labels: + {{- include "substrate-telemetry.labels" . | nindent 4 }} + telemetry-component: shard + annotations: + {{- toYaml .Values.service.shard.annotations | nindent 4 }} + +spec: + type: {{ .Values.service.shard.type }} + ports: + - port: {{ .Values.service.shard.port }} + targetPort: {{ .Values.service.shard.targetPort }} + protocol: TCP + name: http + selector: + {{- include "substrate-telemetry.selectorLabels" . | nindent 4 }} + telemetry-component: shard diff --git a/helm/values.yaml b/helm/values.yaml index 854e8ad..bf6ec7c 100644 --- a/helm/values.yaml +++ b/helm/values.yaml @@ -2,7 +2,9 @@ # This is a YAML-formatted file. # Declare variables to be passed into your templates. -replicaCount: 3 +replicaCount: + shard: 3 + core: 1 image: repository: parity/substrate-telemetry-backend @@ -37,9 +39,20 @@ securityContext: {} # runAsUser: 1000 service: - type: LoadBalancer - port: 80 - targetPort: 3000 + shard: + type: LoadBalancer + port: 80 + targetPort: 8000 + annotations: + cloud.google.com/load-balancer-type: Internal + networking.gke.io/internal-load-balancer-allow-global-access: "true" + external-dns.alpha.kubernetes.io/hostname: substrate-telemetry.parity-stg.parity.io. + core: + type: ClusterIP + port: 80 + targetPort: 8000 + annotations: {} + ingress: enabled: false