Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix orioledb patroni etcd dependency with Service Reference #5237

Merged
merged 9 commits into from
Oct 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion deploy/etcd/templates/clusterdefinition.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,6 @@ spec:
--data-dir /var/run/etcd/default.etcd
connectionCredential:
username: root
password: ""
password: ""
endpoint: "$(SVC_FQDN)"
port: "$(SVC_PORT_client)"
4 changes: 4 additions & 0 deletions deploy/orioledb-cluster/templates/cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
componentSpecs:
- name: orioledb
componentDefRef: orioledb
serviceRefs:
- name: etcdService
cluster: {{ .Values.etcd.cluster | default "etcd" }}
namespace: {{ .Values.etcd.namespace | default "default" }}
{{- include "kblib.componentMonitor" . | indent 6 }}
{{- include "orioledb-cluster.replicaCount" . | indent 6 }}
enabledLogs:
Expand Down
22 changes: 16 additions & 6 deletions deploy/orioledb-cluster/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,10 @@
"type": "object",
"properties": {
"version": {
"title": "Version",
"description": "Cluster version.",
"type": "string",
"default": "orioledb-beta1"
},
"mode": {
"title": "Mode",
"description": "Cluster topology mode.",
"type": "string",
"default": "standalone",
"enum": [
Expand All @@ -19,8 +15,6 @@
]
},
"replicas": {
"title": "Replicas",
"description": "The number of replicas, for standalone mode, the replicas is 1, for replication mode, the default replicas is 2.",
"type": "integer",
"default": 1,
"minimum": 1,
Expand Down Expand Up @@ -59,6 +53,22 @@
"default": 20,
"minimum": 1,
"maximum": 10000
},
"etcd": {
"type": "object",
"title": "The patroni dependency etcd Schema",
"properties": {
"cluster": {
"type": "string",
"default": "etcd",
"description": "The patroni dependency etcd cluster name"
},
"namespace": {
"type": "string",
"default": "default",
"description": "The patroni dependency etcd cluster namespace"
}
}
}
}
}
6 changes: 6 additions & 0 deletions deploy/orioledb-cluster/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,9 @@ requests:
## @param storage size, the unit is Gi
##
storage: 20

## @param patroni etcd cluster name, if not set will use the cluster name "etcd"
## and the cluster must exist,
etcd:
cluster: "etcd"
namespace: "default"
18 changes: 18 additions & 0 deletions deploy/orioledb/config/etcd-serve-config.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{{- $clusterName := $.cluster.metadata.name }}
{{- $namespace := $.cluster.metadata.namespace }}
{{- $orioledb_etcd_from_service_ref := fromJson "{}" }}
{{- if index $.component "serviceReferences" }}
{{- range $i, $e := $.component.serviceReferences }}
{{- if eq $i "etcdService" }}
{{- $orioledb_etcd_from_service_ref = $e }}
{{- break }}
{{- end }}
{{- end }}
{{- end }}
{{- $etcd_server := "" }}
{{- if $orioledb_etcd_from_service_ref }}
{{- if and (index $orioledb_etcd_from_service_ref.spec "endpoint") (index $orioledb_etcd_from_service_ref.spec "port") }}
{{- $etcd_server = printf "%s:%s" $orioledb_etcd_from_service_ref.spec.endpoint.value $orioledb_etcd_from_service_ref.spec.port.value }}
{{- end }}
{{- end }}
export PATRONI_ETCD3_HOST={{ $etcd_server }}
14 changes: 12 additions & 2 deletions deploy/orioledb/templates/clusterdefinition.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,22 @@ spec:
namespace: {{ .Release.Namespace }}
volumeName: agamotto-configuration
defaultMode: 0777
- name: etcd-env
templateRef: etcd-env
namespace: {{ .Release.Namespace }}
volumeName: patroni-dependency
defaultMode: 0777
scriptSpecs:
- name: orioledb-scripts
templateRef: orioledb-scripts
namespace: {{ .Release.Namespace }}
volumeName: scripts
defaultMode: 0777
serviceRefDeclarations:
- name: etcdService
serviceRefDeclarationSpecs:
- serviceKind: etcd
serviceVersion: ^v3.\d...d$
service:
ports:
- name: tcp-postgresql
Expand Down Expand Up @@ -140,6 +150,8 @@ spec:
mountPath: /kb-scripts
- name: pod-info
mountPath: /kb-podinfo
- name: patroni-dependency
mountPath: /dependency
ports:
- name: tcp-postgresql
containerPort: 5432
Expand All @@ -148,8 +160,6 @@ spec:
env: ## refer https://github.com/zalando/spilo/blob/master/ENVIRONMENT.rst
- name: PGROOT
value: /home/postgres/pgdata/pgroot
- name: PATRONI_ETCD3_HOST
value: "etcd-etcd:2379" # todo : not hardcode
- name: SCOPE
value: "$(KB_CLUSTER_NAME)-$(KB_COMP_NAME)-patroni$(KB_CLUSTER_UID_POSTFIX_8)"
- name: KUBERNETES_SCOPE_LABEL
Expand Down
10 changes: 10 additions & 0 deletions deploy/orioledb/templates/etcd-configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: etcd-env
labels:
{{- include "orioledb.labels" . | nindent 4 }}
data:
conf: |-
{{- .Files.Get "config/etcd-serve-config.tpl" | nindent 4 }}

5 changes: 3 additions & 2 deletions deploy/orioledb/templates/scripts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,10 @@ data:
CREATE EXTENSION pg_stat_statements;
setup.sh: |
mkdir -p /home/postgres/pgdata/conf
chmod 777 -R /home/postgres/pgdata/conf
chmod 777 -R /home/postgres/pgdata
cp /home/postgres/conf/postgresql.conf /home/postgres/pgdata/conf
chmod 777 /home/postgres/pgdata/conf/postgresql.conf
chmod 777 -R /home/postgres/pgdata/conf
source /dependency/conf

{{/* chmod 750 -R /home/postgres/pgdata*/}}
{{/* mkdir -p /var/lib/postgresql/conf*/}}
Expand Down
2 changes: 1 addition & 1 deletion internal/cli/cmd/cluster/create_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func buildHelmValues(c *cluster.ChartInfo, values map[string]interface{}) map[st
if c.SubSchema == nil {
return values
}

// todo: for key like `etcd.cluster` should adjust it to a map like
subSchemaKeys := maps.Keys(c.SubSchema.Properties)
newValues := map[string]interface{}{
c.SubChartName: map[string]interface{}{},
Expand Down
Loading