Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
wenxinlee2015 committed Oct 20, 2023
2 parents cfc5a3d + a24ea69 commit 184d228
Show file tree
Hide file tree
Showing 10 changed files with 264 additions and 4 deletions.
6 changes: 6 additions & 0 deletions bcs-ops/env/offline-manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ bcs-ops:
containerd: "1.6.21"
runc: "1.1.8"
docker: "19.03.9"
jq: "1.6"
yq: "4.30.6"

images:
- hub.bktencent.com/registry.k8s.io/kube-apiserver:v1.20.15
Expand Down Expand Up @@ -44,6 +46,8 @@ bcs-ops:
containerd: "1.6.21"
runc: "1.1.8"
docker: "19.03.9"
jq: "1.6"
yq: "4.30.6"

images:
- hub.bktencent.com/registry.k8s.io/kube-apiserver:v1.23.17
Expand Down Expand Up @@ -79,6 +83,8 @@ bcs-ops:
crictl: "1.26.0"
containerd: "1.6.21"
runc: "1.1.8"
jq: "1.6"
yq: "4.30.6"

images:
- hub.bktencent.com/registry.k8s.io/kube-apiserver:v1.24.15
Expand Down
4 changes: 3 additions & 1 deletion bcs-ops/install_master.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ safe_source "${ROOT_DIR}/functions/k8s.sh"

"${ROOT_DIR}"/system/config_envfile.sh -c init
"${ROOT_DIR}"/system/config_system.sh -c dns sysctl
"${ROOT_DIR}"/tools/install_tools.sh jq yq
"${ROOT_DIR}"/system/install_yq
"${ROOT_DIR}"/k8s/install_cri.sh
"${ROOT_DIR}"/k8s/install_k8s_tools
"${ROOT_DIR}"/k8s/render_kubeadm
Expand Down Expand Up @@ -108,4 +110,4 @@ else
fi
fi

"${ROOT_DIR}"/k8s/install_k8s
"${ROOT_DIR}"/k8s/install_k8s
1 change: 1 addition & 0 deletions bcs-ops/install_node.sh
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ safe_source "${ROOT_DIR}/functions/k8s.sh"

"${ROOT_DIR}"/system/config_envfile.sh -c init
"${ROOT_DIR}"/system/config_system.sh -c dns sysctl
"${ROOT_DIR}"/tools/install_tools.sh jq yq
"${ROOT_DIR}"/k8s/install_cri.sh
"${ROOT_DIR}"/k8s/install_k8s_tools
"${ROOT_DIR}"/k8s/render_kubeadm
Expand Down
2 changes: 1 addition & 1 deletion bcs-ops/install_op.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ for file in "${source_files[@]}"; do
safe_source "$file"
done

"${ROOT_DIR}"/k8s/operate_completion kubeadm kubectl helm ctr
"${ROOT_DIR}"/k8s/operate_completion kubeadm kubectl helm ctr yq

if [[ -n "${BKREPO_URL:-}" ]]; then
if command -v helm &>/dev/null; then
Expand Down
2 changes: 1 addition & 1 deletion bcs-ops/k8s/install_k8s_tools
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ _offline_k8s() {
}

main() {
local source_file
local source_files
source_files=("${ROOT_DIR}/functions/utils.sh" "${ROOT_DIR}/env/bcs.env")
for file in "${source_files[@]}"; do
safe_source "$file"
Expand Down
14 changes: 13 additions & 1 deletion bcs-ops/k8s/operate_completion
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ ROOT_DIR="${SELF_DIR}/.."

RC_FILE="/etc/bash_completion.d/bcs.bash"

PROJECTS=(kubeadm kubectl helm ctr)
PROJECTS=(kubeadm kubectl helm ctr yq)
readonly SELF_DIR ROOT_DIR RC_FILE PROJECTS

usage_and_exit() {
Expand Down Expand Up @@ -100,6 +100,18 @@ source <(helm completion bash)
EOF
}

completion_yq() {
check_completion
sed -ri \
'/bcs config begin for yq/,/bcs config end for yq/d' ${RC_FILE}
cat >>"$RC_FILE" <<'EOF'
# bcs config begin for yq
# yq 命令补全
source <(yq shell-completion bash)
# bcs config end for yq
EOF
}

completion_clean() {
rm -f ${RC_FILE}
}
Expand Down
3 changes: 3 additions & 0 deletions bcs-ops/system/config_envfile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ init_env() {
# mirror
## yum_mirror
MIRROR_URL=${MIRROR_URL:-"https://mirrors.tencent.com"}
## repo_url
REPO_URL=${REPO_URL:-"https://bkopen-1252002024.file.myqcloud.com/ce7/tools"}
##
MIRROR_IP=${MIRROR_IP:-}
## image_registry
Expand Down Expand Up @@ -277,6 +279,7 @@ CSI_EOF
## yum_mirror
MIRROR_URL="${MIRROR_URL}"
REPO_URL="${REPO_URL}"
MIRROR_IP="${MIRROR_IP}"
## image_registry
### docker.io
Expand Down
72 changes: 72 additions & 0 deletions bcs-ops/tools/install_jq
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!/bin/bash
#######################################
# Tencent is pleased to support the open source community by making Blueking Container Service available.
# Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
# Licensed under the MIT License (the "License"); you may not use this file except
# in compliance with the License. You may obtain a copy of the License at
# http://opensource.org/licenses/MIT
# 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.
#######################################

set -euo pipefail

# install jq
SELF_DIR=$(dirname "$(readlink -f "$0")")
ROOT_DIR="${SELF_DIR}/.."
readonly SELF_DIR ROOT_DIR

safe_source() {
local source_file=$1
if [[ -f ${source_file} ]]; then
#shellcheck source=/dev/null
source "${source_file}"
else
echo "[ERROR]: FAIL to source, missing ${source_file}"
exit 1
fi
}

_curl_jq() {
local url save_file version
version=$1
url="${REPO_URL}/jq-${version}.xz"
save_file="/tmp/jq.xz"
if curl -sSfL "${url}" -o "${save_file}" -m "360"; then
rm -f /tmp/jq
unxz -dc ${save_file} >/tmp/jq
chmod +x /tmp/jq
mv /tmp/jq /usr/local/bin/jq
rm -f ${save_file}
else
utils::log "ERROR" "fail to download jq"
fi
}

_offline_jq() {
# ToDo
true
}

main() {
local source_files
source_files=("${ROOT_DIR}/functions/utils.sh" "${ROOT_DIR}/env/bcs.env")
for file in "${source_files[@]}"; do
safe_source "$file"
done
jq_ver=$(awk '/jq/{gsub("\"","",$2);print $2;exit}' \
"${ROOT_DIR}"/env/offline-manifest.yaml)

if ! command -v jq >/dev/null; then
if [[ -n ${BCS_OFFLINE:-} ]]; then
_offline_jq
else
_curl_jq "$jq_ver"
fi
fi
utils::log "OK" "installed $(jq -V)"
}

main
91 changes: 91 additions & 0 deletions bcs-ops/tools/install_tools.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#!/bin/bash

#######################################
# Tencent is pleased to support the open source community by making Blueking Container Service available.
# Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
# Licensed under the MIT License (the "License"); you may not use this file except
# in compliance with the License. You may obtain a copy of the License at
# http://opensource.org/licenses/MIT
# 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.
#######################################

set -euo pipefail

# Process encapsulation of tool installation
VERSION="1.0.0"
PROGRAM="$(basename "$0")"
SELF_DIR=$(dirname "$(readlink -f "$0")")
ROOT_DIR="${SELF_DIR}/.."

PROJECTS=(yq jq)

readonly SELF_DIR ROOT_DIR PROJECTS

usage_and_exit() {
cat <<EOF
Usage:
$PROGRAM
[ -h --help -? show usage ]
[ -v -V --version show script version]
[ ${PROJECTS[*]} ]
EOF
exit "$1"
}

version() {
echo "$PROGRAM version $VERSION"
}

safe_source() {
local source_file=$1
if [[ -f ${source_file} ]]; then
#shellcheck source=/dev/null
source "${source_file}"
else
echo "[ERROR]: FAIL to source, missing ${source_file}"
exit 1
fi
}

main() {
local source_files
source_files=("${ROOT_DIR}/functions/utils.sh")
for file in "${source_files[@]}"; do
safe_source "$file"
done

local project

(($# == 0)) && usage_and_exit 1
while (($# > 0)); do
case "$1" in
--help | -h | '-?')
usage_and_exit 0
;;
--version | -v | -V)
version
exit 0
;;
-*)
# ToDo: Unified standard error code
export ERR_CODE=1
utils::log "ERROR" "unkown para: $1"
;;
*)
project="${ROOT_DIR}/tools/install_$1"
if [[ -x "${project}" ]]; then
"${project}"
else
utils::log "ERROR" "can't exec ${project}"
fi
;;
esac
shift
done
return 0
}

main "$@"
73 changes: 73 additions & 0 deletions bcs-ops/tools/install_yq
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/bin/bash
#######################################
# Tencent is pleased to support the open source community by making Blueking Container Service available.
# Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
# Licensed under the MIT License (the "License"); you may not use this file except
# in compliance with the License. You may obtain a copy of the License at
# http://opensource.org/licenses/MIT
# 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.
#######################################

set -euo pipefail

# install yq
SELF_DIR=$(dirname "$(readlink -f "$0")")
ROOT_DIR="${SELF_DIR}/.."
readonly SELF_DIR ROOT_DIR

safe_source() {
local source_file=$1
if [[ -f ${source_file} ]]; then
#shellcheck source=/dev/null
source "${source_file}"
else
echo "[ERROR]: FAIL to source, missing ${source_file}"
exit 1
fi
}

_curl_yq() {
local url save_file version
version=$1
url="${REPO_URL}/yq-${version}.xz"
save_file="/tmp/yq.xz"
if curl -sSfL "${url}" -o "${save_file}" -m "360"; then
# rm -f /tmp/yq
unxz -dc ${save_file} >/tmp/yq
chmod +x /tmp/yq
mv /tmp/yq /usr/local/bin/yq
rm -f ${save_file}
else
utils::log "ERROR" "fail to download yq: $url"
fi
}

_offline_yq() {
# ToDo
true
}

main() {
local source_files
source_files=("${ROOT_DIR}/functions/utils.sh" "${ROOT_DIR}/env/bcs.env")
for file in "${source_files[@]}"; do
safe_source "$file"
done
yq_ver=$(awk '/yq/{gsub("\"","",$2);print $2;exit}' \
"${ROOT_DIR}"/env/offline-manifest.yaml)

if ! command -v yq >/dev/null; then
if [[ -n ${BCS_OFFLINE:-} ]]; then
_offline_yq
else
_curl_yq "$yq_ver"
fi
fi
utils::log "OK" "installed $(yq -V)"
"$ROOT_DIR"/k8s/operate_completion yq
}

main

0 comments on commit 184d228

Please sign in to comment.