Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mutating_webhook_configuration and validation_webhook_configuration error with no rules #1643

Closed
onwsk8r opened this issue Mar 15, 2022 · 2 comments · Fixed by #1628
Closed
Labels

Comments

@onwsk8r
Copy link

onwsk8r commented Mar 15, 2022

Terraform Version, Provider Version and Kubernetes Version

❯ terraform -v
Terraform v1.1.7
on linux_amd64
+ provider registry.terraform.io/hashicorp/kubernetes v2.8.0
Kubernetes Version: 1.21.6

Affected Resource(s)

  • kubernetes_mutating_webhook_configuration
  • kubernetes_validating_webhook_configuration

Terraform Configuration Files

resource "kubernetes_mutating_webhook_configuration" "example" {
  metadata {
    name = "foo"
  }

  webhook {
    name = "foo"

    client_config {
      service {
        namespace = "default"
        name      = "foo-webhook"
      }
    }

    failure_policy            = "Fail"
    side_effects              = "None"
    timeout_seconds           = 2
    admission_review_versions = ["v1beta1"]
  }
}

resource "kubernetes_validating_webhook_configuration" "example" {
  metadata {
    name = "foo"
  }

  webhook {
    name = "foo"

    client_config {
      service {
        namespace = "default"
        name      = "foo-webhook"
      }
    }

    failure_policy            = "Fail"
    side_effects              = "None"
    timeout_seconds           = 2
    admission_review_versions = ["v1beta1"]
  }
}

Debug Output

tl;dr

2022-03-15T05:48:58.906-0500 [TRACE] vertex "kubernetes_validating_webhook_configuration.example": starting visit (*terraform.NodeValidatableResource)
2022-03-15T05:48:58.906-0500 [TRACE] vertex "kubernetes_mutating_webhook_configuration.example": starting visit (*terraform.NodeValidatableResource)
2022-03-15T05:48:58.906-0500 [ERROR] vertex "kubernetes_validating_webhook_configuration.example" error: Insufficient rule blocks
2022-03-15T05:48:58.906-0500 [TRACE] vertex "kubernetes_validating_webhook_configuration.example": visit complete, with errors
2022-03-15T05:48:58.906-0500 [ERROR] vertex "kubernetes_mutating_webhook_configuration.example" error: Insufficient rule blocks
2022-03-15T05:48:58.906-0500 [TRACE] vertex "kubernetes_mutating_webhook_configuration.example": visit complete, with errors

See the whole thing here.

Steps to Reproduce

  1. Put the sample HCl code above into a file
  2. Run terraform init
  3. Run terraform apply
  4. $Profit (or not)

Expected Behavior

The Terraform provider is expected to demonstrate similar behavior to the Kubernetes API. HCl code and terraform apply should produce the same result as YAML and kubectl apply.

Actual Behavior

Terraform indicates that At least 1 "rule" blocks are required (is that proper Engrish?), which is not the case when running kubectl apply with the YAML version of the code. Moreover, the documentation lists rule blocks as optional.

Important Factoids

The resource documentation shows rule as being optional, which is how the Kubernetes API works as well. But wait! The Dynamic Admission Controllers documentation says that [e]ach webhook must specify a list of rules! Case closed, you say - the documentation supports the requirement. Indeed it does not, because an empty list is a valid list, and the API docs for each resource do not specify a minimum length for the list!

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment
@onwsk8r onwsk8r added the bug label Mar 15, 2022
@github-actions github-actions bot removed the bug label Mar 15, 2022
@arybolovlev
Copy link
Contributor

Hi @onwsk8r,

Thank you for reporting this issue. It seems to be a duplicate of this one. There is PR that addresses this issue. Please keep an eye on our release notes.

Thank you!

@github-actions
Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
3 participants