From e1e73412a58782b2175215498ba4f8d345611017 Mon Sep 17 00:00:00 2001 From: Mason Hensley Date: Thu, 23 Jul 2020 18:30:58 -0400 Subject: [PATCH 1/3] Update manifest.yaml --- manifest.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/manifest.yaml b/manifest.yaml index a18ee7af..01edbfb1 100644 --- a/manifest.yaml +++ b/manifest.yaml @@ -14,7 +14,7 @@ spec: selector: name: grumpy --- -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment metadata: name: grumpy @@ -23,6 +23,9 @@ metadata: name: grumpy spec: replicas: 1 + selector: + matchLabels: + name: grumpy template: metadata: name: grumpy From c2b60b4c13b9e40df73d257e630c526061df5b5e Mon Sep 17 00:00:00 2001 From: Oren Oichman Date: Mon, 10 Aug 2020 10:16:00 +0300 Subject: [PATCH 2/3] Update grumpy.go Hi , I made a few small changes so the code will work with v1 , more so I would suggest using regex to see part of the pod name something like : podnamingReg := regexp.MustCompile(`kuku`) if podnamingReg.MatchString(string(pod.Name)) { instead of if pod.Name == "smooth-app" { up to you --- grumpy.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/grumpy.go b/grumpy.go index 70e85a13..6eab65d7 100644 --- a/grumpy.go +++ b/grumpy.go @@ -48,10 +48,7 @@ func (gs *GrumpyServerHandler) serve(w http.ResponseWriter, r *http.Request) { glog.Error("error deserializing pod") return } - if pod.Name == "smooth-app" { - return - } - + arResponse := v1beta1.AdmissionReview{ Response: &v1beta1.AdmissionResponse{ Allowed: false, @@ -60,6 +57,16 @@ func (gs *GrumpyServerHandler) serve(w http.ResponseWriter, r *http.Request) { }, }, } + + if pod.Name == "smooth-app" { + fmt.Printf("the pod %s is up to the name standard", pod.Name) + arResponse.Response.Allowed = true + } + + arResponse.APIVersion = "admission.k8s.io/v1" + arResponse.Kind = arRequest.Kind + arResponse.Response.UID = arRequest.Request.UID + resp, err := json.Marshal(arResponse) if err != nil { glog.Errorf("Can't encode response: %v", err) From fc76b7f82555574f49357fb13fa829a80d816195 Mon Sep 17 00:00:00 2001 From: Oren Oichman Date: Mon, 10 Aug 2020 10:18:48 +0300 Subject: [PATCH 3/3] Update manifest.yaml --- manifest.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.yaml b/manifest.yaml index 01edbfb1..3f9ee8c3 100644 --- a/manifest.yaml +++ b/manifest.yaml @@ -63,7 +63,7 @@ spec: - name: logs emptyDir: {} --- -apiVersion: admissionregistration.k8s.io/v1beta1 +apiVersion: admissionregistration.k8s.io/v1 kind: ValidatingWebhookConfiguration metadata: name: grumpy