当前位置:网站首页>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
边栏推荐
- 渐变环形进度条
- 国产新冠口服药为什么是治艾滋病的药
- 在CRA创建的项目中使用@并让其识别@路径并给出路径提示
- 三表联查2
- High cost, difficult to implement, slow to take effect, what about open source security?
- Understand the staticarea initialization logic of SAP ui5 application through the initialization of fileuploader
- 大厂们终于无法忍受“加一秒”了,微软谷歌Meta等公司提议废除闰秒
- 如何通过C#/VB.NET从PDF中提取表格
- Smart fish tank design based on stm32
- 交换机和路由器技术-03-交换机基本配置
猜你喜欢

下棋机器人折断7岁男孩手指,网友:违反了机器人第一定律

Xcode 发布测试包TestFlight

Node package depends on download management

Xcode releases test package testflight

Rare discounts on Apple's official website, with a discount of 600 yuan for all iphone13 series; Chess robot injured the fingers of chess playing children; Domestic go language lovers launch a new pro

Windows and network foundation-15-local security policy

WebView basic use

Switch and router technology-03-basic configuration of switch

记一次 .NET 某智慧物流 WCS系统 CPU 爆高分析

Explain the pile of binary trees in detail
随机推荐
关于 SAP UI5 应用 ui5.yaml 里的 paths 映射问题
Purchase in Appstore
DDD(领域驱动设计)分层架构
CUE语言基础入门:CUE是一门为配置而生的语言
Kubernetes Chapter 8: deploy NFS system with kubernetes to complete database persistence (kubernetes work practice class)
阿里巴巴鹰眼系统简介
每条你收藏的资讯背后,都离不开TA
The 7-year-old boy broke his finger by AI robot just because he played chess too fast?
KMP template - string matching
(2) CBAM integrated two stream project construction - data preparation
Functions in JS
2021-06-18 automatic assembly error in SSM project
7 岁男孩被 AI 机器人折断手指,仅因下棋太快?
With the arrival of large displacement hard core products, can the tank brand break through the ceiling of its own brand?
两表联查1
Switch and router technology-02-working principle of Ethernet switch
科目三: 直线行驶
Shell编程规范与变量
通过 FileUploader 的初始化,了解 SAP UI5 应用的 StaticArea 初始化逻辑
风口之下,隐形正畸还能走多远?