Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: clusterpedia-io/clusterpedia-helm
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 35b102d4b86c549555206a649d9c5ccd5b5bf930
Choose a base ref
..
head repository: clusterpedia-io/clusterpedia-helm
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: fdd21d8501948c1770ab66ccf80beab237d8448d
Choose a head ref
2 changes: 1 addition & 1 deletion charts/clusterpedia/Chart.yaml
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ 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: 2.2.1
version: 3.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
2 changes: 1 addition & 1 deletion charts/clusterpedia/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -388,4 +388,4 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this
- name: OTEL_RESOURCE_ATTRIBUTES
value: 'k8s.namespace.name=$(OTEL_K8S_NAMESPACE),k8s.node.name=$(OTEL_RESOURCE_ATTRIBUTES_NODE_NAME),k8s.pod.name=$(OTEL_RESOURCE_ATTRIBUTES_POD_NAME)'
{{- end -}}
{{- end -}}
{{- end -}}
48 changes: 14 additions & 34 deletions charts/clusterpedia/templates/apiserver-deployment.yaml
Original file line number Diff line number Diff line change
@@ -39,33 +39,24 @@ spec:
{{- if eq (include "clusterpedia.storage.type" .) "postgres" }}
- |
# Load YAML data into a Bash variable
source /opt/scripts/parse-yaml.sh;
create_variables /etc/clusterpedia/storage/internalstorage-config.yaml;
until psql -U ${user} -h ${host} -p ${port} postgres -c "SELECT 1 FROM pg_database WHERE datname = ${database}" | grep -q 1 || psql -U ${user} -h ${host} -p ${port} postgres -c "CREATE DATABASE ${database} owner ${user} " -c "GRANT ALL PRIVILEGES ON DATABASE ${database} to ${user}"; do
if [ -n ${DB_DSN} ]; then source /opt/scripts/parse-yaml.sh; create_variables ${DB_DSN}; fi;
until psql -U ${DB_USER} -h ${DB_HOST} -p ${DB_PORT} postgres -c "SELECT 1 FROM pg_database WHERE datname = ${DB_DATABASE}" | grep -q 1 || psql -U ${DB_USER} -h ${DB_HOST} -p ${DB_PORT} postgres -c "CREATE DATABASE ${DB_DATABASE} owner ${DB_USER} " -c "GRANT ALL PRIVILEGES ON DATABASE ${DB_DATABASE} to ${DB_USER}"; do
echo waiting for database check && sleep 1;
done;
echo 'DataBase OK ✓'
{{- else if eq (include "clusterpedia.storage.type" .) "mysql" }}
- |
# Load YAML data into a Bash variable
source /opt/scripts/parse-yaml.sh;
create_variables /etc/clusterpedia/storage/internalstorage-config.yaml;
if [ -z $password ]; then password=${DB_PASSWORD}; fi;
until mysql -u${user} -p${password} --host=${host} --port=${port} -e "CREATE DATABASE IF NOT EXISTS ${database}"; do
if [ -n ${DB_DSN} ]; then source /opt/scripts/parse-yaml.sh; create_variables ${DB_DSN}; fi;
until mysql -u${DB_USER} -p${DB_PASSWORD} --host=${DB_HOST} --port=${DB_PORT} -e "CREATE DATABASE IF NOT EXISTS ${DB_DATABASE}"; do
echo waiting for database check && sleep 1;
done;
echo 'DataBase OK ✓'
{{- end }}
env:
- name: {{ include "clusterpedia.storage.password.envKey" . }}
valueFrom:
secretKeyRef:
name: {{ include "clusterpedia.internalstorage.fullname" . }}
key: password
envFrom:
- secretRef:
name: {{ include "clusterpedia.internalstorage.fullname" . }}
volumeMounts:
- name: internalstorage-config
mountPath: /etc/clusterpedia/storage
readOnly: true
- name: scripts
mountPath: /opt/scripts
readOnly: true
@@ -78,35 +69,24 @@ spec:
{{- if eq (include "clusterpedia.storage.type" .) "postgres" }}
- |
# Load YAML data into a Bash variable
source /opt/scripts/parse-yaml.sh;
create_variables /etc/clusterpedia/storage/internalstorage-config.yaml;
until pg_isready -U ${user} -d "dbname=${database}" -h ${host} -p ${port}; do
if [ -n ${DB_DSN} ]; then source /opt/scripts/parse-yaml.sh; create_variables ${DB_DSN}; fi;
until pg_isready -U ${DB_USER} -d "dbname=${DB_DATABASE}" -h ${DB_HOST} -p ${DB_PORT}; do
echo waiting for database check && sleep 1;
done;
echo 'DataBase OK ✓'
{{- else if eq (include "clusterpedia.storage.type" .) "mysql" }}
- |
# Load YAML data into a Bash variable
source /opt/scripts/parse-yaml.sh;
create_variables /etc/clusterpedia/storage/internalstorage-config.yaml;
if [ -z $password ]; then password=${DB_PASSWORD}; fi;
until mysqladmin status -u${user} -p${password} --host=${host} --port=${port}; do
if [ -n ${DB_DSN} ]; then source /opt/scripts/parse-yaml.sh; create_variables ${DB_DSN}; fi;
until mysqladmin status -u${DB_USER} -p${DB_PASSWORD} --host=${DB_HOST} --port=${DB_PORT}; do
echo waiting for database check && sleep 1;
done;
echo 'DataBase OK ✓'
{{- end }}
{{- if eq (include "clusterpedia.storage.type" .) "mysql" }}
env:
- name: DB_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "clusterpedia.internalstorage.fullname" . }}
key: password
{{- end }}
envFrom:
- secretRef:
name: {{ include "clusterpedia.internalstorage.fullname" . }}
volumeMounts:
- name: internalstorage-config
mountPath: /etc/clusterpedia/storage
readOnly: true
- name: scripts
mountPath: /opt/scripts
readOnly: true
Original file line number Diff line number Diff line change
@@ -39,33 +39,24 @@ spec:
{{- if eq (include "clusterpedia.storage.type" .) "postgres" }}
- |
# Load YAML data into a Bash variable
source /opt/scripts/parse-yaml.sh;
create_variables /etc/clusterpedia/storage/internalstorage-config.yaml;
until psql -U ${user} -h ${host} -p ${port} postgres -c "SELECT 1 FROM pg_database WHERE datname = '{{ include "clusterpedia.storage.database" . }}'" | grep -q 1 || psql -U ${user} -h ${host} -p ${port} postgres -c "CREATE DATABASE {{ include "clusterpedia.storage.database" . }} owner ${user} " -c "GRANT ALL PRIVILEGES ON DATABASE {{ include "clusterpedia.storage.database" . }} to ${user} "; do
if [ -n ${DB_DSN} ]; then source /opt/scripts/parse-yaml.sh; create_variables ${DB_DSN}; fi;
until psql -U ${DB_USER} -h ${DB_HOST} -p ${DB_PORT} postgres -c "SELECT 1 FROM pg_database WHERE datname = '{{ include "clusterpedia.storage.database" . }}'" | grep -q 1 || psql -U ${DB_USER} -h ${DB_HOST} -p ${DB_PORT} postgres -c "CREATE DATABASE {{ include "clusterpedia.storage.database" . }} owner ${DB_USER} " -c "GRANT ALL PRIVILEGES ON DATABASE {{ include "clusterpedia.storage.database" . }} to ${DB_USER} "; do
echo waiting for database check && sleep 1;
done;
echo 'DataBase OK ✓'
{{- else if eq (include "clusterpedia.storage.type" .) "mysql" }}
- |
# Load YAML data into a Bash variable
source /opt/scripts/parse-yaml.sh;
create_variables /etc/clusterpedia/storage/internalstorage-config.yaml;
if [ -z $password ]; then password=${DB_PASSWORD}; fi;
until mysql -u${user} -p${password} --host=${host} --port=${port} -e 'CREATE DATABASE IF NOT EXISTS {{ include "clusterpedia.storage.database" . }}'; do
if [ -n ${DB_DSN} ]; then source /opt/scripts/parse-yaml.sh; create_variables ${DB_DSN}; fi;
until mysql -u${DB_USER} -p${DB_PASSWORD} --host=${DB_HOST} --port=${DB_PORT} -e 'CREATE DATABASE IF NOT EXISTS {{ include "clusterpedia.storage.database" . }}'; do
echo waiting for database check && sleep 1;
done;
echo 'DataBase OK ✓'
{{- end }}
env:
- name: {{ include "clusterpedia.storage.password.envKey" . }}
valueFrom:
secretKeyRef:
name: {{ include "clusterpedia.internalstorage.fullname" . }}
key: password
envFrom:
- secretRef:
name: {{ include "clusterpedia.internalstorage.fullname" . }}
volumeMounts:
- name: internalstorage-config
mountPath: /etc/clusterpedia/storage
readOnly: true
- name: scripts
mountPath: /opt/scripts
readOnly: true
@@ -78,35 +69,24 @@ spec:
{{- if eq (include "clusterpedia.storage.type" .) "postgres" }}
- |
# Load YAML data into a Bash variable
source /opt/scripts/parse-yaml.sh;
create_variables /etc/clusterpedia/storage/internalstorage-config.yaml;
until pg_isready -U ${user} -d "dbname=${database}" -h ${host} -p ${port}; do
if [ -n ${DB_DSN} ]; then source /opt/scripts/parse-yaml.sh; create_variables ${DB_DSN}; fi;
until pg_isready -U ${DB_USER} -d "dbname=${DB_DATABASE}" -h ${DB_HOST} -p ${DB_PORT}; do
echo waiting for database check && sleep 1;
done;
echo 'DataBase OK ✓'
{{- else if eq (include "clusterpedia.storage.type" .) "mysql" }}
- |
# Load YAML data into a Bash variable
source /opt/scripts/parse-yaml.sh;
create_variables /etc/clusterpedia/storage/internalstorage-config.yaml;
if [ -z $password ]; then password=${DB_PASSWORD}; fi;
until mysqladmin status -u${user} -p${password} --host=${host} --port=${port}; do
if [ -n ${DB_DSN} ]; then source /opt/scripts/parse-yaml.sh; create_variables ${DB_DSN}; fi;
until mysqladmin status -u${DB_USER} -p${password} --host=${DB_PASSWORD} --port=${DB_PORT}; do
echo waiting for database check && sleep 1;
done;
echo 'DataBase OK ✓'
{{- end }}
{{- if eq (include "clusterpedia.storage.type" .) "mysql" }}
env:
- name: DB_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "clusterpedia.internalstorage.fullname" . }}
key: password
{{- end }}
envFrom:
- secretRef:
name: {{ include "clusterpedia.internalstorage.fullname" . }}
volumeMounts:
- name: internalstorage-config
mountPath: /etc/clusterpedia/storage
readOnly: true
- name: scripts
mountPath: /opt/scripts
readOnly: true
18 changes: 11 additions & 7 deletions charts/clusterpedia/templates/internalstorage-secret.yaml
Original file line number Diff line number Diff line change
@@ -7,10 +7,14 @@ metadata:
app: {{ include "clusterpedia.internalstorage.fullname" . }}
internalstorage.clusterpedia.io/type: {{ include "clusterpedia.storage.type" . }}
data:
DB_TYPE: {{ include "clusterpedia.storage.type" . | quote }}
DB_DSN: {{ include "clusterpedia.storage.dsn" . | quote }}
DB_HOST: {{ include "clusterpedia.storage.host" . | quote }}
DB_PORT: {{ include "clusterpedia.storage.port" . }}
DB_USER: {{ include "clusterpedia.storage.user" . }}
DB_PASSWORD: {{ include "clusterpedia.storage.password" . }}
DB_DATABASE: {{ include "clusterpedia.storage.database" . }}
{{- if empty (include "clusterpedia.storage.dsn" .) }}
DB_TYPE: {{ include "clusterpedia.storage.type" . | b64enc }}
DB_HOST: {{ include "clusterpedia.storage.host" . | b64enc }}
DB_PORT: "{{ include "clusterpedia.storage.port" . | b64enc }}"
DB_USER: "{{ include "clusterpedia.storage.user" . | b64enc }}"
DB_PASSWORD: {{ include "clusterpedia.storage.password" . | b64enc }}
DB_DATABASE: {{ include "clusterpedia.storage.database" . | b64enc }}
{{- else }}
DB_TYPE: {{ include "clusterpedia.storage.type" . | b64enc | quote}}
DB_DSN: {{ include "clusterpedia.storage.dsn" . | b64enc | quote}}
{{- end }}
46 changes: 13 additions & 33 deletions charts/clusterpedia/templates/scripts-configmap.yaml
Original file line number Diff line number Diff line change
@@ -6,23 +6,6 @@ metadata:
labels: {{- include "common.labels.standard" . | nindent 4 }}
data:
parse-yaml.sh: |
function parse_yaml() {
local prefix=$2
local s='[[:space:]]*' w='[a-zA-Z0-9_]*' fs=$(echo @|tr @ '\034')
sed -ne "s|^\($s\):|\1|" \
-e "s|^\($s\)\($w\)$s:$s[\"']\(.*\)[\"']$s\$|\1$fs\2$fs\3|p" \
-e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p" $1 |
awk -F$fs '{
indent = length($1)/2;
vname[indent] = $2;
for (i in vname) {if (i > indent) {delete vname[i]}}
if (length($3) > 0) {
vn=""; for (i=0; i<indent; i++) {vn=(vn)(vname[i])("_")}
printf("%s%s%s=\"%s\"\n", "'$prefix'",vn, $2, $3);
}
}'
}
function parse_mysql_dsn() {
local dsn=$1
if [ -z $dsn ]
@@ -41,11 +24,11 @@ data:
IFS=':' read -r -a address <<< $address; host=${address[0]}; port=${address[1]}
fi
echo "database=\"$database\""
echo "host=\"$host\""
echo "port=\"$port\""
echo "user=\"$user\""
echo "password=\"$password\""
echo "DB_DATABASE=\"$database\""
echo "DB_HOST=\"$host\""
echo "DB_PORT=\"$port\""
echo "DB_USER=\"$user\""
echo "DB_PASSWORD=\"$password\""
}
function parse_postgres_dsn() {
@@ -71,23 +54,20 @@ data:
fi
done
echo "database=\"$database\""
echo "host=\"$host\""
echo "port=\"$port\""
echo "user=\"$user\""
echo "DB_DATABASE=\"$database\""
echo "DB_HOST=\"$host\""
echo "DB_PORT=\"$port\""
echo "DB_USER=\"$user\""
}
function create_variables() {
local yaml_file="$1"
eval "$(parse_yaml "$yaml_file")"
if [ $type == "mysql" ]
if [ $DB_TYPE == "mysql" ]
then
eval $(parse_mysql_dsn "$dsn")
eval $(parse_mysql_dsn "$DB_DSN")
fi
if [ $type == "postgres" ]
if [ $DB_TYPE == "postgres" ]
then
eval $(parse_postgres_dsn "$dsn")
eval $(parse_postgres_dsn "$DB_DSN")
fi
}