当前位置:网站首页>helm安装kubevela完整Makefile脚本内容
helm安装kubevela完整Makefile脚本内容
2022-07-27 15:07:00 【学亮编程手记】
Makefile
PROJECT ?= kubevela
VERSION ?= v1.4.8
CHART ?= 1.4.8
GIT_ACCESS_TOKEN=BLjk5y9ZwwQho_ETLcCj
IMAGE_PULLER = $(shell pwd)/bin/puller.sh
IMAGE_EXPORTER = $(shell pwd)/bin/exporter.sh
publish:
tar -czvf - -C ./releases ${PROJECT}-${VERSION} | ssh [email protected] "mkdir -p /zxl/kube-installer-plugins/${PROJECT} && cat > /zxl/kube-installer-plugins/${PROJECT}/${PROJECT}-$(shell uname -m)-${VERSION}.tar.gz"
released: clean binary chart image patch
echo ./releases/${PROJECT}-${VERSION}
binary:
mkdir -p ./releases/${PROJECT}-${VERSION}/binaries
curl -L "https://github.com/kubevela/kubevela/releases/download/v1.4.8/kubectl-vela-v1.4.8-linux-`case $$(uname -m) in x86_64|amd64) echo amd64;;armv8*|aarch64*|arm64) echo arm64;;armv*) echo armv7;;esac`.tar.gz" | tar zxf - -C ./releases/${PROJECT}-${VERSION}/binaries
define override_content
image:
pullPolicy: IfNotPresent
persistence:
storageClass: "rook-ceph-block"
endef
export override_content
chart:
mkdir -p ./releases/${PROJECT}-${VERSION}/charts
helm repo add kubevela https://charts.kubevela.net/core --force-update
helm repo update kubevela
helm pull kubevela/vela-core --version ${CHART} --destination ./releases/${PROJECT}-${VERSION}/charts --untar
rm -fr ./releases/${PROJECT}-${VERSION}/charts/vela-core/templates/tests
echo "$$override_content" > ./releases/${PROJECT}-${VERSION}/charts/override.yaml
define patch_content
#---------------------------------------------------------------
# Author: zxl
# E-mail: [email protected]
# Create: $(shell date "+%Y-%m-%d %H:%M:%S")
# Describe: Todo
#---------------------------------------------------------------
set -e
helm upgrade --install --create-namespace -n vela-system kubevela ./charts/vela-core -f ./charts/override.yaml
endef
export patch_content
patch:
echo "$$patch_content" > ./releases/${PROJECT}-${VERSION}/patch.sh
image: image-exporter
@helm template ./releases/${PROJECT}-${VERSION}/charts/vela-core/ | grep 'image:'| grep 'oamdev' | sed 's/^.*image: //g' | sed "s/^\([\"']\)\(.*\)\1\$$/\2/g" | uniq > ./releases/${PROJECT}-${VERSION}/images.txt
@mkdir -p ./releases/${PROJECT}-${VERSION}/images
@$(IMAGE_EXPORTER) -o ./releases/${PROJECT}-${VERSION}/images/${PROJECT}-${VERSION}.tar -f ./releases/${PROJECT}-${VERSION}/images.txt
@gzip ./releases/${PROJECT}-${VERSION}/images/${PROJECT}-${VERSION}.tar
# @grep 'repository: ' ./releases/${PROJECT}-${VERSION}/charts/vela-core/values.yaml | sed 's/^.*repository: //g' | sed "s/^\([\"']\)\(.*\)\1\$$/\2/g" | uniq > ./releases/${PROJECT}-${VERSION}/images.txt
# @mkdir -p ./releases/${PROJECT}-${VERSION}/images
# @$(IMAGE_EXPORTER) -o ./releases/${PROJECT}-${VERSION}/images/${PROJECT}-${VERSION}.tar -f ./releases/${PROJECT}-${VERSION}/images.txt
# @gzip ./releases/${PROJECT}-${VERSION}/images/${PROJECT}-${VERSION}.tar
image-exporter:
@mkdir -p ./bin
@curl --header "PRIVATE-TOKEN: ${GIT_ACCESS_TOKEN}" "https://git.xxx.com/api/v4/projects/662/repository/files/bin%2Fpuller.sh?ref=master" | sed -r 's/^.*"content":"([^"]*)".*$$/\1/' | base64 -d > $(IMAGE_PULLER)
@chmod +x $(IMAGE_PULLER)
@curl --header "PRIVATE-TOKEN: ${GIT_ACCESS_TOKEN}" "https://git.xxx.com/api/v4/projects/662/repository/files/bin%2Fexporter.sh?ref=master" | sed -r 's/^.*"content":"([^"]*)".*$$/\1/' | base64 -d > $(IMAGE_EXPORTER)
@chmod +x $(IMAGE_EXPORTER)
clean:
rm -rvf ./releases/${PROJECT}-${VERSION}
Makefile脚本中使用到的两个shell脚本完整内容如下--
exporter.sh
导出镜像到文件,如果镜像不存在则首先拉取镜像
set -e
POSITIONAL=()
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
-f|--file)
file="$2"
shift
shift
;;
-i|--images)
images="$2"
shift
shift
;;
-o|--output)
output="$2"
shift
shift
;;
-u|--user)
user="$2"
shift
shift
;;
-h|--help)
echo "Usage: ./exporter.sh [flags [options]]..."
echo
echo "Available Flags:"
echo " -f, --file: image list file"
echo " -i, --images: image list string, separated by comma"
echo " -o, --output: output file name"
echo " -u, --user: user[:password] Registry user and password, only valid for ctr"
echo " -h, --help: print this help message"
echo
exit 0
;;
*)
POSITIONAL+=("$1")
shift
;;
esac
done
set -- "${POSITIONAL[@]}"
export IFS=$'\n\t, '
if [[ "${user}" != "" ]]; then
# pull with user
if [[ "${file}" != "" ]] && [ -f "${file}" ]; then
files=$(cat "$file")
for image in $files; do
"$(dirname "$0")"/puller.sh -i "$image" -u "${user}"
done
fi
if [[ "${images}" != "" ]]; then
for image in $images; do
"$(dirname "$0")"/puller.sh -i "$image" -u "${user}"
done
fi
else
# pull without user
if [[ "${file}" != "" ]] && [ -f "${file}" ]; then
files=$(cat "$file")
for image in $files; do
"$(dirname "$0")"/puller.sh -i "$image"
done
fi
if [[ "${images}" != "" ]]; then
for image in $images; do
"$(dirname "$0")"/puller.sh -i "$image"
done
fi
fi
if which docker &> /dev/null; then
echo "export images via docker"
echo docker save -o "$output" $(echo "$files" "$images" | sed 's/@[^,]*//g' | sed 's/,/ /g') | bash
elif which ctr &> /dev/null; then
echo "export images via ctr"
echo ctr images export "$output" $(echo "$files" "$images" | sed 's/@[^,]*//g' | sed 's/,/ /g') | bash
fi
puller.sh
拉取镜像,会自动判断是否走代理
set -e
POSITIONAL=()
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
-i|--image)
image="$2"
shift
shift
;;
-u|--user)
user="$2"
shift
shift
;;
-h|--help)
echo "Usage: ./puller.sh [flags [options]]..."
echo
echo "Available Flags:"
echo " -i, --image: fetch and prepare an image for use in containerd"
echo " -u, --user: user[:password] Registry user and password"
echo " -h, --help: print this help message"
echo
exit 0
;;
*)
POSITIONAL+=("$1")
shift
;;
esac
done
set -- "${POSITIONAL[@]}"
if [[ "$image" == "" ]]; then
echo "image is required"
echo "Use \"-h|--help\" for more information about this command."
exit 1
fi
function image() {
for image in "[email protected]"
do
if echo "$image" | grep -q '/'; then
if echo "${image%%/*}" | grep -q '\.'; then
echo "$image"
else
echo "docker.io/$image"
fi
else
echo "docker.io/library/$image"
fi
done
}
IMAGE=$(image "$image" | sed 's/"//g')
if which docker &> /dev/null; then
echo "pull image via docker"
if [[ "$IMAGE" =~ ^docker\.io\/.* ]] || [[ "$IMAGE" =~ ^harbor\.dameng\.io\/.* ]]; then
docker pull "$IMAGE"
else
repository=$(echo $IMAGE | sed 's/[^\/]*\/\(.*\)/\1/g')
docker pull "$repository"
docker tag "$repository" "$IMAGE"
docker rmi "$repository"
fi
exit 0
fi
if which ctr &> /dev/null; then
echo "pull image via ctr"
if [ -v user ]; then
ctr image pull --hosts-dir /etc/containerd/certs.d -u "$user" "$IMAGE" --skip-verify
else
ctr image pull --hosts-dir /etc/containerd/certs.d "$IMAGE" --skip-verify
fi
exit 0
fi
边栏推荐
- LNMP environment - deploy WordPress
- Servlet中文乱码setContentType设置无效
- New attributes of ES6 array
- How to modify the decoding clock [chapter]
- Database foundation
- 牛客题目——用两个栈实现队列、包含min函数的栈、有效括号序列
- 这种精度高,消耗资源少的大模型稀疏训练方法被阿里云科学家找到了!已被收录到IJCAI
- 大厂们终于无法忍受“加一秒”了,微软谷歌Meta等公司提议废除闰秒
- SAP UI5 FileUploader 使用的隐藏 iframe 和 form 元素的设计明细
- Leader: who uses redis overdue monitoring to close orders and get out of here!
猜你喜欢
随机推荐
Flex flex flex box layout 2
New attributes of ES6 array
技术实践干货 | 从工作流到工作流
Storage of data in C language
node包依赖下载管理
Understand the basic properties of BOM and DOM
Basic use and optimization of uitableview
Gartner authority predicts eight development trends of network security in the next four years
Complete steps of JDBC program implementation
Built in object (bottom)
高精度定时器
Share a scheme of "redis" to realize "chat round system" that can't be found on the Internet
C语言之程序环境和预处理
C语言之枚举和联合体
C语言之数据的储存
关于 SAP UI5 应用 ui5.yaml 里的 paths 映射问题
Passive income: return to the original and safe two ways to earn
UML图介绍
C语言之字符函数和字符串函数及内存函数
合工大苍穹战队视觉组培训Day8——视觉,目标识别









