Commit 3f1a6a63 authored by rawmind0's avatar rawmind0
Browse files

Updated nginx ingress addon to remove admission batch jobs if they exist

parent 35641a24
......@@ -53,11 +53,15 @@ const (
Nodelocal = "nodelocal"
NginxIngressAddonAppName = "ingress-nginx"
NginxIngressAddonAppNamespace = "ingress-nginx"
NginxIngressAddonDefaultBackendName = "default-http-backend"
NginxIngressAddonDefaultBackendNamespace = "ingress-nginx"
)
var DNSProviders = []string{KubeDNSProvider, CoreDNSProvider}
var (
DNSProviders = []string{KubeDNSProvider, CoreDNSProvider}
NginxIngressAddonJobNames = []string{"ingress-nginx-admission-create", "ingress-nginx-admission-patch"}
)
type ingressOptions struct {
RBACConfig string
......@@ -613,6 +617,20 @@ func (c *Cluster) deployIngress(ctx context.Context, data map[string]interface{}
if version < "0.16.0" {
ingressConfig.AlpineImage = c.SystemImages.Alpine
}
// since nginx ingress controller 0.40.0, admission batch jobs are deployed.
// Before deployment of the new ingress controller based on the update strategy, remove admission batch jobs if they exist.
if version > "0.40.0" {
log.Infof(ctx, "[ingress] removing admission batch jobs if they exist")
kubeClient, err := k8s.NewClient(c.LocalKubeConfigPath, c.K8sWrapTransport)
if err != nil {
return err
}
for _, jobName := range NginxIngressAddonJobNames {
if err = k8s.DeleteK8sJobIfExists(kubeClient, jobName, NginxIngressAddonAppNamespace); err != nil {
return err
}
}
}
}
tmplt, err := templates.GetVersionedTemplates(kdm.NginxIngress, data, c.Version)
if err != nil {
......
......@@ -71,6 +71,13 @@ func DeleteK8sSystemJob(jobYaml string, k8sClient *kubernetes.Clientset, timeout
return nil
}
func DeleteK8sJobIfExists(k8sClient *kubernetes.Clientset, name, namespace string) error {
if err := deleteK8sJob(k8sClient, name, namespace); err != nil && !apierrors.IsNotFound(err) {
return err
}
return nil
}
func ensureJobCompleted(k8sClient *kubernetes.Clientset, j interface{}) error {
job := j.(v1.Job)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment