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

chore: remove deprecated built in KB_XXX envs #1333

Merged
merged 7 commits into from
Dec 18, 2024
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
8 changes: 4 additions & 4 deletions addons/apecloud-mysql/scripts-ut-spec/etcd_clean_spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ Describe "Etcd Clean Script Tests"
Describe "when SERVICE_ETCD_ENDPOINT is set,"
setup() {
SERVICE_ETCD_ENDPOINT="http://localhost:2379"
KB_NAMESPACE="test-namespace"
KB_CLUSTER_NAME="test-cluster"
CLUSTER_NAMESPACE="test-namespace"
CLUSTER_NAME="test-cluster"
ETCDCTL_API="3"
}
Before "setup"
Expand Down Expand Up @@ -67,8 +67,8 @@ Describe "Etcd Clean Script Tests"
Describe "when ETCDCTL_API is set to 2"
setup() {
SERVICE_ETCD_ENDPOINT="http://localhost:2379"
KB_NAMESPACE="test-namespace"
KB_CLUSTER_NAME="test-cluster"
CLUSTER_NAMESPACE="test-namespace"
CLUSTER_NAME="test-cluster"
ETCDCTL_API="2"
}
Before "setup"
Expand Down
20 changes: 10 additions & 10 deletions addons/apecloud-mysql/scripts-ut-spec/etcd_post_start_spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ Describe "etcd-post-start.sh script tests"
LOCAL_ETCD_POD_FQDN="etcd1,etcd2"
LOCAL_ETCD_PORT="2379"
CELL="zone1"
KB_NAMESPACE="test-namespace"
KB_CLUSTER_NAME="test-cluster"
CLUSTER_NAMESPACE="test-namespace"
CLUSTER_NAME="test-cluster"
ETCDCTL_API="3"
}
Before "setup"
Expand All @@ -27,8 +27,8 @@ Describe "etcd-post-start.sh script tests"
setup() {
SERVICE_ETCD_ENDPOINT="http://etcd1:2379,http://etcd2:2379"
CELL="zone1"
KB_NAMESPACE="test-namespace"
KB_CLUSTER_NAME="test-cluster"
CLUSTER_NAMESPACE="test-namespace"
CLUSTER_NAME="test-cluster"
ETCDCTL_API="3"
}
Before "setup"
Expand All @@ -46,8 +46,8 @@ Describe "etcd-post-start.sh script tests"
Describe "when both LOCAL_ETCD_POD_FQDN and SERVICE_ETCD_ENDPOINT are empty"
setup() {
CELL="zone1"
KB_NAMESPACE="test-namespace"
KB_CLUSTER_NAME="test-cluster"
CLUSTER_NAMESPACE="test-namespace"
CLUSTER_NAME="test-cluster"
ETCDCTL_API="3"
}
Before "setup"
Expand All @@ -64,8 +64,8 @@ Describe "etcd-post-start.sh script tests"
LOCAL_ETCD_POD_FQDN="etcd1,etcd2"
LOCAL_ETCD_PORT="2379"
CELL="zone1"
KB_NAMESPACE="test-namespace"
KB_CLUSTER_NAME="test-cluster"
CLUSTER_NAMESPACE="test-namespace"
CLUSTER_NAME="test-cluster"
ETCDCTL_API="2"
}
Before "setup"
Expand Down Expand Up @@ -95,8 +95,8 @@ Describe "etcd-post-start.sh script tests"
LOCAL_ETCD_POD_FQDN="etcd1,etcd2"
LOCAL_ETCD_PORT="2379"
CELL="zone1"
KB_NAMESPACE="test-namespace"
KB_CLUSTER_NAME="test-cluster"
CLUSTER_NAMESPACE="test-namespace"
CLUSTER_NAME="test-cluster"
ETCDCTL_API="3"
}
Before "setup"
Expand Down
12 changes: 6 additions & 6 deletions addons/apecloud-mysql/scripts-ut-spec/setup_spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ Describe "ApeCloud MySQL Startup Script Tests"
MY_POD_LIST=wesql1-mysql-0,wesql1-mysql-1,wesql1-mysql-2
MY_COMP_REPLICAS=3
MY_COMP_NAME=mysql
MY_CLUSTER_NAME=wesql1
MY_CLUSTER_UID=c3636ff1-bb54-47a4-ac4e-111ba9b41295
CLUSTER_NAME=wesql1
CLUSTER_UID=c3636ff1-bb54-47a4-ac4e-111ba9b41295
KB_SERVICE_CHARACTER_TYPE=wesql
KB_MYSQL_VOLUME_DIR=.
}
Expand Down Expand Up @@ -90,7 +90,7 @@ Describe "get_service_name function"
Include ../scripts/setup.sh
setup() {
MY_COMP_NAME=mysql
MY_CLUSTER_NAME=wesql1
CLUSTER_NAME=wesql1
}
Before "setup"
It "returns the correct service name"
Expand All @@ -104,7 +104,7 @@ Describe "get_cluster_members function"
setup() {
MY_POD_LIST="pod1,pod2,pod3"
MY_COMP_NAME=mysql
MY_CLUSTER_NAME=wesql1
CLUSTER_NAME=wesql1
MYSQL_CONSENSUS_PORT=13306
}
Before "setup"
Expand Down Expand Up @@ -132,9 +132,9 @@ Describe "generate_cluster_info function"
MY_POD_NAME="pod1"
MY_POD_LIST="pod1,pod2,pod3"
MY_COMP_NAME=mysql
MY_CLUSTER_NAME=wesql1
CLUSTER_NAME=wesql1
MY_COMP_REPLICAS=3
MY_CLUSTER_UID="test-uid"
CLUSTER_UID="test-uid"
}
Before "setup"
It "sets the correct environment variables"
Expand Down
8 changes: 4 additions & 4 deletions addons/apecloud-mysql/scripts-ut-spec/vtctld_spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ Describe "vtctld.sh script tests"
export CELL="zone1"
export VTCTLD_GRPC_PORT="15999"
export VTCTLD_WEB_PORT="15000"
export KB_NAMESPACE="namespace"
export KB_CLUSTER_NAME="cluster"
export CLUSTER_NAMESPACE="namespace"
export CLUSTER_NAME="cluster"
export VTDATAROOT="/var/lib/vitess"
}
Before "setup"
Expand All @@ -22,8 +22,8 @@ Describe "vtctld.sh script tests"
unset CELL
unset VTCTLD_GRPC_PORT
unset VTCTLD_WEB_PORT
unset KB_NAMESPACE
unset KB_CLUSTER_NAME
unset CLUSTER_NAMESPACE
unset CLUSTER_NAME
unset VTDATAROOT
}
After "cleanup"
Expand Down
8 changes: 4 additions & 4 deletions addons/apecloud-mysql/scripts/etcd-clean.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ servers=${servers:1}

echo $servers

echo "Deleting all keys with prefix /vitess/${KB_NAMESPACE}/${KB_CLUSTER_NAME} from Etcd server at ${endpoints}..."
echo "Deleting all keys with prefix /vitess/${CLUSTER_NAMESPACE}/${CLUSTER_NAME} from Etcd server at ${endpoints}..."

# Set different deletion methods according to different etcdctl versions.
if [[ ${ETCDCTL_API} == "2" ]]; then
etcdctl --endpoints $servers rm -r /vitess/${KB_NAMESPACE}/${KB_CLUSTER_NAME}
etcdctl --endpoints $servers rm -r /vitess/${CLUSTER_NAMESPACE}/${CLUSTER_NAME}
else
etcdctl --endpoints $servers del /vitess/${KB_NAMESPACE}/${KB_CLUSTER_NAME} --prefix
etcdctl --endpoints $servers del /vitess/${CLUSTER_NAMESPACE}/${CLUSTER_NAME} --prefix
fi

if [ $? -eq 0 ]; then
echo "Successfully deleted all keys with prefix /vitess/${KB_NAMESPACE}/$KB_CLUSTER_NAME."
echo "Successfully deleted all keys with prefix /vitess/${CLUSTER_NAMESPACE}/$CLUSTER_NAME."
else
echo "Failed to delete keys. Please check your Etcd server and try again."
exit 1
Expand Down
16 changes: 8 additions & 8 deletions addons/apecloud-mysql/scripts/etcd-post-start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,17 @@ echo $servers

if [[ ${ETCDCTL_API} == "2" ]]; then
# etcdctl API 2 manages data in a directory-based format, requiring directories to be created in advance.
etcdctl --endpoints=${servers} get "/vitess/${KB_NAMESPACE}/${KB_CLUSTER_NAME}/$cell" >/dev/null 2>&1
etcdctl --endpoints=${servers} get "/vitess/${CLUSTER_NAMESPACE}/${CLUSTER_NAME}/$cell" >/dev/null 2>&1
if [[ $? -eq 0 ]]; then
exit 0
fi
echo "add /vitess/$KB_NAMESPACE/$KB_CLUSTER_NAME/global"
etcdctl --endpoints=${servers} mkdir /vitess/${KB_NAMESPACE}/${KB_CLUSTER_NAME}/global
echo "add /vitess/$KB_NAMESPACE/$KB_CLUSTER_NAME/$cell"
etcdctl --endpoints=${servers} mkdir /vitess/${KB_NAMESPACE}/${KB_CLUSTER_NAME}/$cell
echo "add /vitess/$CLUSTER_NAMESPACE/$CLUSTER_NAME/global"
etcdctl --endpoints=${servers} mkdir /vitess/${CLUSTER_NAMESPACE}/${CLUSTER_NAME}/global
echo "add /vitess/$CLUSTER_NAMESPACE/$CLUSTER_NAME/$cell"
etcdctl --endpoints=${servers} mkdir /vitess/${CLUSTER_NAMESPACE}/${CLUSTER_NAME}/$cell
else
# etcdctl API 3 manages data in key-value pairs, eliminating the need to create additional directories.
output=$(etcdctl --endpoints="${servers}" get "/vitess/${KB_NAMESPACE}/${KB_CLUSTER_NAME}/$cell" --prefix --keys-only)
output=$(etcdctl --endpoints="${servers}" get "/vitess/${CLUSTER_NAMESPACE}/${CLUSTER_NAME}/$cell" --prefix --keys-only)
if [[ -n $output ]]; then
exit 0
fi
Expand All @@ -50,8 +50,8 @@ echo "add $cell CellInfo"
set +e
vtctl --topo_implementation etcd2 \
--topo_global_server_address "${servers}" \
--topo_global_root "/vitess/${KB_NAMESPACE}/${KB_CLUSTER_NAME}/global" VtctldCommand AddCellInfo \
--root "/vitess/${KB_NAMESPACE}/${KB_CLUSTER_NAME}/$cell" \
--topo_global_root "/vitess/${CLUSTER_NAMESPACE}/${CLUSTER_NAME}/global" VtctldCommand AddCellInfo \
--root "/vitess/${CLUSTER_NAMESPACE}/${CLUSTER_NAME}/$cell" \
--server-address "${servers}" \
$cell
set -e
6 changes: 3 additions & 3 deletions addons/apecloud-mysql/scripts/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ if [ -z "${__SOURCED__:+x}" ]; then
set -ex
fi

# MY_CLUSTER_NAME=clustername
# CLUSTER_NAME=clustername
# MY_COMP_NAME=componentname
# compose headless service name from cluster and component name
# return: clustername-componentname-headless
get_service_name() {
cluster_name=${MY_CLUSTER_NAME:?missing cluster name}
cluster_name=${CLUSTER_NAME:?missing cluster name}
component_name=${MY_COMP_NAME:?missing component name}
echo "${cluster_name}-${component_name}-headless"
}
Expand Down Expand Up @@ -55,7 +55,7 @@ generate_cluster_info() {
echo "KB_MYSQL_N=${KB_MYSQL_N}"

if [ -z "$KB_MYSQL_CLUSTER_UID" ]; then
export KB_MYSQL_CLUSTER_UID=${MY_CLUSTER_UID:?missing cluster uid}
export KB_MYSQL_CLUSTER_UID=${CLUSTER_UID:?missing cluster uid}
fi
echo "KB_MYSQL_CLUSTER_UID=${KB_MYSQL_CLUSTER_UID}"

Expand Down
2 changes: 1 addition & 1 deletion addons/apecloud-mysql/scripts/vtctld.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ cell=${CELL:-'zone1'}
grpc_port=${VTCTLD_GRPC_PORT:-'15999'}
vtctld_web_port=${VTCTLD_WEB_PORT:-'15000'}

topology_fags="--topo_implementation etcd2 --topo_global_server_address ${endpoints} --topo_global_root /vitess/${KB_NAMESPACE}/${KB_CLUSTER_NAME}/global"
topology_fags="--topo_implementation etcd2 --topo_global_server_address ${endpoints} --topo_global_root /vitess/${CLUSTER_NAMESPACE}/${CLUSTER_NAME}/global"

VTDATAROOT=$VTDATAROOT/vtctld
su vitess <<EOF
Expand Down
2 changes: 1 addition & 1 deletion addons/apecloud-mysql/scripts/vtgate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ fi

echo $endpoints

topology_fags="--topo_implementation etcd2 --topo_global_server_address ${endpoints} --topo_global_root /vitess/${KB_NAMESPACE}/${KB_CLUSTER_NAME}/global"
topology_fags="--topo_implementation etcd2 --topo_global_server_address ${endpoints} --topo_global_root /vitess/${CLUSTER_NAMESPACE}/${CLUSTER_NAME}/global"

echo "starting vtgate."
su vitess <<EOF
Expand Down
4 changes: 2 additions & 2 deletions addons/apecloud-mysql/scripts/vttablet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ vtctld_host=${VTCTLD_HOST:-'127.0.0.1'}
vtctld_web_port=${VTCTLD_WEB_PORT:-'15000'}
printf -v alias '%s-%010d' $cell $uid
printf -v tablet_dir 'vt_%010d' $uid
tablet_hostname=$(eval echo \$KB_"$uid"_HOSTNAME)
tablet_hostname="$MY_POD_NAME.$MY_COMP_NAME-headless.$CLUSTER_NAMESPACE.svc.cluster.local"
printf -v tablet_logfile 'vttablet_%010d_querylog.txt' $uid

tablet_type=replica
Expand All @@ -44,7 +44,7 @@ fi

echo $endpoints

topology_fags="--topo_implementation etcd2 --topo_global_server_address ${endpoints} --topo_global_root /vitess/${KB_NAMESPACE}/${KB_CLUSTER_NAME}/global"
topology_fags="--topo_implementation etcd2 --topo_global_server_address ${endpoints} --topo_global_root /vitess/${CLUSTER_NAMESPACE}/${CLUSTER_NAME}/global"

VTDATAROOT=$VTDATAROOT/vttablet
su vitess <<EOF
Expand Down
14 changes: 9 additions & 5 deletions addons/apecloud-mysql/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -294,11 +294,15 @@ vars:
componentVarRef:
optional: false
replicas: Required
- name: MY_CLUSTER_NAME
- name: CLUSTER_NAME
valueFrom:
clusterVarRef:
clusterName: Required
- name: MY_CLUSTER_UID
- name: CLUSTER_NAMESPACE
valueFrom:
clusterVarRef:
namespace: Required
- name: CLUSTER_UID
valueFrom:
clusterVarRef:
clusterUID: Required
Expand Down Expand Up @@ -347,9 +351,9 @@ env:
- name: KB_MYSQL_CONF_FILE
value: "/opt/mysql/my.cnf"
- name: KB_MYSQL_CLUSTER_UID
value: $(KB_CLUSTER_UID)
value: $(CLUSTER_UID)
- name: KB_MYSQL_N
value: $(KB_COMP_REPLICAS)
value: $(MY_COMP_REPLICAS)
- name: CLUSTER_DOMAIN
value: {{ .Values.clusterDomain }}
- name: MY_POD_NAME
Expand Down Expand Up @@ -406,7 +410,7 @@ env:
value: "15100"
- name: VTTABLET_GRPC_PORT
- name: VTCTLD_HOST
value: "$(KB_CLUSTER_NAME)-wescale-ctrl-headless"
value: "$(CLUSTER_NAME)-wescale-ctrl-headless"
- name: VTCTLD_WEB_PORT
value: "15000"
- name: SERVICE_PORT
Expand Down
14 changes: 13 additions & 1 deletion addons/apecloud-mysql/templates/cmpd-wescale-controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ spec:
- name: CELL
value: {{ .Values.wesqlscale.cell | default "zone1" | quote }}
- name: VTCTLD_SERVER
value: "$(KB_CLUSTER_NAME)-wescale-ctrl-headless"
value: "$(CLUSTER_NAME)-wescale-ctrl-headless"
- name: VTCTLD_WEB_PORT
value: "15000"
- name: VTCTLD_GRPC_PORT
Expand All @@ -56,6 +56,18 @@ spec:
- name: data
mountPath: /vtdataroot
vars:
- name: CLUSTER_NAME
valueFrom:
clusterVarRef:
clusterName: Required
- name: CLUSTER_NAMESPACE
valueFrom:
clusterVarRef:
namespace: Required
- name: CLUSTER_UID
valueFrom:
clusterVarRef:
clusterUID: Required
- name: MYSQL_ROOT_USER
valueFrom:
credentialVarRef:
Expand Down
12 changes: 12 additions & 0 deletions addons/apecloud-mysql/templates/cmpd-wescale.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,18 @@ spec:
scrapePath: /metrics
scrapePort: webport
vars:
- name: CLUSTER_NAME
valueFrom:
clusterVarRef:
clusterName: Required
- name: CLUSTER_NAMESPACE
valueFrom:
clusterVarRef:
namespace: Required
- name: CLUSTER_UID
valueFrom:
clusterVarRef:
clusterUID: Required
- name: MYSQL_USER
valueFrom:
credentialVarRef:
Expand Down
2 changes: 1 addition & 1 deletion addons/apecloud-postgresql/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ vars:
password: Required
# env for syncer to initialize dcs
# TODO: modify these env for syncer
- name: MY_CLUSTER_NAME
- name: CLUSTER_NAME
valueFrom:
clusterVarRef:
clusterName: Required
Expand Down
2 changes: 1 addition & 1 deletion addons/etcd/dataprotection/backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ handle_exit() {
trap handle_exit EXIT

# use etcdctl create snapshot
ENDPOINTS=${DP_DB_HOST}.${KB_NAMESPACE}.svc${CLUSTER_DOMAIN}:2379
ENDPOINTS=${DP_DB_HOST}.${CLUSTER_NAMESPACE}.svc${CLUSTER_DOMAIN}:2379
exec_etcdctl "${ENDPOINTS}" snapshot save "${DP_BACKUP_NAME}"
# check the backup file, make sure it is not empty
if check_backup_file "${DP_BACKUP_NAME}"; then
Expand Down
2 changes: 1 addition & 1 deletion addons/etcd/dataprotection/restore.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ if [ "$(datasafed list "${remote_backup_file}")" = "${remote_backup_file}" ]; th
fi

backup_file=${restore_dir}/${DP_BACKUP_NAME}
endpoint=${DP_DB_HOST}.${KB_NAMESPACE}.svc${CLUSTER_DOMAIN}:2379
endpoint=${DP_DB_HOST}.${CLUSTER_NAMESPACE}.svc${CLUSTER_DOMAIN}:2379

if check_backup_file "${backup_file}"; then
echo "Backup file is valid"
Expand Down
5 changes: 5 additions & 0 deletions addons/kafka/templates/cmpd-broker-27.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ spec:
componentVarRef:
optional: false
componentName: Required
- name: COMPONENT_REPLICAS
valueFrom:
componentVarRef:
optional: false
replicas: Required
- name: CLUSTER_NAME
valueFrom:
clusterVarRef:
Expand Down
5 changes: 5 additions & 0 deletions addons/kafka/templates/cmpd-broker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ spec:
componentVarRef:
optional: false
componentName: Required
- name: COMPONENT_REPLICAS
valueFrom:
componentVarRef:
optional: false
replicas: Required
## Todo: currently only nodeport and clusterIp network modes are supported. LoadBalance is not supported yet and needs future support.
- name: BROKER_ADVERTISED_PORT
valueFrom:
Expand Down
Loading
Loading