前提条件
1.已经部署了harbor,且harbor安装了对应的插件(helm-chart对应的插件)
2.服务器安装了推送helm package的命令
3.安装了helm组件
脚本组件安装方法如下(helm组件安装)
function installHelm(){
echo $1
downloadFile helm-v3.6.0-linux-amd64.tar.gz helm
if [[ $? -ne 0 ]]; then
colorEcho ${RED} "Faild to download ${DOWNLOADFILENAME}.Please download it manually from download.ihr360.com"
return 3
fi
tar -zxvf ${DOWNLOADPATH}/${DOWNLOADFILENAME} -C /${DOWNLOADPATH}
mv ${DOWNLOADPATH}/linux-amd64/helm /usr/local/bin/helm
colorEcho ${BLUE} "download and install helm-push"
downloadFile helm-push_0.10.3_linux_amd64.tar.gz helm
if [[ $? -ne 0 ]]; then
colorEcho ${RED} "Faild to download ${DOWNLOADFILENAME}.Please download it manually from download.ihr360.com"
return 3
fi
mkdir -p /root/.local/share/helm/plugins/helm-push && cp ${DOWNLOADPATH}/${DOWNLOADFILENAME} /root/.local/share/helm/plugins/helm-push
cd /root/.local/share/helm/plugins/helm-push && tar -zxvf ${DOWNLOADFILENAME}
helm plugin list
if [[ $? -ne 0 ]]; then
colorEcho ${RED} "Faild to install ${DOWNLOADFILENAME}"
return 3
fi
helm repo add --username **** --password ******** efssc-harbor https://harbor.assistfc.com/chartrepo/helm-chart //添加远程仓库秘钥地址
return 0
}
kubed
实现k8s秘钥secret 同步到不同的命名空间(kubed):
function installSecret(){
colorEcho ${BLUE} "秘钥同步模块的安装"
helm install kubed efssc-harbor/kubed --version v0.12.0 --namespace kube-system
if [[ $? -ne 0 ]]; then
colorEcho ${RED} "install kubed for helm fails"
return 2
fi
kubectl create secret docker-registry huawei-registry-key --docker-server=******* --docker-username=****** --docker-password=******
kubectl annotate secret huawei-registry-key kubed.appscode.com/sync="" --overwrite
colorEcho ${BLUE} "秘钥同步模块完成,且已同步docker registry秘钥到所有的空间中"
cd ${INSTALL_SPACE}/helm && helm pull efssc-harbor/kubed --version=v0.12.0
return 0
}