From 55d5812404d68e5c879d2783469785d6902643ac Mon Sep 17 00:00:00 2001 From: shuting Date: Wed, 15 Jul 2020 10:39:02 -0700 Subject: [PATCH 1/3] bugfix - delete synchronized resources (#997) * Delete individual resource when policy deleted Co-authored-by: evalsocket --- pkg/generate/generate.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/pkg/generate/generate.go b/pkg/generate/generate.go index 20580dfa59..a66db2d21a 100644 --- a/pkg/generate/generate.go +++ b/pkg/generate/generate.go @@ -47,11 +47,17 @@ func (c *Controller) applyGenerate(resource unstructured.Unstructured, gr kyvern policy, err := c.pLister.Get(gr.Spec.Policy) if err != nil { if apierrors.IsNotFound(err) { - labels := resource.GetLabels() - if labels["app.kubernetes.io/synchronize"] == "enable" { - if err := c.client.DeleteResource(gr.Spec.Resource.Kind, gr.Spec.Resource.Namespace, gr.Spec.Resource.Name, false); err != nil { - logger.V(4).Info("Generated resource is deleted") - return nil, err + for _,e := range gr.Status.GeneratedResources { + resp, err := c.client.GetResource(e.Kind,e.Namespace,e.Name); + if err != nil { + logger.Error(err,"Generated resource failed to get","Resource",resp.GetName()) + } + + labels := resp.GetLabels() + if labels["app.kubernetes.io/synchronize"] == "enable" { + if err := c.client.DeleteResource(resp.GetKind(), resp.GetNamespace(), resp.GetName(), false); err != nil { + logger.Error(err,"Generated resource is not deleted","Resource",resp.GetName()) + } } } return nil, nil From f39372cb666e484a4c3eab41a9c86e399460c6a8 Mon Sep 17 00:00:00 2001 From: Shuting Zhao Date: Wed, 15 Jul 2020 13:05:54 -0700 Subject: [PATCH 2/3] tag v1.1.7 --- .travis.yml | 2 ++ charts/kyverno/Chart.yaml | 4 ++-- definitions/install.yaml | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 841ba164ba..89cb96c595 100644 --- a/.travis.yml +++ b/.travis.yml @@ -37,6 +37,8 @@ after_success: - | if [ $TRAVIS_PULL_REQUEST == 'false' ] then + git checkout -f + docker login -u $DOCKER_USER -p $DOCKER_PASSWORD || travis_terminate 1 echo "pushing Kyverno image" diff --git a/charts/kyverno/Chart.yaml b/charts/kyverno/Chart.yaml index 846dbe80ef..7263ed539d 100644 --- a/charts/kyverno/Chart.yaml +++ b/charts/kyverno/Chart.yaml @@ -1,7 +1,7 @@ apiVersion: v1 name: kyverno -version: 1.1.7-rc4 -appVersion: v1.1.7-rc4 +version: 1.1.7 +appVersion: v1.1.7 description: Kubernetes Native Policy Management keywords: - kubernetes diff --git a/definitions/install.yaml b/definitions/install.yaml index 17dd131fbd..356eefe571 100644 --- a/definitions/install.yaml +++ b/definitions/install.yaml @@ -775,7 +775,7 @@ spec: fieldPath: metadata.namespace - name: KYVERNO_SVC value: kyverno-svc - image: nirmata/kyverno:v1.1.7-rc4 + image: nirmata/kyverno:v1.1.7 imagePullPolicy: Always livenessProbe: failureThreshold: 4 @@ -807,6 +807,6 @@ spec: cpu: 100m memory: 50Mi initContainers: - - image: nirmata/kyvernopre:v1.1.7-rc4 + - image: nirmata/kyvernopre:v1.1.7 name: kyverno-pre serviceAccountName: kyverno-service-account From af5bc530818ab4d45b8a99a23e6a6d15453a5510 Mon Sep 17 00:00:00 2001 From: Yuvraj <10830562+evalsocket@users.noreply.github.com> Date: Wed, 15 Jul 2020 14:37:04 -0700 Subject: [PATCH 3/3] krew yaml fixes (#1000) --- .krew.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.krew.yaml b/.krew.yaml index 5a49128f63..02953fff5b 100644 --- a/.krew.yaml +++ b/.krew.yaml @@ -10,7 +10,7 @@ spec: matchLabels: os: linux arch: amd64 - {{addURIAndSha "https://github.com/nirmata/kyverno/releases/download/{{ .TagName }}/kyverno-cli_{{ .TagName }}_linux_x86_64.tar.gz" .TagName }} + {{addURIAndSha "https://github.com/nirmata/kyverno/releases/download/{{ .TagName }}/kyverno-cli_{{ .TagName }}_linux_x86_64.tar.gz" .TagName | indent 6 }} files: - from: kyverno to: . @@ -21,7 +21,7 @@ spec: matchLabels: os: darwin arch: amd64 - {{addURIAndSha "https://github.com/nirmata/kyverno/releases/download/{{ .TagName }}/kyverno-cli_{{ .TagName }}_darwin_x86_64.tar.gz" .TagName }} + {{addURIAndSha "https://github.com/nirmata/kyverno/releases/download/{{ .TagName }}/kyverno-cli_{{ .TagName }}_darwin_x86_64.tar.gz" .TagName | indent 6 }} files: - from: kyverno to: . @@ -32,7 +32,7 @@ spec: matchLabels: os: windows arch: amd64 - {{addURIAndSha "https://github.com/nirmata/kyverno/releases/download/{{ .TagName }}/kyverno-cli_{{ .TagName }}_windows_x86_64.zip" .TagName }} + {{addURIAndSha "https://github.com/nirmata/kyverno/releases/download/{{ .TagName }}/kyverno-cli_{{ .TagName }}_windows_x86_64.zip" .TagName | indent 6 }} files: - from: kyverno.exe to: .