World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.
Java ai-catalogdata-catalogdatalakefederated-querylakehousemetadatametalakemodel-catalogopendatacatalogskycomputingstratosphere
[#7766] Use the sql scripts in the image instead of in the chart (#7767)
Danhua Wang664b4d138ea4
diff --git a/dev/charts/gravitino/Chart.yaml b/dev/charts/gravitino/Chart.yamlindex 8fd9b1854f..fda8201aa8 100644--- a/dev/charts/gravitino/Chart.yaml+++ b/dev/charts/gravitino/Chart.yaml@@ -23,6 +23,11 @@ home: https://gravitino.apache.organnotations:licenses: Apache-2.0dependencies:+ - name: common+ repository: https://charts.bitnami.com/bitnami+ tags:+ - bitnami-common+ version: 2.19.2- condition: mysql.enabledname: mysqlrepository: https://charts.bitnami.com/bitnamidiff --git a/dev/charts/gravitino/resources/files/mysql b/dev/charts/gravitino/resources/files/mysqldeleted file mode 120000index 1fadad5214..0000000000--- a/dev/charts/gravitino/resources/files/mysql+++ /dev/null@@ -1 +0,0 @@-../../../../../scripts/mysql\ No newline at end of filediff --git a/dev/charts/gravitino/templates/_helpers.tpl b/dev/charts/gravitino/templates/_helpers.tplindex edf00f207e..8258ac350d 100644--- a/dev/charts/gravitino/templates/_helpers.tpl+++ b/dev/charts/gravitino/templates/_helpers.tpl@@ -65,3 +65,19 @@ Define the gravitino.namespace{{- define "gravitino.namespace" -}}{{- .Release.Namespace -}}{{- end -}}++{{/*+Return the proper Gravitino image name+*/}}+{{- define "gravitino.image" -}}+ {{- include "common.images.image" (dict "imageRoot" .Values.image "global" .Values.global) -}}+{{- end -}}++{{/*+Return the proper MySQL image name for the init-mysql initContainer+*/}}+{{- define "init-mysql.image" -}}+{{- if .Values.mysql.enabled -}}+ {{- include "common.images.image" (dict "imageRoot" .Values.mysql.image "global" .Values.global) -}}+{{- end -}}+{{- end -}}\ No newline at end of filediff --git a/dev/charts/gravitino/templates/configmap-mysql-init.yaml b/dev/charts/gravitino/templates/configmap-mysql-init.yamldeleted file mode 100644index 089c47ca00..0000000000--- a/dev/charts/gravitino/templates/configmap-mysql-init.yaml+++ /dev/null@@ -1,46 +0,0 @@-{{- /*- Licensed to the Apache Software Foundation (ASF) under one- or more contributor license agreements. See the NOTICE file- distributed with this work for additional information- regarding copyright ownership. The ASF licenses this file- to you under the Apache License, Version 2.0 (the- "License"); you may not use this file except in compliance- with the License. You may obtain a copy of the License at-- http://www.apache.org/licenses/LICENSE-2.0-- Unless required by applicable law or agreed to in writing,- software distributed under the License is distributed on an- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY- KIND, either express or implied. See the License for the- specific language governing permissions and limitations- under the License.- */}}--{{- if .Values.mysql.enabled }}-apiVersion: v1-kind: ConfigMap-metadata:- name: gravitino-mysql-init- namespace: {{ include "gravitino.namespace" . }}- labels:- {{- include "gravitino.labels" . | nindent 4 }}-data:- {{- $sqlFiles := .Files.Glob "resources/files/mysql/schema-*-mysql.sql" }}- {{- $maxVersionFile := "" }}- {{- $maxVersion := "0.0.0" }}- {{- range $path, $content := $sqlFiles }}- {{- $fileName := base $path }}- {{- $version := regexFind "schema-(\\d+\\.\\d+\\.\\d+)-mysql\\.sql" $fileName | replace "schema-" "" | replace "-mysql.sql" "" }}- {{- if (semverCompare ">= 0.0.0" $version) }}- {{- if (semverCompare (printf "> %s" $maxVersion) $version) }}- {{- $maxVersion = $version }}- {{- $maxVersionFile = $path }}- {{- end }}- {{- end }}- {{- end }}- {{- if $maxVersionFile }}- {{ base $maxVersionFile }}: |-- {{- tpl (.Files.Get $maxVersionFile | toString) $ | nindent 4 }}- {{- end }}-{{- end }}\ No newline at end of filediff --git a/dev/charts/gravitino/templates/deployment.yaml b/dev/charts/gravitino/templates/deployment.yamlindex a509cef23e..59c25f5c88 100644--- a/dev/charts/gravitino/templates/deployment.yaml+++ b/dev/charts/gravitino/templates/deployment.yaml@@ -46,13 +46,76 @@ spec:{{- toYaml . | nindent 8 }}{{- end }}spec:- {{- with .Values.image.pullSecrets }}+ {{- with .Values.global.imagePullSecrets }}imagePullSecrets:{{- toYaml . | nindent 8 }}+ {{- end }}+ initContainers:+ - name: sqlfile+ image: {{ include "gravitino.image" . }}+ imagePullPolicy: "{{ .Values.image.pullPolicy }}"+ command:+ - /bin/bash+ - -c+ - |+ cp -r /root/gravitino/scripts/* /tmp/scripts/+ VERSION=$(ls /root/gravitino/libs/gravitino-server-* | grep -oP '[0-9]+\.[0-9]+\.[0-9]+'|head -1)+ echo $VERSION > /tmp/scripts/version.txt+ resources:+ {{- toYaml .Values.initResources | nindent 10 }}+ volumeMounts:+ - mountPath: /tmp/scripts/+ name: scripts-emptydir+ {{- if .Values.mysql.enabled }}+ - name: init-mysql+ image: {{ include "init-mysql.image" . }}+ imagePullPolicy: "{{ .Values.image.pullPolicy }}"+ command:+ - /bin/bash+ - -c+ - |+ while ! mysql -h {{ .Release.Name }}-mysql -u root -e "SELECT 1"; do+ echo "Waiting for MySQL to be ready..."+ sleep 2+ done+ VERSION=$(cat /scripts/version.txt)+ if [ -z "$VERSION" ]; then+ echo "ERROR:Please set VERSION"+ exit 1+ fi+ dir="/scripts/mysql"+ schema_file=$(ls $dir/schema-*-mysql.sql | sort -V | awk -F'[-]' '$2 <= '$VERSION' {print $0}' | tail -n 1)+ if [ ! -f "$schema_file" ]; then+ echo "ERROR:Failed to find schema file $schema_file"+ exit 1+ fi+ upgrade_file=$(ls $dir/upgrade-*-to-*-mysql.sql | sort -V | awk -F'[-]' '$4 <= '$VERSION' {print $0}' | tail -n 1)+ if [ ! -f "$upgrade_file" ]; then+ echo "ERROR:Failed to find upgrade file $upgrade_file"+ exit 1+ fi+ echo "Schema file: $schema_file"+ echo "Upgrade file: $upgrade_file"+ if ! mysql -h {{ .Release.Name }}-mysql -u root -D gravitino <"$upgrade_file"; then+ echo "WARNING: Upgrade script failed: $upgrade_file" >&2+ echo "Continuing with schema script..." >&2+ fi+ mysql -h {{ .Release.Name }}-mysql -u root -D gravitino <$schema_file+ resources:+ {{- toYaml .Values.initResources | nindent 10 }}+ env:+ - name: MYSQL_PWD+ valueFrom:+ secretKeyRef:+ name: {{ .Release.Name }}-mysql+ key: mysql-root-password+ volumeMounts:+ - mountPath: /scripts+ name: scripts-emptydir{{- end }}containers:- name: {{ include "gravitino.name" . }}- image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"+ image: {{ include "gravitino.image" . }}imagePullPolicy: {{ .Values.image.pullPolicy | quote }}command:- "/bin/bash"@@ -108,6 +171,8 @@ spec:- name: gravitino-confconfigMap:name: {{ include "gravitino.fullname" . }}+ - emptyDir: {}+ name: scripts-emptydir{{- if not .Values.persistence.enabled }}- name: storageemptyDir: {}diff --git a/dev/charts/gravitino/values.yaml b/dev/charts/gravitino/values.yamlindex 45173f359c..04d05ed11e 100644--- a/dev/charts/gravitino/values.yaml+++ b/dev/charts/gravitino/values.yaml@@ -16,18 +16,23 @@# specific language governing permissions and limitations# under the License.#+global:+ # Set if you want to change the default docker registry, e.g. a private one.+ # imageRegistry: myRegistryName-image:- repository: apache/gravitino- tag: 1.0.0-SNAPSHOT- pullPolicy: IfNotPresent## Optionally specify an array of pullSecrets (secrets must be manually created in the namespace)## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/## Example:- ## pullSecrets:- ## - myRegistryKeySecretName+ ## imagePullSecrets:+ ## - name: my-registry-secret##- pullSecrets: []+ imagePullSecrets: []++image:+ registry: docker.io+ repository: apache/gravitino+ tag: 1.0.0-SNAPSHOT+ pullPolicy: IfNotPresent## MySQL chart configuration## ref: https://github.com/bitnami/charts/blob/main/bitnami/mysql/values.yaml@@ -44,9 +49,6 @@ mysql:##image:tag: 8.0.36-debian-12-r12- ## @param initdbScriptsConfigMap ConfigMap with the initdb scripts- ##- initdbScriptsConfigMap: gravitino-mysql-init## MySQL Authentication parameters##auth:@@ -418,6 +420,14 @@ resources: {}# cpu: 2000m# memory: 3Gi+initResources: {}+# limits:+# cpu: "25m"+# memory: "128Mi"+# requests:+# cpu: "25m"+# memory: "128Mi"+## Node labels for pod assignment## ref: https://kubernetes.io/docs/user-guide/node-selection/##diff --git a/docs/security/how-to-authenticate.md b/docs/security/how-to-authenticate.mdindex 6ea061995f..6e88be6728 100644--- a/docs/security/how-to-authenticate.md+++ b/docs/security/how-to-authenticate.md@@ -230,7 +230,7 @@ docker run -dti -p 8080:8080 -e KC_BOOTSTRAP_ADMIN_USERNAME=admin -e KC_BOOTSTRA* Confirm that `Client authentication` `Standard flow` `Direct access grants` `Service accounts roles` is enabled.* Click *Next** Set *Valid redirect URIs* to `http://localhost:8090/*`- * Set *Web origins* to `http://localhost:8090/*`+ * Set *Web origins* to `http://localhost:8090`* Click *Save*.* Click *Credentials* tab page, get `Client Secret`.