apiVersion: "apiextensions.k8s.io/v1"
kind: "CustomResourceDefinition"
metadata:
  name: "ktbans.k8s.sers.dev"
spec:
  group: "k8s.sers.dev"
  scope: "Namespaced"
  names:
    plural: "ktbans"
    singular: "ktban"
    kind: "Ktban"
    shortNames:
      - "kb"
  versions:
    - name: "v1alpha1"
      served: true
      storage: true
      schema:
        openAPIV3Schema:
          type: "object"
          properties:
            spec:
              required: [ "ip", "portFrom", "portTo", "protocol", "direction" ] #add interfaceGroup?
              type: "object"
              properties:
                ip:
                  type: "string"
                portFrom:
                  type: "integer"
                portTo:
                  type: "integer"
                #portRange:
                #  type: "string"
                #  pattern: "^([0-9]){0,5}|([:,][0-9]{0,5})+"
                #interfaceGroup:
                #  type: "string"
                #  maximum: 20
                protocol:
                  type: "string"
                direction:
                  type: "string"
                  pattern: "^(in|out){1}$"
      additionalPrinterColumns:
        - name: "IP"
          type: "string"
          description: ""
          jsonPath: ".spec.ip"
        - name: "Pfrom"
          type: "integer"
          description: "Specifies starting range of ports which will be blocked"
          jsonPath: ".spec.portFrom"
        - name: "PTo"
          type: "integer"
          description: "Specifies ending range of ports which will be blocked"
          jsonPath: ".spec.portTo"
        #- name: "InterfaceGroup"
        #  type: "string"
        #  description: "Specifies which interface group (as interface abstraction) will get the ban"
        #  jsonPath: ".spec.interfaceGroup"
        - name: "Protocol"
          type: "integer"
          description: "Which (transport-) protocol will be blocked"
          jsonPath: ".spec.protocol"
        - name: "Direction"
          type: "string"
          description: "Specifies in which direction connections will be blocked (in|out)"
          jsonPath: ".spec.direction"
