apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: kuryrnetworkpolicies.openstack.org
spec:
  group: openstack.org
  scope: Namespaced
  names:
    plural: kuryrnetworkpolicies
    singular: kuryrnetworkpolicy
    kind: KuryrNetworkPolicy
    shortNames:
    - knp
  versions:
  - name: v1
    served: true
    storage: true
    additionalPrinterColumns:
      - name: SG-ID
        type: string
        description: The ID of the SG associated to the policy
        jsonPath: .status.securityGroupId
      - name: Age
        type: date
        jsonPath: .metadata.creationTimestamp
    schema:
      openAPIV3Schema:
        type: object
        required:
        - status
        - spec
        properties:
          spec:
            type: object
            required:
            - egressSgRules
            - ingressSgRules
            - podSelector
            - policyTypes
            properties:
              egressSgRules:
                type: array
                items:
                  type: object
                  required:
                  - sgRule
                  properties:
                    affectedPods:
                      type: array
                      items:
                        type: object
                        properties:
                          podIP:
                            type: string
                          podNamespace:
                            type: string
                        required:
                        - podIP
                        - podNamespace
                    namespace:
                      type: string
                    sgRule:
                      type: object
                      properties:
                        description:
                          type: string
                        direction:
                          type: string
                        ethertype:
                          type: string
                        port_range_max:
                          type: integer
                        port_range_min:
                          type: integer
                        protocol:
                          type: string
                        remote_ip_prefix:
                          type: string
              ingressSgRules:
                type: array
                items:
                  type: object
                  required:
                  - sgRule
                  properties:
                    affectedPods:
                      type: array
                      items:
                        type: object
                        properties:
                          podIP:
                            type: string
                          podNamespace:
                            type: string
                        required:
                        - podIP
                        - podNamespace
                    namespace:
                      type: string
                    sgRule:
                      type: object
                      properties:
                        description:
                          type: string
                        direction:
                          type: string
                        ethertype:
                          type: string
                        port_range_max:
                          type: integer
                        port_range_min:
                          type: integer
                        protocol:
                          type: string
                        remote_ip_prefix:
                          type: string
              podSelector:
                x-kubernetes-preserve-unknown-fields: true
                type: object
              policyTypes:
                type: array
                items:
                  type: string
          status:
            type: object
            required:
            - securityGroupRules
            properties:
              securityGroupId:
                type: string
              securityGroupRules:
                type: array
                items:
                  type: object
                  required:
                  - id
                  properties:
                    id:
                      type: string
                    description:
                      type: string
                    direction:
                      type: string
                    ethertype:
                      type: string
                    port_range_max:
                      type: integer
                    port_range_min:
                      type: integer
                    protocol:
                      type: string
                    remote_ip_prefix:
                      type: string
                    security_group_id:
                      type: string
              podSelector:
                x-kubernetes-preserve-unknown-fields: true
                type: object
