1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-31 03:45:17 +00:00

bug fix : Kyverno policies block uninstall of Kyverno (#2659)

* bug fix uninstall kyverno  issue

* rename the methods
This commit is contained in:
Vyankatesh Kudtarkar 2021-11-03 12:14:32 +05:30 committed by GitHub
parent 8f6028701e
commit 6eb7cf57f7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 7 deletions

View file

@ -57,6 +57,15 @@ const (
// NamespaceAPIVersion define the default namespace resource apiVersion
NamespaceAPIVersion = "v1"
// ClusterRoleAPIVersion define the default clusterrole resource apiVersion
ClusterRoleAPIVersion = "rbac.authorization.k8s.io/v1"
// ClusterRoleKind define the default clusterrole resource kind
ClusterRoleKind = "ClusterRole"
// ClusterRoleName define the default name of clusterrole
ClusterRoleName = "kyverno:webhook"
)
var (

View file

@ -60,22 +60,22 @@ func extractCA(config *rest.Config) (result []byte) {
func (wrc *Register) constructOwner() v1.OwnerReference {
logger := wrc.log
kubeNamespace, err := wrc.GetKubePolicyNamespace()
kubeClusterRole, err := wrc.GetKubePolicyClusterRole()
if err != nil {
logger.Error(err, "failed to construct OwnerReference")
return v1.OwnerReference{}
}
return v1.OwnerReference{
APIVersion: config.NamespaceAPIVersion,
Kind: config.NamespaceKind,
Name: config.KyvernoNamespace,
UID: kubeNamespace.GetUID(),
APIVersion: config.ClusterRoleAPIVersion,
Kind: config.ClusterRoleKind,
Name: config.ClusterRoleName,
UID: kubeClusterRole.GetUID(),
}
}
func (wrc *Register) GetKubePolicyNamespace() (*unstructured.Unstructured, error) {
kubeNamespace, err := wrc.client.GetResource(config.NamespaceAPIVersion, config.NamespaceKind, "", config.KyvernoNamespace)
func (wrc *Register) GetKubePolicyClusterRole() (*unstructured.Unstructured, error) {
kubeNamespace, err := wrc.client.GetResource(config.ClusterRoleAPIVersion, config.ClusterRoleKind, "", config.ClusterRoleName)
if err != nil {
return nil, err
}