1
0
mirror of https://github.com/rancher/rke.git synced 2025-09-15 22:49:13 +00:00

Remove ingress controller when disabled

This commit is contained in:
moelsayed
2018-07-13 23:48:15 +02:00
committed by Alena Prokharchyk
parent af77619859
commit 241f7857d6
4 changed files with 119 additions and 19 deletions

View File

@@ -1,12 +1,40 @@
package addons
import "github.com/rancher/rke/templates"
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.JobDeployerTemplate, jobConfig)
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
}