Skip to content

pod-disruption-budget resource

Source: internal/api/policy/v1/pod_disruption_budget_rsrc.go:22

Example usage:

imports: {
  kubernetes-policy-v1: 'github.com/cloudboss/unobin-library-kubernetes//api/policy/v1'
}

resources: {
  example: kubernetes-policy-v1.pod-disruption-budget {
    # Set input fields here.
  }
}

Inputs

metadata

object
object({
  name: optional(string)
  generate-name: optional(string)
  namespace: optional(string)
  annotations: optional(map(string))
  labels: optional(map(string))
})

required

spec

object
object({
  min-available: optional(string)
  max-unavailable: optional(string)
  selector: object({
    match-labels: optional(map(string))
    match-expressions: optional(
      list(
        object({
          key: optional(string)
          operator: optional(string)
          values: optional(list(string))
        })
      )
    )
  })
})

required

ignore-annotations

optional(list(string))

ignore-labels

optional(list(string))

Input Constraints

Metadata rules

Exactly one of metadata.name or metadata.generate-name.

metadata.name must not be empty.

Rule logic
When
input.metadata.name != null
Require
@core.length(input.metadata.name) >= 1

metadata.generate-name must not be empty.

Rule logic
When
input.metadata.generate-name != null
Require
@core.length(input.metadata.generate-name) >= 1

invalid metadata.name.

Rule logic
Require
@core.is-match(input.metadata.name, '^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$')
&& @core.length(input.metadata.name ?? '') <= 253

invalid metadata.generate-name.

Rule logic
Require
@core.is-match(input.metadata.generate-name, '^([a-z0-9]([-a-z0-9]{0,61}[a-z0-9])?|([a-z0-9][-a-z0-9]{0,61})?[\\x00-\\x7f]-)$')

invalid metadata.labels key.

Rule logic
For each
input.metadata.labels ?? {}
Require
@core.is-match(@each.key, '^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?[A-Za-z0-9]([-_.A-Za-z0-9]{0,61}[A-Za-z0-9])?$')
&& @core.is-match(@each.key, '^([^/]{1,253}/)?[^/]{1,63}$')

invalid metadata.annotations key.

Rule logic
For each
input.metadata.annotations ?? {}
Require
@core.is-match(@each.key, '^([A-Za-z0-9İK]([-A-Za-z0-9İK]*[A-Za-z0-9İK])?(\\.[A-Za-z0-9İK]([-A-Za-z0-9İK]*[A-Za-z0-9İK])?)*/)?[A-Za-z0-9İK]([-_.A-Za-z0-9İK]{0,61}[A-Za-z0-9İK])?$')
&& @core.is-match(@each.key, '^([^/]{1,253}/)?[^/]{1,63}$')

invalid metadata.labels value.

Rule logic
For each
input.metadata.labels ?? {}
Require
@core.is-match(@each.value, '^([A-Za-z0-9]([-_.A-Za-z0-9]{0,61}[A-Za-z0-9])?)?$')

Spec rules

invalid spec.min-available.

Rule logic
Require
@core.is-match(input.spec.min-available, '^(([+-]?0*([0-9]{1,9}|1[0-9]{9}|20[0-9]{8}|21[0-3][0-9]{7}|214[0-6][0-9]{6}|2147[0-3][0-9]{5}|21474[0-7][0-9]{4}|214748[0-2][0-9]{3}|2147483[0-5][0-9]{2}|21474836[0-3][0-9]|214748364[0-7])|-0*2147483648)|[+]?0*([0-9]{1,2}|100)%|-0+%|)$')

invalid spec.max-unavailable.

Rule logic
Require
@core.is-match(input.spec.max-unavailable, '^(([+-]?0*([0-9]{1,9}|1[0-9]{9}|20[0-9]{8}|21[0-3][0-9]{7}|214[0-6][0-9]{6}|2147[0-3][0-9]{5}|21474[0-7][0-9]{4}|214748[0-2][0-9]{3}|2147483[0-5][0-9]{2}|21474836[0-3][0-9]|214748364[0-7])|-0*2147483648)|[+]?0*([0-9]{1,2}|100)%|-0+%|)$')

Ignore annotations rules

If set, @each.value must be a valid Go regular expression.

Rule logic
For each
input.ignore-annotations ?? []
Require
@core.is-format(@each.value, 'regex')

Ignore labels rules

If set, @each.value must be a valid Go regular expression.

Rule logic
For each
input.ignore-labels ?? []
Require
@core.is-format(@each.value, 'regex')

Outputs

server

string

api-version

string

kind

string

name

string

namespace

string

uid

string

metadata

object
object({
  name: string
  generate-name: string
  namespace: string
  annotations: map(string)
  labels: map(string)
})

spec

object
object({
  min-available: string
  max-unavailable: string
  selector: object({
    match-labels: map(string)
    match-expressions: list(
      object({
        key: string
        operator: string
        values: list(string)
      })
    )
  })
})