1 Star 0 Fork 0

golang/rke

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
addons.go 1.17 KB
一键复制 编辑 原始数据 按行查看 历史
moelsayed 提交于 2018-07-13 23:48 . Remove ingress controller when disabled
package addons
import (
"fmt"
"strconv"
"github.com/rancher/rke/k8s"
"github.com/rancher/rke/templates"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
func GetAddonsExecuteJob(addonName, nodeName, image string) (string, error) {
return getAddonJob(addonName, nodeName, image, false)
}
func GetAddonsDeleteJob(addonName, nodeName, image string) (string, error) {
return getAddonJob(addonName, nodeName, image, true)
}
func getAddonJob(addonName, nodeName, image string, isDelete bool) (string, error) {
jobConfig := map[string]string{
"AddonName": addonName,
"NodeName": nodeName,
"Image": image,
"DeleteJob": strconv.FormatBool(isDelete),
}
return templates.CompileTemplateFromMap(templates.AddonJobTemplate, jobConfig)
}
func AddonJobExists(addonJobName, kubeConfigPath string, k8sWrapTransport k8s.WrapTransport) (bool, error) {
k8sClient, err := k8s.NewClient(kubeConfigPath, k8sWrapTransport)
if err != nil {
return false, err
}
addonJobStatus, err := k8s.GetK8sJobStatus(k8sClient, addonJobName, metav1.NamespaceSystem)
if err != nil {
return false, fmt.Errorf("Failed to get job [%s] status: %v", addonJobName, err)
}
return addonJobStatus.Created, nil
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/gober/rke.git
git@gitee.com:gober/rke.git
gober
rke
rke
v0.2.4-rc1

搜索帮助