File tree 1 file changed +14
-0
lines changed
1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change 5
5
package webhook
6
6
7
7
import (
8
+ "context"
9
+
8
10
"github.com/elastic/cloud-on-k8s/operators/pkg/apis/elasticsearch/v1alpha1"
9
11
"github.com/elastic/cloud-on-k8s/operators/pkg/webhook/elasticsearch"
10
12
"github.com/elastic/cloud-on-k8s/operators/pkg/webhook/license"
11
13
admission "k8s.io/api/admissionregistration/v1beta1"
12
14
corev1 "k8s.io/api/core/v1"
15
+ v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
13
16
"sigs.k8s.io/controller-runtime/pkg/manager"
14
17
"sigs.k8s.io/controller-runtime/pkg/webhook"
15
18
@@ -48,6 +51,17 @@ func RegisterValidations(mgr manager.Manager, params Parameters) error {
48
51
Build ()
49
52
50
53
disabled := ! params .AutoInstall
54
+ if params .AutoInstall {
55
+ // nasty side effect in register function
56
+ webhookSvc := corev1.Service {
57
+ ObjectMeta : v1.ObjectMeta {
58
+ Name : params .Bootstrap .Service .Name ,
59
+ Namespace : params .Bootstrap .Service .Namespace ,
60
+ },
61
+ }
62
+ // best effort deletion attempt to handle incompatible services from previous versions
63
+ _ = mgr .GetClient ().Delete (context .Background (), & webhookSvc )
64
+ }
51
65
svr , err := webhook .NewServer (admissionServerName , mgr , webhook.ServerOptions {
52
66
Port : serverPort ,
53
67
CertDir : "/tmp/cert" ,
You can’t perform that action at this time.
0 commit comments