From 9f32a901ec5ae46aba52c512ccf320f5b0b2e159 Mon Sep 17 00:00:00 2001 From: weideng1 Date: Wed, 14 Dec 2022 12:57:29 -0700 Subject: [PATCH 01/22] initial collection of helm charts to deploy zdm into k8s --- k8s_helm_charts/zdm/.helmignore | 23 ++++ k8s_helm_charts/zdm/Chart.yaml | 24 ++++ k8s_helm_charts/zdm/templates/_helpers.tpl | 60 ++++++++++ k8s_helm_charts/zdm/templates/configmap.yaml | 13 +++ k8s_helm_charts/zdm/templates/deployment.yaml | 104 ++++++++++++++++++ k8s_helm_charts/zdm/templates/secrets.yaml | 10 ++ k8s_helm_charts/zdm/templates/service.yaml | 26 +++++ k8s_helm_charts/zdm/values.yaml | 34 ++++++ 8 files changed, 294 insertions(+) create mode 100644 k8s_helm_charts/zdm/.helmignore create mode 100644 k8s_helm_charts/zdm/Chart.yaml create mode 100644 k8s_helm_charts/zdm/templates/_helpers.tpl create mode 100644 k8s_helm_charts/zdm/templates/configmap.yaml create mode 100644 k8s_helm_charts/zdm/templates/deployment.yaml create mode 100644 k8s_helm_charts/zdm/templates/secrets.yaml create mode 100644 k8s_helm_charts/zdm/templates/service.yaml create mode 100644 k8s_helm_charts/zdm/values.yaml diff --git a/k8s_helm_charts/zdm/.helmignore b/k8s_helm_charts/zdm/.helmignore new file mode 100644 index 00000000..0e8a0eb3 --- /dev/null +++ b/k8s_helm_charts/zdm/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/k8s_helm_charts/zdm/Chart.yaml b/k8s_helm_charts/zdm/Chart.yaml new file mode 100644 index 00000000..c7a49506 --- /dev/null +++ b/k8s_helm_charts/zdm/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: zdm +description: A Helm chart for Zero Downtime Migration + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 0.1.0 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +appVersion: "2.0.x" diff --git a/k8s_helm_charts/zdm/templates/_helpers.tpl b/k8s_helm_charts/zdm/templates/_helpers.tpl new file mode 100644 index 00000000..7ae5c2dc --- /dev/null +++ b/k8s_helm_charts/zdm/templates/_helpers.tpl @@ -0,0 +1,60 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "zdm.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "zdm.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "zdm.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "zdm.labels" -}} +{{ include "zdm.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "zdm.selectorLabels" -}} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "zdm.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "zdm.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/k8s_helm_charts/zdm/templates/configmap.yaml b/k8s_helm_charts/zdm/templates/configmap.yaml new file mode 100644 index 00000000..10cda9a0 --- /dev/null +++ b/k8s_helm_charts/zdm/templates/configmap.yaml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ include "zdm.fullname" . }} + namespace: {{ .Values.namespace }} +data: + ZDM_ORIGIN_PORT: "9042" + ZDM_TARGET_PORT: "9042" + ZDM_PRIMARY_CLUSTER: ORIGIN + ZDM_READ_MODE: PRIMARY_ONLY + ZDM_LOG_LEVEL: INFO + ZDM_PROXY_MAX_CLIENT_CONNECTIONS: "1000" + ZDM_METRICS_ENABLED: "true" diff --git a/k8s_helm_charts/zdm/templates/deployment.yaml b/k8s_helm_charts/zdm/templates/deployment.yaml new file mode 100644 index 00000000..8364ef46 --- /dev/null +++ b/k8s_helm_charts/zdm/templates/deployment.yaml @@ -0,0 +1,104 @@ +# calculate a variable that contains all proxy service addresses +{{ $service_addresses := "" -}} +{{- range $index := until (.Values.proxy.count | int) -}} + {{- $service_addresses = printf "%s,$(ZDM_PROXY_%s_SERVICE_HOST)" $service_addresses ($index | toString) -}} +{{- end -}} +{{- $service_addresses = $service_addresses | trimPrefix "," -}} + +# pull in these templates outside of range loop +{{ $zdm_fullname := include "zdm.fullname" . -}} +{{- $zdm_labels := include "zdm.labels" . -}} +{{- $zdm_selectorLabels := include "zdm.selectorLabels" . -}} + +{{- range $index := until (.Values.proxy.count | int) -}} +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + {{- $zdm_labels | nindent 4 }} + app: {{ $zdm_fullname }}-{{ $index }} + name: {{ $zdm_fullname }}-{{ $index }} + namespace: {{ $.Values.namespace }} +spec: + replicas: 1 + selector: + matchLabels: + {{- $zdm_selectorLabels | nindent 6 }} + app: {{ $zdm_fullname }}-{{ $index }} + template: + metadata: + labels: + {{- $zdm_selectorLabels | nindent 8 }} + app: {{ $zdm_fullname }}-{{ $index }} + spec: + containers: + - image: datastax/zdm-proxy:2.0.x + name: {{ $zdm_fullname }}-{{ $index }} + resources: + requests: + memory: {{ $.Values.proxy.resources.requests.memory | quote }} + cpu: {{ $.Values.proxy.resources.requests.cpu | quote }} + limits: + memory: {{ $.Values.proxy.resources.limits.memory | quote }} + cpu: {{ $.Values.proxy.resources.limits.cpu | quote }} + envFrom: + - configMapRef: + name: {{ $zdm_fullname }} + env: + - name: ZDM_PROXY_LISTEN_ADDRESS + valueFrom: + fieldRef: + fieldPath: status.podIP + - name: ZDM_PROXY_LISTEN_PORT + value: "9042" + - name: ZDM_METRICS_ADDRESS + valueFrom: + fieldRef: + fieldPath: status.podIP + - name: ZDM_METRICS_PORT + value: "14001" + - name: ZDM_PROXY_TOPOLOGY_INDEX + value: {{ $index | quote }} + - name: ZDM_PROXY_TOPOLOGY_ADDRESSES + value: {{ $service_addresses }} + - name: ZDM_ORIGIN_SECURE_CONNECT_BUNDLE_PATH + value: /tmp/scb/origin.zip + - name: ZDM_TARGET_SECURE_CONNECT_BUNDLE_PATH + value: /tmp/scb/target.zip + - name: ZDM_ORIGIN_USERNAME + valueFrom: + secretKeyRef: + name: {{ $zdm_fullname }} + key: ORIGIN_USERNAME + - name: ZDM_ORIGIN_PASSWORD + valueFrom: + secretKeyRef: + name: {{ $zdm_fullname }} + key: ORIGIN_PASSWORD + - name: ZDM_TARGET_USERNAME + valueFrom: + secretKeyRef: + name: {{ $zdm_fullname }} + key: TARGET_USERNAME + - name: ZDM_TARGET_PASSWORD + valueFrom: + secretKeyRef: + name: {{ $zdm_fullname }} + key: TARGET_PASSWORD + ports: + - containerPort: 9042 + volumeMounts: + - name: scb + mountPath: "/tmp/scb" + readOnly: true + volumes: + - name: scb + secret: + secretName: zdmproxy-scb + items: + - key: secure-connect-origin.zip + path: origin.zip + - key: secure-connect-target.zip + path: target.zip +--- +{{- end -}} diff --git a/k8s_helm_charts/zdm/templates/secrets.yaml b/k8s_helm_charts/zdm/templates/secrets.yaml new file mode 100644 index 00000000..36153b32 --- /dev/null +++ b/k8s_helm_charts/zdm/templates/secrets.yaml @@ -0,0 +1,10 @@ +apiVersion: v1 +data: + ORIGIN_PASSWORD: {{ .Values.origin_password | b64enc | quote | default "Y2Fzc2FuZHJhCg==" }} + ORIGIN_USERNAME: {{ .Values.origin_username | b64enc | quote | default "Y2Fzc2FuZHJhCg==" }} + TARGET_PASSWORD: {{ .Values.target_password | b64enc | quote | default "Y2Fzc2FuZHJhCg==" }} + TARGET_USERNAME: {{ .Values.target_username | b64enc | quote | default "Y2Fzc2FuZHJhCg==" }} +kind: Secret +metadata: + name: {{ include "zdm.fullname" . }} + namespace: {{ .Values.namespace }} diff --git a/k8s_helm_charts/zdm/templates/service.yaml b/k8s_helm_charts/zdm/templates/service.yaml new file mode 100644 index 00000000..f13de8b1 --- /dev/null +++ b/k8s_helm_charts/zdm/templates/service.yaml @@ -0,0 +1,26 @@ +# pull in these templates outside of range loop +{{ $zdm_fullname := include "zdm.fullname" . -}} +{{- $zdm_labels := include "zdm.labels" . -}} +{{- $zdm_selectorLabels := include "zdm.selectorLabels" . -}} +{{- range $index := until (.Values.proxy.count | int) -}} +apiVersion: v1 +kind: Service +metadata: + namespace: {{ $.Values.namespace }} + name: {{ $zdm_fullname }}-{{ $index }} + labels: + {{- $zdm_labels | nindent 4 }} + app: {{ $zdm_fullname }}-{{ $index }} + role: zdmproxy +spec: + type: {{ $.Values.service.type }} + ports: + - port: {{ $.Values.service.port | int }} + targetPort: 9042 + protocol: TCP + name: cql + selector: + {{- $zdm_selectorLabels | nindent 4 }} + app: {{ $zdm_fullname }}-{{ $index }} +--- +{{- end -}} diff --git a/k8s_helm_charts/zdm/values.yaml b/k8s_helm_charts/zdm/values.yaml new file mode 100644 index 00000000..82107d95 --- /dev/null +++ b/k8s_helm_charts/zdm/values.yaml @@ -0,0 +1,34 @@ +# Default values for zdm. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +namespace: zdmproxy + +origin_username: +origin_password: +target_username: +target_password: + +proxy: + count: 3 + resources: + limits: + cpu: 2000m + memory: 512Mi + requests: + cpu: 1000m + memory: 512Mi + +image: + repository: datastax/zdm-proxy + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "" + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +service: + type: ClusterIP + port: 9942 From 9896ee15886f95498d450900dd6c9bb0aeff32b9 Mon Sep 17 00:00:00 2001 From: weideng1 Date: Wed, 14 Dec 2022 13:05:43 -0700 Subject: [PATCH 02/22] added README file --- k8s_helm_charts/README.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 k8s_helm_charts/README.md diff --git a/k8s_helm_charts/README.md b/k8s_helm_charts/README.md new file mode 100644 index 00000000..e5258384 --- /dev/null +++ b/k8s_helm_charts/README.md @@ -0,0 +1,20 @@ +Usage: +1. Create dedicated namespace for zdmproxy. + + ```kubectl create ns zdmproxy``` + +2. Import Secure Connect Bundle into a k8s secret called zdmproxy-scb. + + ```kubectl -n zdmproxy create secret generic zdmproxy-scb --from-file=/tmp/secure-connect-origin.zip --from-file=/tmp/secure-connect-target.zip``` + +3. Run helm install to deploy the helm charts. + + ```helm -n zdmproxy install --set origin_username="$prod_astra_user" --set origin_password="$prod_astra_escaped_password" --set target_username="$prod_astra_user" --set target_password="$prod_astra_escaped_password" zdm-proxy ./zdm``` + +4. Verify that all components are up and running. + + ```kubectl -n zdmproxy get svc,cm,secret,deploy,po -o wide --show-labels``` + +5. When you're done, run helm uninstall to remove all objects. + + ```helm uninstall zdm-proxy``` From e84293583e8e4e7da3072eb71ffcb11ed155a83d Mon Sep 17 00:00:00 2001 From: weideng1 Date: Wed, 14 Dec 2022 13:19:12 -0700 Subject: [PATCH 03/22] pull zdm-proxy docker image version from helm chart's AppVersion --- k8s_helm_charts/zdm/templates/deployment.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/k8s_helm_charts/zdm/templates/deployment.yaml b/k8s_helm_charts/zdm/templates/deployment.yaml index 8364ef46..e06db3af 100644 --- a/k8s_helm_charts/zdm/templates/deployment.yaml +++ b/k8s_helm_charts/zdm/templates/deployment.yaml @@ -32,7 +32,7 @@ spec: app: {{ $zdm_fullname }}-{{ $index }} spec: containers: - - image: datastax/zdm-proxy:2.0.x + - image: "{{ $.Values.image.repository }}:{{ $.Values.image.tag | default $.Chart.AppVersion }}" name: {{ $zdm_fullname }}-{{ $index }} resources: requests: From 29b0b4d3a73c0dc1446f992d715f371c922a001a Mon Sep 17 00:00:00 2001 From: weideng1 Date: Wed, 14 Dec 2022 13:35:21 -0700 Subject: [PATCH 04/22] fixed a bug so release name can be customized now --- k8s_helm_charts/zdm/templates/deployment.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/k8s_helm_charts/zdm/templates/deployment.yaml b/k8s_helm_charts/zdm/templates/deployment.yaml index e06db3af..61673e71 100644 --- a/k8s_helm_charts/zdm/templates/deployment.yaml +++ b/k8s_helm_charts/zdm/templates/deployment.yaml @@ -1,15 +1,15 @@ +# pull in these templates outside of range loop +{{ $zdm_fullname := include "zdm.fullname" . -}} +{{- $zdm_labels := include "zdm.labels" . -}} +{{- $zdm_selectorLabels := include "zdm.selectorLabels" . -}} + # calculate a variable that contains all proxy service addresses {{ $service_addresses := "" -}} {{- range $index := until (.Values.proxy.count | int) -}} - {{- $service_addresses = printf "%s,$(ZDM_PROXY_%s_SERVICE_HOST)" $service_addresses ($index | toString) -}} + {{- $service_addresses = printf "%s,$(%s_%s_SERVICE_HOST)" $service_addresses ($zdm_fullname | upper | replace "-" "_") ($index | toString) -}} {{- end -}} {{- $service_addresses = $service_addresses | trimPrefix "," -}} -# pull in these templates outside of range loop -{{ $zdm_fullname := include "zdm.fullname" . -}} -{{- $zdm_labels := include "zdm.labels" . -}} -{{- $zdm_selectorLabels := include "zdm.selectorLabels" . -}} - {{- range $index := until (.Values.proxy.count | int) -}} apiVersion: apps/v1 kind: Deployment From 3d46813db47177e0122ba99992cb6dd210b4d299 Mon Sep 17 00:00:00 2001 From: weideng1 Date: Wed, 14 Dec 2022 18:00:29 -0700 Subject: [PATCH 05/22] added a big more verification info in README --- k8s_helm_charts/README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/k8s_helm_charts/README.md b/k8s_helm_charts/README.md index e5258384..196193e2 100644 --- a/k8s_helm_charts/README.md +++ b/k8s_helm_charts/README.md @@ -15,6 +15,13 @@ Usage: ```kubectl -n zdmproxy get svc,cm,secret,deploy,po -o wide --show-labels``` + You can also run ```kubectl -n zdmproxy logs pod/zdm-proxy-0-xxxxxxx``` to see if there are the following entries in the log, which means everything is working as expected: + + ``` + time="2022-12-14T21:19:57Z" level=info msg="Proxy connected and ready to accept queries on 172.25.132.116:9042" + time="2022-12-14T21:19:57Z" level=info msg="Proxy started. Waiting for SIGINT/SIGTERM to shutdown." + ``` + 5. When you're done, run helm uninstall to remove all objects. ```helm uninstall zdm-proxy``` From 0e765f3cfa0bf33c40ce6c349dceeb6fa2734061 Mon Sep 17 00:00:00 2001 From: weideng1 Date: Wed, 14 Dec 2022 19:00:31 -0700 Subject: [PATCH 06/22] added Cassandra Data Migrator (CDM) to the helm chart and adjusted hirearchy of some helm values --- k8s_helm_charts/zdm/templates/cdm.yaml | 64 +++++++++++++++++++ k8s_helm_charts/zdm/templates/deployment.yaml | 2 +- k8s_helm_charts/zdm/values.yaml | 22 +++++-- 3 files changed, 81 insertions(+), 7 deletions(-) create mode 100644 k8s_helm_charts/zdm/templates/cdm.yaml diff --git a/k8s_helm_charts/zdm/templates/cdm.yaml b/k8s_helm_charts/zdm/templates/cdm.yaml new file mode 100644 index 00000000..f216fbab --- /dev/null +++ b/k8s_helm_charts/zdm/templates/cdm.yaml @@ -0,0 +1,64 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + app: cdm + name: cdm-1 + namespace: {{ .Values.namespace }} +spec: + replicas: 1 + selector: + matchLabels: + app: cdm-1 + template: + metadata: + labels: + app: cdm-1 + spec: + containers: + - name: cdm-1 + image: {{ .Values.cdm.image.repository }}:{{ .Values.cdm.image.tag }} + resources: + requests: + memory: {{ .Values.cdm.resources.requests.memory }} + cpu: {{ .Values.cdm.resources.requests.cpu }} + limits: + memory: {{ .Values.cdm.resources.limits.memory }} + cpu: {{ .Values.cdm.resources.limits.cpu }} + envFrom: + - configMapRef: + name: {{ include "zdm.fullname" . }} + env: + - name: ZDM_TARGET_SECURE_CONNECT_BUNDLE_PATH + value: /tmp/scb/target.zip + - name: ZDM_ORIGIN_USERNAME + valueFrom: + secretKeyRef: + name: {{ include "zdm.fullname" . }} + key: ORIGIN_USERNAME + - name: ZDM_ORIGIN_PASSWORD + valueFrom: + secretKeyRef: + name: {{ include "zdm.fullname" . }} + key: ORIGIN_PASSWORD + - name: ZDM_TARGET_USERNAME + valueFrom: + secretKeyRef: + name: {{ include "zdm.fullname" . }} + key: TARGET_USERNAME + - name: ZDM_TARGET_PASSWORD + valueFrom: + secretKeyRef: + name: {{ include "zdm.fullname" . }} + key: TARGET_PASSWORD + volumeMounts: + - name: scb + mountPath: "/tmp/scb" + readOnly: true + volumes: + - name: scb + secret: + secretName: zdmproxy-scb + items: + - key: secure-connect-target.zip + path: target.zip diff --git a/k8s_helm_charts/zdm/templates/deployment.yaml b/k8s_helm_charts/zdm/templates/deployment.yaml index 61673e71..c6d427df 100644 --- a/k8s_helm_charts/zdm/templates/deployment.yaml +++ b/k8s_helm_charts/zdm/templates/deployment.yaml @@ -32,7 +32,7 @@ spec: app: {{ $zdm_fullname }}-{{ $index }} spec: containers: - - image: "{{ $.Values.image.repository }}:{{ $.Values.image.tag | default $.Chart.AppVersion }}" + - image: "{{ $.Values.proxy.image.repository }}:{{ $.Values.proxy.image.tag | default $.Chart.AppVersion }}" name: {{ $zdm_fullname }}-{{ $index }} resources: requests: diff --git a/k8s_helm_charts/zdm/values.yaml b/k8s_helm_charts/zdm/values.yaml index 82107d95..9553e3f1 100644 --- a/k8s_helm_charts/zdm/values.yaml +++ b/k8s_helm_charts/zdm/values.yaml @@ -18,14 +18,24 @@ proxy: requests: cpu: 1000m memory: 512Mi + image: + repository: datastax/zdm-proxy + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "" -image: - repository: datastax/zdm-proxy - pullPolicy: IfNotPresent - # Overrides the image tag whose default is the chart appVersion. - tag: "" +cdm: + resources: + limits: + cpu: 2000m + memory: 4096Mi + requests: + cpu: 1000m + memory: 2048Mi + image: + repository: datastax/cassandra-data-migrator + tag: 2.10.2 -imagePullSecrets: [] nameOverride: "" fullnameOverride: "" From 9647c8794b502bac462eca5a0fe03cfcd516f191 Mon Sep 17 00:00:00 2001 From: weideng1 Date: Wed, 14 Dec 2022 22:34:35 -0700 Subject: [PATCH 07/22] use cdm image 2.10.3 to solve python3 dependency --- k8s_helm_charts/zdm/values.yaml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/k8s_helm_charts/zdm/values.yaml b/k8s_helm_charts/zdm/values.yaml index 9553e3f1..43f73728 100644 --- a/k8s_helm_charts/zdm/values.yaml +++ b/k8s_helm_charts/zdm/values.yaml @@ -13,11 +13,11 @@ proxy: count: 3 resources: limits: - cpu: 2000m - memory: 512Mi + cpu: 4000m + memory: 8192Mi requests: - cpu: 1000m - memory: 512Mi + cpu: 4000m + memory: 8192Mi image: repository: datastax/zdm-proxy pullPolicy: IfNotPresent @@ -27,14 +27,14 @@ proxy: cdm: resources: limits: - cpu: 2000m - memory: 4096Mi + cpu: 16000m + memory: 32768Mi requests: - cpu: 1000m - memory: 2048Mi + cpu: 16000m + memory: 32768Mi image: repository: datastax/cassandra-data-migrator - tag: 2.10.2 + tag: 2.10.3 nameOverride: "" fullnameOverride: "" From 83a7cc620d2500d142ce0bb3f106173c6dc6f8af Mon Sep 17 00:00:00 2001 From: weideng1 Date: Wed, 14 Dec 2022 22:42:53 -0700 Subject: [PATCH 08/22] modify README instructions for local dev machine --- k8s_helm_charts/README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/k8s_helm_charts/README.md b/k8s_helm_charts/README.md index 196193e2..8f85bf40 100644 --- a/k8s_helm_charts/README.md +++ b/k8s_helm_charts/README.md @@ -11,6 +11,12 @@ Usage: ```helm -n zdmproxy install --set origin_username="$prod_astra_user" --set origin_password="$prod_astra_escaped_password" --set target_username="$prod_astra_user" --set target_password="$prod_astra_escaped_password" zdm-proxy ./zdm``` + The default resource allocations _(memory and cpu) are designed for production environment, if you see pods pending due to not enough resources, try to use the following commands instead: + + ```helm -n zdmproxy uninstall zdm-proxy``` + + ```helm -n zdmproxy install --set origin_username="$prod_astra_user" --set origin_password="$prod_astra_escaped_password" --set target_username="$prod_astra_user" --set target_password="$prod_astra_escaped_password" --set proxy.resources.requests.cpu=1000m --set proxy.resources.requests.memory=2000Mi --set proxy.resources.limits.cpu=1000m --set proxy.resources.limits.memory=2000Mi --set cdm.resources.requests.cpu=1000m --set cdm.resources.requests.memory=2000Mi --set cdm.resources.limits.cpu=1000m --set cdm.resources.limits.memory=2000Mi zdm-proxy ./zdm``` + 4. Verify that all components are up and running. ```kubectl -n zdmproxy get svc,cm,secret,deploy,po -o wide --show-labels``` From bb8c038a4c5487d256218f4afda982ab885960bb Mon Sep 17 00:00:00 2001 From: weideng1 Date: Thu, 15 Dec 2022 00:01:52 -0700 Subject: [PATCH 09/22] changed README instructions to move secrets lifecycle outside of helm, so helm is no longer managing it --- k8s_helm_charts/README.md | 10 +++++--- k8s_helm_charts/zdm/templates/cdm.yaml | 21 ++++++++++------ k8s_helm_charts/zdm/templates/deployment.yaml | 25 ++++++++++--------- k8s_helm_charts/zdm/templates/secrets.yaml | 10 -------- 4 files changed, 33 insertions(+), 33 deletions(-) delete mode 100644 k8s_helm_charts/zdm/templates/secrets.yaml diff --git a/k8s_helm_charts/README.md b/k8s_helm_charts/README.md index 8f85bf40..592bbac0 100644 --- a/k8s_helm_charts/README.md +++ b/k8s_helm_charts/README.md @@ -5,17 +5,21 @@ Usage: 2. Import Secure Connect Bundle into a k8s secret called zdmproxy-scb. - ```kubectl -n zdmproxy create secret generic zdmproxy-scb --from-file=/tmp/secure-connect-origin.zip --from-file=/tmp/secure-connect-target.zip``` + ```kubectl -n zdmproxy create secret generic zdmproxy-scb --from-file=/tmp/secure-connect-target.zip``` + + Import Origin contact points, Origin username and password, Target/Astra client ID and client Secret into another k8s secret called zdmproxy. + + ```kubectl -n zdmproxy create secret generic zdmproxy --from-literal=origin_contact_points="$origin_contact_points" --from-literal=origin_username="$origin_username" --from-literal=origin_password="$origin_password" --from-literal=target_username="$prod_astra_user" --from-literal=target_password="$prod_astra_password"``` 3. Run helm install to deploy the helm charts. - ```helm -n zdmproxy install --set origin_username="$prod_astra_user" --set origin_password="$prod_astra_escaped_password" --set target_username="$prod_astra_user" --set target_password="$prod_astra_escaped_password" zdm-proxy ./zdm``` + ```helm -n zdmproxy install zdm-proxy ./zdm``` The default resource allocations _(memory and cpu) are designed for production environment, if you see pods pending due to not enough resources, try to use the following commands instead: ```helm -n zdmproxy uninstall zdm-proxy``` - ```helm -n zdmproxy install --set origin_username="$prod_astra_user" --set origin_password="$prod_astra_escaped_password" --set target_username="$prod_astra_user" --set target_password="$prod_astra_escaped_password" --set proxy.resources.requests.cpu=1000m --set proxy.resources.requests.memory=2000Mi --set proxy.resources.limits.cpu=1000m --set proxy.resources.limits.memory=2000Mi --set cdm.resources.requests.cpu=1000m --set cdm.resources.requests.memory=2000Mi --set cdm.resources.limits.cpu=1000m --set cdm.resources.limits.memory=2000Mi zdm-proxy ./zdm``` + ```helm -n zdmproxy install --set proxy.resources.requests.cpu=1000m --set proxy.resources.requests.memory=2000Mi --set proxy.resources.limits.cpu=1000m --set proxy.resources.limits.memory=2000Mi --set cdm.resources.requests.cpu=1000m --set cdm.resources.requests.memory=2000Mi --set cdm.resources.limits.cpu=1000m --set cdm.resources.limits.memory=2000Mi zdm-proxy ./zdm``` 4. Verify that all components are up and running. diff --git a/k8s_helm_charts/zdm/templates/cdm.yaml b/k8s_helm_charts/zdm/templates/cdm.yaml index f216fbab..25721e81 100644 --- a/k8s_helm_charts/zdm/templates/cdm.yaml +++ b/k8s_helm_charts/zdm/templates/cdm.yaml @@ -31,26 +31,31 @@ spec: env: - name: ZDM_TARGET_SECURE_CONNECT_BUNDLE_PATH value: /tmp/scb/target.zip + - name: ZDM_ORIGIN_CONTACT_POINTS + valueFrom: + secretKeyRef: + name: zdmproxy + key: origin_contact_points - name: ZDM_ORIGIN_USERNAME valueFrom: secretKeyRef: - name: {{ include "zdm.fullname" . }} - key: ORIGIN_USERNAME + name: zdmproxy + key: origin_username - name: ZDM_ORIGIN_PASSWORD valueFrom: secretKeyRef: - name: {{ include "zdm.fullname" . }} - key: ORIGIN_PASSWORD + name: zdmproxy + key: origin_password - name: ZDM_TARGET_USERNAME valueFrom: secretKeyRef: - name: {{ include "zdm.fullname" . }} - key: TARGET_USERNAME + name: zdmproxy + key: target_username - name: ZDM_TARGET_PASSWORD valueFrom: secretKeyRef: - name: {{ include "zdm.fullname" . }} - key: TARGET_PASSWORD + name: zdmproxy + key: target_password volumeMounts: - name: scb mountPath: "/tmp/scb" diff --git a/k8s_helm_charts/zdm/templates/deployment.yaml b/k8s_helm_charts/zdm/templates/deployment.yaml index c6d427df..1b2a7c0e 100644 --- a/k8s_helm_charts/zdm/templates/deployment.yaml +++ b/k8s_helm_charts/zdm/templates/deployment.yaml @@ -61,30 +61,33 @@ spec: value: {{ $index | quote }} - name: ZDM_PROXY_TOPOLOGY_ADDRESSES value: {{ $service_addresses }} - - name: ZDM_ORIGIN_SECURE_CONNECT_BUNDLE_PATH - value: /tmp/scb/origin.zip - name: ZDM_TARGET_SECURE_CONNECT_BUNDLE_PATH value: /tmp/scb/target.zip + - name: ZDM_ORIGIN_CONTACT_POINTS + valueFrom: + secretKeyRef: + name: zdmproxy + key: origin_contact_points - name: ZDM_ORIGIN_USERNAME valueFrom: secretKeyRef: - name: {{ $zdm_fullname }} - key: ORIGIN_USERNAME + name: zdmproxy + key: origin_username - name: ZDM_ORIGIN_PASSWORD valueFrom: secretKeyRef: - name: {{ $zdm_fullname }} - key: ORIGIN_PASSWORD + name: zdmproxy + key: origin_password - name: ZDM_TARGET_USERNAME valueFrom: secretKeyRef: - name: {{ $zdm_fullname }} - key: TARGET_USERNAME + name: zdmproxy + key: target_username - name: ZDM_TARGET_PASSWORD valueFrom: secretKeyRef: - name: {{ $zdm_fullname }} - key: TARGET_PASSWORD + name: zdmproxy + key: target_password ports: - containerPort: 9042 volumeMounts: @@ -96,8 +99,6 @@ spec: secret: secretName: zdmproxy-scb items: - - key: secure-connect-origin.zip - path: origin.zip - key: secure-connect-target.zip path: target.zip --- diff --git a/k8s_helm_charts/zdm/templates/secrets.yaml b/k8s_helm_charts/zdm/templates/secrets.yaml deleted file mode 100644 index 36153b32..00000000 --- a/k8s_helm_charts/zdm/templates/secrets.yaml +++ /dev/null @@ -1,10 +0,0 @@ -apiVersion: v1 -data: - ORIGIN_PASSWORD: {{ .Values.origin_password | b64enc | quote | default "Y2Fzc2FuZHJhCg==" }} - ORIGIN_USERNAME: {{ .Values.origin_username | b64enc | quote | default "Y2Fzc2FuZHJhCg==" }} - TARGET_PASSWORD: {{ .Values.target_password | b64enc | quote | default "Y2Fzc2FuZHJhCg==" }} - TARGET_USERNAME: {{ .Values.target_username | b64enc | quote | default "Y2Fzc2FuZHJhCg==" }} -kind: Secret -metadata: - name: {{ include "zdm.fullname" . }} - namespace: {{ .Values.namespace }} From 461139e1585b5d87dc4f02c4ce254aff6c879983 Mon Sep 17 00:00:00 2001 From: weideng1 Date: Thu, 15 Dec 2022 00:04:44 -0700 Subject: [PATCH 10/22] address another small comment from Jim --- k8s_helm_charts/zdm/templates/cdm.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/k8s_helm_charts/zdm/templates/cdm.yaml b/k8s_helm_charts/zdm/templates/cdm.yaml index 25721e81..6463c16b 100644 --- a/k8s_helm_charts/zdm/templates/cdm.yaml +++ b/k8s_helm_charts/zdm/templates/cdm.yaml @@ -3,20 +3,20 @@ kind: Deployment metadata: labels: app: cdm - name: cdm-1 + name: cdm namespace: {{ .Values.namespace }} spec: replicas: 1 selector: matchLabels: - app: cdm-1 + app: cdm template: metadata: labels: - app: cdm-1 + app: cdm spec: containers: - - name: cdm-1 + - name: cdm image: {{ .Values.cdm.image.repository }}:{{ .Values.cdm.image.tag }} resources: requests: From 7235572e3c889aaa345659699a4013ffc3f1d852 Mon Sep 17 00:00:00 2001 From: weideng1 Date: Thu, 15 Dec 2022 00:18:02 -0700 Subject: [PATCH 11/22] move ZDM_ORIGIN_PORT from configmap to secret, which is preset before helm --- k8s_helm_charts/README.md | 4 ++-- k8s_helm_charts/zdm/templates/configmap.yaml | 1 - k8s_helm_charts/zdm/templates/deployment.yaml | 5 +++++ k8s_helm_charts/zdm/values.yaml | 5 ----- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/k8s_helm_charts/README.md b/k8s_helm_charts/README.md index 592bbac0..6aaf26c2 100644 --- a/k8s_helm_charts/README.md +++ b/k8s_helm_charts/README.md @@ -7,9 +7,9 @@ Usage: ```kubectl -n zdmproxy create secret generic zdmproxy-scb --from-file=/tmp/secure-connect-target.zip``` - Import Origin contact points, Origin username and password, Target/Astra client ID and client Secret into another k8s secret called zdmproxy. + Import Origin contact points, Origin port, Origin username and password, Target/Astra client ID and client Secret into another k8s secret called zdmproxy. - ```kubectl -n zdmproxy create secret generic zdmproxy --from-literal=origin_contact_points="$origin_contact_points" --from-literal=origin_username="$origin_username" --from-literal=origin_password="$origin_password" --from-literal=target_username="$prod_astra_user" --from-literal=target_password="$prod_astra_password"``` + ```kubectl -n zdmproxy create secret generic zdmproxy --from-literal=origin_contact_points="$origin_contact_points" --from-literal=origin_port="$origin_port" --from-literal=origin_username="$origin_username" --from-literal=origin_password="$origin_password" --from-literal=target_username="$prod_astra_user" --from-literal=target_password="$prod_astra_password"``` 3. Run helm install to deploy the helm charts. diff --git a/k8s_helm_charts/zdm/templates/configmap.yaml b/k8s_helm_charts/zdm/templates/configmap.yaml index 10cda9a0..f345eb56 100644 --- a/k8s_helm_charts/zdm/templates/configmap.yaml +++ b/k8s_helm_charts/zdm/templates/configmap.yaml @@ -4,7 +4,6 @@ metadata: name: {{ include "zdm.fullname" . }} namespace: {{ .Values.namespace }} data: - ZDM_ORIGIN_PORT: "9042" ZDM_TARGET_PORT: "9042" ZDM_PRIMARY_CLUSTER: ORIGIN ZDM_READ_MODE: PRIMARY_ONLY diff --git a/k8s_helm_charts/zdm/templates/deployment.yaml b/k8s_helm_charts/zdm/templates/deployment.yaml index 1b2a7c0e..a00f4e77 100644 --- a/k8s_helm_charts/zdm/templates/deployment.yaml +++ b/k8s_helm_charts/zdm/templates/deployment.yaml @@ -68,6 +68,11 @@ spec: secretKeyRef: name: zdmproxy key: origin_contact_points + - name: ZDM_ORIGIN_PORT + valueFrom: + secretKeyRef: + name: zdmproxy + key: origin_port - name: ZDM_ORIGIN_USERNAME valueFrom: secretKeyRef: diff --git a/k8s_helm_charts/zdm/values.yaml b/k8s_helm_charts/zdm/values.yaml index 43f73728..f44cd20b 100644 --- a/k8s_helm_charts/zdm/values.yaml +++ b/k8s_helm_charts/zdm/values.yaml @@ -4,11 +4,6 @@ namespace: zdmproxy -origin_username: -origin_password: -target_username: -target_password: - proxy: count: 3 resources: From eb5c49b4c72f22e53b6f84806aff7ae2a39a547d Mon Sep 17 00:00:00 2001 From: weideng1 Date: Thu, 15 Dec 2022 00:23:20 -0700 Subject: [PATCH 12/22] mpromoted a bunch of values that should be user configurable to values.yaml, including logLevel, readMode, primaryCluster, etal --- k8s_helm_charts/zdm/templates/configmap.yaml | 11 +++++------ k8s_helm_charts/zdm/values.yaml | 7 +++++++ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/k8s_helm_charts/zdm/templates/configmap.yaml b/k8s_helm_charts/zdm/templates/configmap.yaml index f345eb56..f8806f19 100644 --- a/k8s_helm_charts/zdm/templates/configmap.yaml +++ b/k8s_helm_charts/zdm/templates/configmap.yaml @@ -4,9 +4,8 @@ metadata: name: {{ include "zdm.fullname" . }} namespace: {{ .Values.namespace }} data: - ZDM_TARGET_PORT: "9042" - ZDM_PRIMARY_CLUSTER: ORIGIN - ZDM_READ_MODE: PRIMARY_ONLY - ZDM_LOG_LEVEL: INFO - ZDM_PROXY_MAX_CLIENT_CONNECTIONS: "1000" - ZDM_METRICS_ENABLED: "true" + ZDM_PRIMARY_CLUSTER: {{ .Values.proxy.primaryCluster }} + ZDM_READ_MODE: {{ .Values.proxy.readMode }} + ZDM_LOG_LEVEL: {{ .Values.proxy.logLevel }} + ZDM_PROXY_MAX_CLIENT_CONNECTIONS: {{ .Values.proxy.maxClientConnections }} + ZDM_METRICS_ENABLED: {{ .Values.proxy.metricsEnabled }} diff --git a/k8s_helm_charts/zdm/values.yaml b/k8s_helm_charts/zdm/values.yaml index f44cd20b..70857068 100644 --- a/k8s_helm_charts/zdm/values.yaml +++ b/k8s_helm_charts/zdm/values.yaml @@ -6,6 +6,13 @@ namespace: zdmproxy proxy: count: 3 + logLevel: "INFO" + # two options: PRIMARY_ONLY and ASYNC_READS_ON_SECONDARY + readMode: "PRIMARY_ONLY" + # two options: ORIGIN and TARGET + primaryCluster: "ORIGIN" + maxClientConnections: "1000" + metricsEnabled: "true" resources: limits: cpu: 4000m From 6eaf66f95812e9ce18621c4eb54f5c1518db24ea Mon Sep 17 00:00:00 2001 From: weideng1 Date: Thu, 15 Dec 2022 00:39:35 -0700 Subject: [PATCH 13/22] fixed a quote bug in configmap --- k8s_helm_charts/zdm/templates/configmap.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/k8s_helm_charts/zdm/templates/configmap.yaml b/k8s_helm_charts/zdm/templates/configmap.yaml index f8806f19..086c6c35 100644 --- a/k8s_helm_charts/zdm/templates/configmap.yaml +++ b/k8s_helm_charts/zdm/templates/configmap.yaml @@ -4,8 +4,8 @@ metadata: name: {{ include "zdm.fullname" . }} namespace: {{ .Values.namespace }} data: - ZDM_PRIMARY_CLUSTER: {{ .Values.proxy.primaryCluster }} - ZDM_READ_MODE: {{ .Values.proxy.readMode }} - ZDM_LOG_LEVEL: {{ .Values.proxy.logLevel }} - ZDM_PROXY_MAX_CLIENT_CONNECTIONS: {{ .Values.proxy.maxClientConnections }} - ZDM_METRICS_ENABLED: {{ .Values.proxy.metricsEnabled }} + ZDM_PRIMARY_CLUSTER: {{ .Values.proxy.primaryCluster | quote }} + ZDM_READ_MODE: {{ .Values.proxy.readMode | quote }} + ZDM_LOG_LEVEL: {{ .Values.proxy.logLevel | quote }} + ZDM_PROXY_MAX_CLIENT_CONNECTIONS: {{ .Values.proxy.maxClientConnections | quote }} + ZDM_METRICS_ENABLED: {{ .Values.proxy.metricsEnabled | quote }} From 286f7c99d9a33f471aff3fd5fd0a6b439647d939 Mon Sep 17 00:00:00 2001 From: weideng1 Date: Thu, 15 Dec 2022 11:16:13 -0700 Subject: [PATCH 14/22] fixed three issues Phil found in his tests --- k8s_helm_charts/README.md | 6 +++--- k8s_helm_charts/zdm/templates/cdm.yaml | 5 +++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/k8s_helm_charts/README.md b/k8s_helm_charts/README.md index 6aaf26c2..b603cb69 100644 --- a/k8s_helm_charts/README.md +++ b/k8s_helm_charts/README.md @@ -3,13 +3,13 @@ Usage: ```kubectl create ns zdmproxy``` -2. Import Secure Connect Bundle into a k8s secret called zdmproxy-scb. +2. Import Secure Connect Bundle (make sure the filename is exactly secure-connect-target.zip) into a k8s secret called zdmproxy-scb. ```kubectl -n zdmproxy create secret generic zdmproxy-scb --from-file=/tmp/secure-connect-target.zip``` Import Origin contact points, Origin port, Origin username and password, Target/Astra client ID and client Secret into another k8s secret called zdmproxy. - ```kubectl -n zdmproxy create secret generic zdmproxy --from-literal=origin_contact_points="$origin_contact_points" --from-literal=origin_port="$origin_port" --from-literal=origin_username="$origin_username" --from-literal=origin_password="$origin_password" --from-literal=target_username="$prod_astra_user" --from-literal=target_password="$prod_astra_password"``` + ```kubectl -n zdmproxy create secret generic zdmproxy --from-literal=origin_contact_points="$origin_contact_points" --from-literal=origin_port="$origin_port" --from-literal=origin_username="$origin_username" --from-literal=origin_password="$origin_password" --from-literal=target_username="$target_username" --from-literal=target_password="$target_password"``` 3. Run helm install to deploy the helm charts. @@ -34,4 +34,4 @@ Usage: 5. When you're done, run helm uninstall to remove all objects. - ```helm uninstall zdm-proxy``` + ```helm -n zdmproxy uninstall zdm-proxy``` diff --git a/k8s_helm_charts/zdm/templates/cdm.yaml b/k8s_helm_charts/zdm/templates/cdm.yaml index 6463c16b..81f972e7 100644 --- a/k8s_helm_charts/zdm/templates/cdm.yaml +++ b/k8s_helm_charts/zdm/templates/cdm.yaml @@ -36,6 +36,11 @@ spec: secretKeyRef: name: zdmproxy key: origin_contact_points + - name: ZDM_ORIGIN_PORT + valueFrom: + secretKeyRef: + name: zdmproxy + key: origin_port - name: ZDM_ORIGIN_USERNAME valueFrom: secretKeyRef: From a42d5e93efbcd5c474ee0bdb1e144dd7046c1812 Mon Sep 17 00:00:00 2001 From: weideng1 Date: Thu, 15 Dec 2022 11:22:40 -0700 Subject: [PATCH 15/22] address Joao's comments to reduce zdm-proxy memory down to 2GB --- k8s_helm_charts/zdm/values.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/k8s_helm_charts/zdm/values.yaml b/k8s_helm_charts/zdm/values.yaml index 70857068..ded8d0ef 100644 --- a/k8s_helm_charts/zdm/values.yaml +++ b/k8s_helm_charts/zdm/values.yaml @@ -16,10 +16,10 @@ proxy: resources: limits: cpu: 4000m - memory: 8192Mi + memory: 2048Mi requests: cpu: 4000m - memory: 8192Mi + memory: 2048Mi image: repository: datastax/zdm-proxy pullPolicy: IfNotPresent From 5d52bd0e9a68a8017b6725b8ca1e263e0d46c5f1 Mon Sep 17 00:00:00 2001 From: weideng1 Date: Thu, 22 Dec 2022 17:01:37 -0700 Subject: [PATCH 16/22] change cdm to pod instead of deployment, as it doesn't need to be auto-started, add livenessProbe and readinessProbe to proxy pods --- k8s_helm_charts/zdm/templates/cdm.yaml | 127 ++++++++---------- k8s_helm_charts/zdm/templates/deployment.yaml | 19 +++ 2 files changed, 78 insertions(+), 68 deletions(-) diff --git a/k8s_helm_charts/zdm/templates/cdm.yaml b/k8s_helm_charts/zdm/templates/cdm.yaml index 81f972e7..b9bf5cc9 100644 --- a/k8s_helm_charts/zdm/templates/cdm.yaml +++ b/k8s_helm_charts/zdm/templates/cdm.yaml @@ -1,74 +1,65 @@ -apiVersion: apps/v1 -kind: Deployment +apiVersion: v1 +kind: Pod metadata: labels: app: cdm name: cdm namespace: {{ .Values.namespace }} spec: - replicas: 1 - selector: - matchLabels: - app: cdm - template: - metadata: - labels: - app: cdm - spec: - containers: - - name: cdm - image: {{ .Values.cdm.image.repository }}:{{ .Values.cdm.image.tag }} - resources: - requests: - memory: {{ .Values.cdm.resources.requests.memory }} - cpu: {{ .Values.cdm.resources.requests.cpu }} - limits: - memory: {{ .Values.cdm.resources.limits.memory }} - cpu: {{ .Values.cdm.resources.limits.cpu }} - envFrom: - - configMapRef: - name: {{ include "zdm.fullname" . }} - env: - - name: ZDM_TARGET_SECURE_CONNECT_BUNDLE_PATH - value: /tmp/scb/target.zip - - name: ZDM_ORIGIN_CONTACT_POINTS - valueFrom: - secretKeyRef: - name: zdmproxy - key: origin_contact_points - - name: ZDM_ORIGIN_PORT - valueFrom: - secretKeyRef: - name: zdmproxy - key: origin_port - - name: ZDM_ORIGIN_USERNAME - valueFrom: - secretKeyRef: - name: zdmproxy - key: origin_username - - name: ZDM_ORIGIN_PASSWORD - valueFrom: - secretKeyRef: - name: zdmproxy - key: origin_password - - name: ZDM_TARGET_USERNAME - valueFrom: - secretKeyRef: - name: zdmproxy - key: target_username - - name: ZDM_TARGET_PASSWORD - valueFrom: - secretKeyRef: - name: zdmproxy - key: target_password - volumeMounts: - - name: scb - mountPath: "/tmp/scb" - readOnly: true - volumes: - - name: scb - secret: - secretName: zdmproxy-scb - items: - - key: secure-connect-target.zip - path: target.zip + containers: + - name: cdm + image: {{ .Values.cdm.image.repository }}:{{ .Values.cdm.image.tag }} + resources: + requests: + memory: {{ .Values.cdm.resources.requests.memory }} + cpu: {{ .Values.cdm.resources.requests.cpu }} + limits: + memory: {{ .Values.cdm.resources.limits.memory }} + cpu: {{ .Values.cdm.resources.limits.cpu }} + envFrom: + - configMapRef: + name: {{ include "zdm.fullname" . }} + env: + - name: ZDM_TARGET_SECURE_CONNECT_BUNDLE_PATH + value: /tmp/scb/target.zip + - name: ZDM_ORIGIN_CONTACT_POINTS + valueFrom: + secretKeyRef: + name: zdmproxy + key: origin_contact_points + - name: ZDM_ORIGIN_PORT + valueFrom: + secretKeyRef: + name: zdmproxy + key: origin_port + - name: ZDM_ORIGIN_USERNAME + valueFrom: + secretKeyRef: + name: zdmproxy + key: origin_username + - name: ZDM_ORIGIN_PASSWORD + valueFrom: + secretKeyRef: + name: zdmproxy + key: origin_password + - name: ZDM_TARGET_USERNAME + valueFrom: + secretKeyRef: + name: zdmproxy + key: target_username + - name: ZDM_TARGET_PASSWORD + valueFrom: + secretKeyRef: + name: zdmproxy + key: target_password + volumeMounts: + - name: scb + mountPath: "/tmp/scb" + readOnly: true + volumes: + - name: scb + secret: + secretName: zdmproxy-scb + items: + - key: secure-connect-target.zip + path: target.zip diff --git a/k8s_helm_charts/zdm/templates/deployment.yaml b/k8s_helm_charts/zdm/templates/deployment.yaml index a00f4e77..77522352 100644 --- a/k8s_helm_charts/zdm/templates/deployment.yaml +++ b/k8s_helm_charts/zdm/templates/deployment.yaml @@ -34,6 +34,25 @@ spec: containers: - image: "{{ $.Values.proxy.image.repository }}:{{ $.Values.proxy.image.tag | default $.Chart.AppVersion }}" name: {{ $zdm_fullname }}-{{ $index }} + livenessProbe: + httpGet: + path: /health/liveness + port: httpproxy + initialDelaySeconds: 15 + periodSeconds: 15 + readinessProbe: + httpGet: + path: /health/readiness + port: httpproxy + initialDelaySeconds: 15 + periodSeconds: 15 + ports: + - name: httpproxy + containerPort: 14001 + protocol: TCP + - name: cql + containerPort: 9042 + protocol: TCP resources: requests: memory: {{ $.Values.proxy.resources.requests.memory | quote }} From f86e2c8318a1d56cf86a6ac87875796fe0a4368e Mon Sep 17 00:00:00 2001 From: weideng1 Date: Fri, 23 Dec 2022 14:48:57 -0700 Subject: [PATCH 17/22] fixed a bug caused by merging two commits --- k8s_helm_charts/zdm/templates/deployment.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/k8s_helm_charts/zdm/templates/deployment.yaml b/k8s_helm_charts/zdm/templates/deployment.yaml index 77522352..ad843c6e 100644 --- a/k8s_helm_charts/zdm/templates/deployment.yaml +++ b/k8s_helm_charts/zdm/templates/deployment.yaml @@ -112,8 +112,6 @@ spec: secretKeyRef: name: zdmproxy key: target_password - ports: - - containerPort: 9042 volumeMounts: - name: scb mountPath: "/tmp/scb" From 6f57a02a38db9437ef382e9c64812dd5c26afe8c Mon Sep 17 00:00:00 2001 From: weideng1 Date: Tue, 27 Dec 2022 23:24:40 -0700 Subject: [PATCH 18/22] switched k8s deployment to statefulsets for proxy pods #88 --- k8s_helm_charts/README.md | 16 +++++-- k8s_helm_charts/zdm/templates/cdm.yaml | 3 -- k8s_helm_charts/zdm/templates/configmap.yaml | 11 ----- k8s_helm_charts/zdm/templates/service.yaml | 2 +- .../templates/{deployment.yaml => sts.yaml} | 45 +++++++++++-------- 5 files changed, 40 insertions(+), 37 deletions(-) delete mode 100644 k8s_helm_charts/zdm/templates/configmap.yaml rename k8s_helm_charts/zdm/templates/{deployment.yaml => sts.yaml} (77%) diff --git a/k8s_helm_charts/README.md b/k8s_helm_charts/README.md index b603cb69..dbaa76b8 100644 --- a/k8s_helm_charts/README.md +++ b/k8s_helm_charts/README.md @@ -23,15 +23,25 @@ Usage: 4. Verify that all components are up and running. - ```kubectl -n zdmproxy get svc,cm,secret,deploy,po -o wide --show-labels``` + ```kubectl -n zdmproxy get svc,ep,po,cm,secret -o wide --show-labels``` - You can also run ```kubectl -n zdmproxy logs pod/zdm-proxy-0-xxxxxxx``` to see if there are the following entries in the log, which means everything is working as expected: + You can also run ```kubectl -n zdmproxy logs pod/zdm-proxy-0``` to see if there are the following entries in the log, which means everything is working as expected: ``` time="2022-12-14T21:19:57Z" level=info msg="Proxy connected and ready to accept queries on 172.25.132.116:9042" time="2022-12-14T21:19:57Z" level=info msg="Proxy started. Waiting for SIGINT/SIGTERM to shutdown." ``` -5. When you're done, run helm uninstall to remove all objects. +5. Switch primary cluster to target (all proxy pods will automatically roll-restart after the change). + + ```helm -n zdmproxy upgrade zdm-proxy ./zdm --set proxy.primaryCluster=TARGET``` + +6. Scale out/in to different number of proxy pods. + + ```helm -n zdmproxy upgrade zdm-proxy ./zdm --set proxy.count=5``` + + Note: if you've already switched primary cluster to target, make sure you add ```--set proxy.primaryCluster=TARGET``` in this command line as well. An alternative is to directly edit zdm/values.yaml then run helm upgrade. + +7. When you're done, run helm uninstall to remove all objects. ```helm -n zdmproxy uninstall zdm-proxy``` diff --git a/k8s_helm_charts/zdm/templates/cdm.yaml b/k8s_helm_charts/zdm/templates/cdm.yaml index b9bf5cc9..85872f25 100644 --- a/k8s_helm_charts/zdm/templates/cdm.yaml +++ b/k8s_helm_charts/zdm/templates/cdm.yaml @@ -16,9 +16,6 @@ spec: limits: memory: {{ .Values.cdm.resources.limits.memory }} cpu: {{ .Values.cdm.resources.limits.cpu }} - envFrom: - - configMapRef: - name: {{ include "zdm.fullname" . }} env: - name: ZDM_TARGET_SECURE_CONNECT_BUNDLE_PATH value: /tmp/scb/target.zip diff --git a/k8s_helm_charts/zdm/templates/configmap.yaml b/k8s_helm_charts/zdm/templates/configmap.yaml deleted file mode 100644 index 086c6c35..00000000 --- a/k8s_helm_charts/zdm/templates/configmap.yaml +++ /dev/null @@ -1,11 +0,0 @@ -apiVersion: v1 -kind: ConfigMap -metadata: - name: {{ include "zdm.fullname" . }} - namespace: {{ .Values.namespace }} -data: - ZDM_PRIMARY_CLUSTER: {{ .Values.proxy.primaryCluster | quote }} - ZDM_READ_MODE: {{ .Values.proxy.readMode | quote }} - ZDM_LOG_LEVEL: {{ .Values.proxy.logLevel | quote }} - ZDM_PROXY_MAX_CLIENT_CONNECTIONS: {{ .Values.proxy.maxClientConnections | quote }} - ZDM_METRICS_ENABLED: {{ .Values.proxy.metricsEnabled | quote }} diff --git a/k8s_helm_charts/zdm/templates/service.yaml b/k8s_helm_charts/zdm/templates/service.yaml index f13de8b1..c0e55c39 100644 --- a/k8s_helm_charts/zdm/templates/service.yaml +++ b/k8s_helm_charts/zdm/templates/service.yaml @@ -21,6 +21,6 @@ spec: name: cql selector: {{- $zdm_selectorLabels | nindent 4 }} - app: {{ $zdm_fullname }}-{{ $index }} + statefulset.kubernetes.io/pod-name: {{ $zdm_fullname }}-{{ $index }} --- {{- end -}} diff --git a/k8s_helm_charts/zdm/templates/deployment.yaml b/k8s_helm_charts/zdm/templates/sts.yaml similarity index 77% rename from k8s_helm_charts/zdm/templates/deployment.yaml rename to k8s_helm_charts/zdm/templates/sts.yaml index ad843c6e..7510cb6c 100644 --- a/k8s_helm_charts/zdm/templates/deployment.yaml +++ b/k8s_helm_charts/zdm/templates/sts.yaml @@ -10,42 +10,46 @@ {{- end -}} {{- $service_addresses = $service_addresses | trimPrefix "," -}} -{{- range $index := until (.Values.proxy.count | int) -}} apiVersion: apps/v1 -kind: Deployment +kind: StatefulSet metadata: labels: {{- $zdm_labels | nindent 4 }} - app: {{ $zdm_fullname }}-{{ $index }} - name: {{ $zdm_fullname }}-{{ $index }} + app: {{ $zdm_fullname }} + name: {{ $zdm_fullname }} namespace: {{ $.Values.namespace }} spec: - replicas: 1 + serviceName: {{ $zdm_fullname }} + replicas: {{ $.Values.proxy.count | int }} selector: matchLabels: {{- $zdm_selectorLabels | nindent 6 }} - app: {{ $zdm_fullname }}-{{ $index }} + app: {{ $zdm_fullname }} template: metadata: labels: {{- $zdm_selectorLabels | nindent 8 }} - app: {{ $zdm_fullname }}-{{ $index }} + app: {{ $zdm_fullname }} spec: containers: - image: "{{ $.Values.proxy.image.repository }}:{{ $.Values.proxy.image.tag | default $.Chart.AppVersion }}" - name: {{ $zdm_fullname }}-{{ $index }} + name: {{ $zdm_fullname }} + command: + - sh + - "-c" + - "ZDM_PROXY_TOPOLOGY_INDEX=`echo ${HOSTNAME##*-}` /main" livenessProbe: httpGet: path: /health/liveness port: httpproxy - initialDelaySeconds: 15 - periodSeconds: 15 + initialDelaySeconds: 10 + periodSeconds: 10 readinessProbe: httpGet: path: /health/readiness port: httpproxy - initialDelaySeconds: 15 - periodSeconds: 15 + initialDelaySeconds: 10 + periodSeconds: 10 ports: - name: httpproxy containerPort: 14001 @@ -60,10 +64,17 @@ spec: limits: memory: {{ $.Values.proxy.resources.limits.memory | quote }} cpu: {{ $.Values.proxy.resources.limits.cpu | quote }} - envFrom: - - configMapRef: - name: {{ $zdm_fullname }} env: + - name: ZDM_PRIMARY_CLUSTER + value: {{ $.Values.proxy.primaryCluster | upper | quote }} + - name: ZDM_READ_MODE + value: {{ $.Values.proxy.readMode | upper | quote }} + - name: ZDM_LOG_LEVEL + value: {{ $.Values.proxy.logLevel | upper | quote }} + - name: ZDM_PROXY_MAX_CLIENT_CONNECTIONS + value: {{ $.Values.proxy.maxClientConnections | quote }} + - name: ZDM_METRICS_ENABLED + value: {{ $.Values.proxy.metricsEnabled | quote }} - name: ZDM_PROXY_LISTEN_ADDRESS valueFrom: fieldRef: @@ -76,8 +87,6 @@ spec: fieldPath: status.podIP - name: ZDM_METRICS_PORT value: "14001" - - name: ZDM_PROXY_TOPOLOGY_INDEX - value: {{ $index | quote }} - name: ZDM_PROXY_TOPOLOGY_ADDRESSES value: {{ $service_addresses }} - name: ZDM_TARGET_SECURE_CONNECT_BUNDLE_PATH @@ -123,5 +132,3 @@ spec: items: - key: secure-connect-target.zip path: target.zip ---- -{{- end -}} From 692a11b23cccb5cf1f9bd6c9eb245d88d48794ae Mon Sep 17 00:00:00 2001 From: weideng1 Date: Wed, 18 Jan 2023 14:15:24 -0700 Subject: [PATCH 19/22] remove CDM from helm chart --- k8s_helm_charts/zdm/templates/cdm.yaml | 62 -------------------------- k8s_helm_charts/zdm/values.yaml | 12 ----- 2 files changed, 74 deletions(-) delete mode 100644 k8s_helm_charts/zdm/templates/cdm.yaml diff --git a/k8s_helm_charts/zdm/templates/cdm.yaml b/k8s_helm_charts/zdm/templates/cdm.yaml deleted file mode 100644 index 4c6b3841..00000000 --- a/k8s_helm_charts/zdm/templates/cdm.yaml +++ /dev/null @@ -1,62 +0,0 @@ -apiVersion: v1 -kind: Pod -metadata: - labels: - app: cdm - name: cdm - namespace: {{ .Values.namespace }} -spec: - containers: - - name: cdm - image: {{ .Values.cdm.image.repository }}:{{ .Values.cdm.image.tag }} - resources: - requests: - memory: {{ .Values.cdm.resources.requests.memory }} - cpu: {{ .Values.cdm.resources.requests.cpu }} - limits: - memory: {{ .Values.cdm.resources.limits.memory }} - cpu: {{ .Values.cdm.resources.limits.cpu }} - env: - - name: ZDM_TARGET_SECURE_CONNECT_BUNDLE_PATH - value: /tmp/scb/target.zip - - name: ZDM_ORIGIN_CONTACT_POINTS - valueFrom: - secretKeyRef: - name: zdmproxy - key: origin_contact_points - - name: ZDM_ORIGIN_PORT - valueFrom: - secretKeyRef: - name: zdmproxy - key: origin_port - - name: ZDM_ORIGIN_USERNAME - valueFrom: - secretKeyRef: - name: zdmproxy - key: origin_username - - name: ZDM_ORIGIN_PASSWORD - valueFrom: - secretKeyRef: - name: zdmproxy - key: origin_password - - name: ZDM_TARGET_USERNAME - valueFrom: - secretKeyRef: - name: zdmproxy - key: target_username - - name: ZDM_TARGET_PASSWORD - valueFrom: - secretKeyRef: - name: zdmproxy - key: target_password - volumeMounts: - - name: scb - mountPath: "/tmp/scb" - readOnly: true - volumes: - - name: scb - secret: - secretName: zdmproxy-scb - items: - - key: secure-connect-target.zip - path: target.zip \ No newline at end of file diff --git a/k8s_helm_charts/zdm/values.yaml b/k8s_helm_charts/zdm/values.yaml index ded8d0ef..dad0fc79 100644 --- a/k8s_helm_charts/zdm/values.yaml +++ b/k8s_helm_charts/zdm/values.yaml @@ -26,18 +26,6 @@ proxy: # Overrides the image tag whose default is the chart appVersion. tag: "" -cdm: - resources: - limits: - cpu: 16000m - memory: 32768Mi - requests: - cpu: 16000m - memory: 32768Mi - image: - repository: datastax/cassandra-data-migrator - tag: 2.10.3 - nameOverride: "" fullnameOverride: "" From 4ef57546d24627bb85de5cbe34967cf7e0d4a5f7 Mon Sep 17 00:00:00 2001 From: weideng1 Date: Tue, 24 Jan 2023 14:52:37 -0700 Subject: [PATCH 20/22] remove deployment.yaml --- k8s_helm_charts/zdm/templates/deployment.yaml | 110 ------------------ 1 file changed, 110 deletions(-) delete mode 100644 k8s_helm_charts/zdm/templates/deployment.yaml diff --git a/k8s_helm_charts/zdm/templates/deployment.yaml b/k8s_helm_charts/zdm/templates/deployment.yaml deleted file mode 100644 index a00f4e77..00000000 --- a/k8s_helm_charts/zdm/templates/deployment.yaml +++ /dev/null @@ -1,110 +0,0 @@ -# pull in these templates outside of range loop -{{ $zdm_fullname := include "zdm.fullname" . -}} -{{- $zdm_labels := include "zdm.labels" . -}} -{{- $zdm_selectorLabels := include "zdm.selectorLabels" . -}} - -# calculate a variable that contains all proxy service addresses -{{ $service_addresses := "" -}} -{{- range $index := until (.Values.proxy.count | int) -}} - {{- $service_addresses = printf "%s,$(%s_%s_SERVICE_HOST)" $service_addresses ($zdm_fullname | upper | replace "-" "_") ($index | toString) -}} -{{- end -}} -{{- $service_addresses = $service_addresses | trimPrefix "," -}} - -{{- range $index := until (.Values.proxy.count | int) -}} -apiVersion: apps/v1 -kind: Deployment -metadata: - labels: - {{- $zdm_labels | nindent 4 }} - app: {{ $zdm_fullname }}-{{ $index }} - name: {{ $zdm_fullname }}-{{ $index }} - namespace: {{ $.Values.namespace }} -spec: - replicas: 1 - selector: - matchLabels: - {{- $zdm_selectorLabels | nindent 6 }} - app: {{ $zdm_fullname }}-{{ $index }} - template: - metadata: - labels: - {{- $zdm_selectorLabels | nindent 8 }} - app: {{ $zdm_fullname }}-{{ $index }} - spec: - containers: - - image: "{{ $.Values.proxy.image.repository }}:{{ $.Values.proxy.image.tag | default $.Chart.AppVersion }}" - name: {{ $zdm_fullname }}-{{ $index }} - resources: - requests: - memory: {{ $.Values.proxy.resources.requests.memory | quote }} - cpu: {{ $.Values.proxy.resources.requests.cpu | quote }} - limits: - memory: {{ $.Values.proxy.resources.limits.memory | quote }} - cpu: {{ $.Values.proxy.resources.limits.cpu | quote }} - envFrom: - - configMapRef: - name: {{ $zdm_fullname }} - env: - - name: ZDM_PROXY_LISTEN_ADDRESS - valueFrom: - fieldRef: - fieldPath: status.podIP - - name: ZDM_PROXY_LISTEN_PORT - value: "9042" - - name: ZDM_METRICS_ADDRESS - valueFrom: - fieldRef: - fieldPath: status.podIP - - name: ZDM_METRICS_PORT - value: "14001" - - name: ZDM_PROXY_TOPOLOGY_INDEX - value: {{ $index | quote }} - - name: ZDM_PROXY_TOPOLOGY_ADDRESSES - value: {{ $service_addresses }} - - name: ZDM_TARGET_SECURE_CONNECT_BUNDLE_PATH - value: /tmp/scb/target.zip - - name: ZDM_ORIGIN_CONTACT_POINTS - valueFrom: - secretKeyRef: - name: zdmproxy - key: origin_contact_points - - name: ZDM_ORIGIN_PORT - valueFrom: - secretKeyRef: - name: zdmproxy - key: origin_port - - name: ZDM_ORIGIN_USERNAME - valueFrom: - secretKeyRef: - name: zdmproxy - key: origin_username - - name: ZDM_ORIGIN_PASSWORD - valueFrom: - secretKeyRef: - name: zdmproxy - key: origin_password - - name: ZDM_TARGET_USERNAME - valueFrom: - secretKeyRef: - name: zdmproxy - key: target_username - - name: ZDM_TARGET_PASSWORD - valueFrom: - secretKeyRef: - name: zdmproxy - key: target_password - ports: - - containerPort: 9042 - volumeMounts: - - name: scb - mountPath: "/tmp/scb" - readOnly: true - volumes: - - name: scb - secret: - secretName: zdmproxy-scb - items: - - key: secure-connect-target.zip - path: target.zip ---- -{{- end -}} From 98636c4bccc60f77bda3c491628f9b208960dc6a Mon Sep 17 00:00:00 2001 From: weideng1 Date: Wed, 25 Jan 2023 14:35:36 -0700 Subject: [PATCH 21/22] revised helm chart according to John's comments on values.yaml best practices --- k8s_helm_charts/README.md | 2 +- k8s_helm_charts/zdm/Chart.yaml | 4 +- k8s_helm_charts/zdm/templates/configmap.yaml | 11 ---- k8s_helm_charts/zdm/templates/service.yaml | 6 +- k8s_helm_charts/zdm/templates/sts.yaml | 23 +++---- k8s_helm_charts/zdm/values.yaml | 64 ++++++++++++-------- 6 files changed, 54 insertions(+), 56 deletions(-) delete mode 100644 k8s_helm_charts/zdm/templates/configmap.yaml diff --git a/k8s_helm_charts/README.md b/k8s_helm_charts/README.md index 67edea59..bd2d8b09 100644 --- a/k8s_helm_charts/README.md +++ b/k8s_helm_charts/README.md @@ -23,7 +23,7 @@ Usage: 4. Verify that all components are up and running. - ```kubectl -n zdmproxy get svc,ep,po,cm,secret -o wide --show-labels``` + ```kubectl -n zdmproxy get svc,ep,po,secret -o wide --show-labels``` You can also run ```kubectl -n zdmproxy logs pod/zdm-proxy-0``` to see if there are the following entries in the log, which means everything is working as expected: diff --git a/k8s_helm_charts/zdm/Chart.yaml b/k8s_helm_charts/zdm/Chart.yaml index c7a49506..d33f7188 100644 --- a/k8s_helm_charts/zdm/Chart.yaml +++ b/k8s_helm_charts/zdm/Chart.yaml @@ -15,10 +15,10 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.1.0 +version: 1.0.0 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to # follow Semantic Versioning. They should reflect the version the application is using. # It is recommended to use it with quotes. -appVersion: "2.0.x" +appVersion: "2.1.x" diff --git a/k8s_helm_charts/zdm/templates/configmap.yaml b/k8s_helm_charts/zdm/templates/configmap.yaml deleted file mode 100644 index 086c6c35..00000000 --- a/k8s_helm_charts/zdm/templates/configmap.yaml +++ /dev/null @@ -1,11 +0,0 @@ -apiVersion: v1 -kind: ConfigMap -metadata: - name: {{ include "zdm.fullname" . }} - namespace: {{ .Values.namespace }} -data: - ZDM_PRIMARY_CLUSTER: {{ .Values.proxy.primaryCluster | quote }} - ZDM_READ_MODE: {{ .Values.proxy.readMode | quote }} - ZDM_LOG_LEVEL: {{ .Values.proxy.logLevel | quote }} - ZDM_PROXY_MAX_CLIENT_CONNECTIONS: {{ .Values.proxy.maxClientConnections | quote }} - ZDM_METRICS_ENABLED: {{ .Values.proxy.metricsEnabled | quote }} diff --git a/k8s_helm_charts/zdm/templates/service.yaml b/k8s_helm_charts/zdm/templates/service.yaml index c0e55c39..1ef002e4 100644 --- a/k8s_helm_charts/zdm/templates/service.yaml +++ b/k8s_helm_charts/zdm/templates/service.yaml @@ -2,7 +2,7 @@ {{ $zdm_fullname := include "zdm.fullname" . -}} {{- $zdm_labels := include "zdm.labels" . -}} {{- $zdm_selectorLabels := include "zdm.selectorLabels" . -}} -{{- range $index := until (.Values.proxy.count | int) -}} +{{- range $index := until (.Values.count | int) -}} apiVersion: v1 kind: Service metadata: @@ -13,9 +13,9 @@ metadata: app: {{ $zdm_fullname }}-{{ $index }} role: zdmproxy spec: - type: {{ $.Values.service.type }} + type: {{ $.Values.serviceType }} ports: - - port: {{ $.Values.service.port | int }} + - port: {{ $.Values.servicePort | int }} targetPort: 9042 protocol: TCP name: cql diff --git a/k8s_helm_charts/zdm/templates/sts.yaml b/k8s_helm_charts/zdm/templates/sts.yaml index 7510cb6c..50682698 100644 --- a/k8s_helm_charts/zdm/templates/sts.yaml +++ b/k8s_helm_charts/zdm/templates/sts.yaml @@ -5,7 +5,7 @@ # calculate a variable that contains all proxy service addresses {{ $service_addresses := "" -}} -{{- range $index := until (.Values.proxy.count | int) -}} +{{- range $index := until (.Values.count | int) -}} {{- $service_addresses = printf "%s,$(%s_%s_SERVICE_HOST)" $service_addresses ($zdm_fullname | upper | replace "-" "_") ($index | toString) -}} {{- end -}} {{- $service_addresses = $service_addresses | trimPrefix "," -}} @@ -20,7 +20,7 @@ metadata: namespace: {{ $.Values.namespace }} spec: serviceName: {{ $zdm_fullname }} - replicas: {{ $.Values.proxy.count | int }} + replicas: {{ $.Values.count | int }} selector: matchLabels: {{- $zdm_selectorLabels | nindent 6 }} @@ -32,7 +32,7 @@ spec: app: {{ $zdm_fullname }} spec: containers: - - image: "{{ $.Values.proxy.image.repository }}:{{ $.Values.proxy.image.tag | default $.Chart.AppVersion }}" + - image: "{{ $.Values.imageRepository }}:{{ $.Values.imageTag | default $.Chart.AppVersion }}" name: {{ $zdm_fullname }} command: - sh @@ -58,23 +58,18 @@ spec: containerPort: 9042 protocol: TCP resources: - requests: - memory: {{ $.Values.proxy.resources.requests.memory | quote }} - cpu: {{ $.Values.proxy.resources.requests.cpu | quote }} - limits: - memory: {{ $.Values.proxy.resources.limits.memory | quote }} - cpu: {{ $.Values.proxy.resources.limits.cpu | quote }} + {{- toYaml .Values.resources | nindent 10 }} env: - name: ZDM_PRIMARY_CLUSTER - value: {{ $.Values.proxy.primaryCluster | upper | quote }} + value: {{ $.Values.primaryCluster | upper | quote }} - name: ZDM_READ_MODE - value: {{ $.Values.proxy.readMode | upper | quote }} + value: {{ $.Values.readMode | upper | quote }} - name: ZDM_LOG_LEVEL - value: {{ $.Values.proxy.logLevel | upper | quote }} + value: {{ $.Values.logLevel | upper | quote }} - name: ZDM_PROXY_MAX_CLIENT_CONNECTIONS - value: {{ $.Values.proxy.maxClientConnections | quote }} + value: {{ $.Values.maxClientConnections | quote }} - name: ZDM_METRICS_ENABLED - value: {{ $.Values.proxy.metricsEnabled | quote }} + value: {{ $.Values.metricsEnabled | quote }} - name: ZDM_PROXY_LISTEN_ADDRESS valueFrom: fieldRef: diff --git a/k8s_helm_charts/zdm/values.yaml b/k8s_helm_charts/zdm/values.yaml index dad0fc79..7f21aa2a 100644 --- a/k8s_helm_charts/zdm/values.yaml +++ b/k8s_helm_charts/zdm/values.yaml @@ -2,33 +2,47 @@ # This is a YAML-formatted file. # Declare variables to be passed into your templates. +# namespace to deploy zdm objects in namespace: zdmproxy -proxy: - count: 3 - logLevel: "INFO" - # two options: PRIMARY_ONLY and ASYNC_READS_ON_SECONDARY - readMode: "PRIMARY_ONLY" - # two options: ORIGIN and TARGET - primaryCluster: "ORIGIN" - maxClientConnections: "1000" - metricsEnabled: "true" - resources: - limits: - cpu: 4000m - memory: 2048Mi - requests: - cpu: 4000m - memory: 2048Mi - image: - repository: datastax/zdm-proxy - pullPolicy: IfNotPresent - # Overrides the image tag whose default is the chart appVersion. - tag: "" +# count is the number of zdm proxy pods (and corresponding services) +count: 3 + +# logLevel is logging level for zdm proxy, available options are: PANIC, FATAL, ERROR, WARN or WARNING, INFO, DEBUG and TRACE +logLevel: "INFO" + +# readMode has two options: PRIMARY_ONLY and ASYNC_READS_ON_SECONDARY +readMode: "PRIMARY_ONLY" + +# primaryCluster has two options: ORIGIN and TARGET +primaryCluster: "ORIGIN" + +# maxClientConnections is the limit on maximum number of client connections per proxy +maxClientConnections: "1000" + +# metricsEnabled is whether to enable metrics/http port on proxy +metricsEnabled: "true" + +# resources request and limit for zdm proxy pods +resources: + limits: + cpu: 4000m + memory: 2048Mi + requests: + cpu: 4000m + memory: 2048Mi + +# imageRepository is the dockerhub repository to pull zdm-proxy image from +imageRepository: datastax/zdm-proxy + +# imageTag defines the tag on dockerhub repo for pulling zdm-proxy image, it overrides the image tag whose default is the chart appVersion. +imageTag: "" + +# serviceType is the type of service used for zdm-proxy pod's associated CQL service +serviceType: ClusterIP + +# servicePort is the CQL port exposed to the rest of the k8s cluster from the zdm-proxy service +servicePort: 9942 nameOverride: "" fullnameOverride: "" - -service: - type: ClusterIP - port: 9942 From dd1c4335ed722be3575843bf186c2e24c9943a27 Mon Sep 17 00:00:00 2001 From: weideng1 Date: Wed, 25 Jan 2023 14:40:09 -0700 Subject: [PATCH 22/22] fix values in README.md that are no longer accurate --- k8s_helm_charts/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/k8s_helm_charts/README.md b/k8s_helm_charts/README.md index bd2d8b09..1e227c72 100644 --- a/k8s_helm_charts/README.md +++ b/k8s_helm_charts/README.md @@ -19,7 +19,7 @@ Usage: ```helm -n zdmproxy uninstall zdm-proxy``` - ```helm -n zdmproxy install --set proxy.resources.requests.cpu=1000m --set proxy.resources.requests.memory=2000Mi --set proxy.resources.limits.cpu=1000m --set proxy.resources.limits.memory=2000Mi --set cdm.resources.requests.cpu=1000m --set cdm.resources.requests.memory=2000Mi --set cdm.resources.limits.cpu=1000m --set cdm.resources.limits.memory=2000Mi zdm-proxy ./zdm``` + ```helm -n zdmproxy install --set resources.requests.cpu=1000m --set resources.requests.memory=2000Mi --set resources.limits.cpu=1000m --set resources.limits.memory=2000Mi zdm-proxy ./zdm``` 4. Verify that all components are up and running. @@ -35,13 +35,13 @@ Usage: 5. Switch primary cluster to target (all proxy pods will automatically roll-restart after the change). - ```helm -n zdmproxy upgrade zdm-proxy ./zdm --set proxy.primaryCluster=TARGET``` + ```helm -n zdmproxy upgrade zdm-proxy ./zdm --set primaryCluster=TARGET``` 6. Scale out/in to different number of proxy pods. - ```helm -n zdmproxy upgrade zdm-proxy ./zdm --set proxy.count=5``` + ```helm -n zdmproxy upgrade zdm-proxy ./zdm --set count=5``` - Note: if you've already switched primary cluster to target, make sure you add ```--set proxy.primaryCluster=TARGET``` in this command line as well. An alternative is to directly edit zdm/values.yaml then run helm upgrade. + Note: if you've already switched primary cluster to target, make sure you add ```--set primaryCluster=TARGET``` in this command line as well. An alternative is to directly edit zdm/values.yaml then run helm upgrade. 7. When you're done, run helm uninstall to remove all objects.