当前位置:网站首页>Helm install kubevela complete makefile script content
Helm install kubevela complete makefile script content
2022-07-27 17:36:00 【Learn programming notes】
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 Two used in the script shell The complete content of the script is as follows --
exporter.sh
Export image to file , If the image does not exist, first pull the image
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
Pull the mirror image , It will automatically determine whether to take the agent
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
边栏推荐
- Understanding service governance in distributed development
- 详解二叉树之堆
- Hegong sky team vision training Day7 - vision, Jetson naon and d435i
- 2021-06-18 SSM项目中自动装配错误
- 国产新冠口服药为什么是治艾滋病的药
- MySQL: 函数
- Motion capture system for end positioning control of flexible manipulator
- $attrs与$listeners组件传值
- Gree "not cool": the giant lawsuit ended and was reduced by large dealers. Is it too late for the new battlefield of air conditioning?
- MySQL: Functions
猜你喜欢

今日睡眠质量记录82分

选择体育场馆的LED显示屏时应该注重哪些方面

KMP template - string matching

.net core with microservices - what is a microservice

Big manufacturers finally can't stand "adding one second", and companies such as Microsoft, Google meta propose to abolish leap seconds

三表联查3

With the arrival of large displacement hard core products, can the tank brand break through the ceiling of its own brand?

Getting started with unity

一个端到端的基于 form 表单的文件上传程序,包含客户端和服务器端

苹果官网罕见打折,iPhone13全系优惠600元;国际象棋机器人弄伤对弈儿童手指;国内Go语言爱好者发起新编程语言|极客头条...
随机推荐
Chen Yili of ICT Institute: reducing cost and increasing efficiency is the greatest value of cloud native applications
Gods at dusk, "cat trembles" bid farewell to the big V Era
Windows与网络基础-15-本地安全策略
Two table joint query 1
Xcode 发布测试包TestFlight
Kubernetes第八篇:使用kubernetes部署NFS系统完成数据库持久化(Kubernetes工作实践类)
.net core with microservices - what is a microservice
SAP UI5 FileUploader 的隐藏 iframe 设计明细
Hegong sky team vision training Day7 - vision, Jetson naon and d435i
Understand the staticarea initialization logic of SAP ui5 application through the initialization of fileuploader
第7天总结&作业
About paths mapping in SAP ui5 application ui5.yaml
三表联查2
可口可乐的首要挑战,不是元气森林
MySQL : 函数
基于STM32的智能鱼缸设计
Big manufacturers finally can't stand "adding one second", and companies such as Microsoft, Google meta propose to abolish leap seconds
High cost, difficult to implement, slow to take effect, what about open source security?
Hidden iframe design details of SAP ui5 fileuploader
Flex flex flex box layout