---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: servers.polixy.linkerd.io
  labels:
    polixy.linkerd.io/crd: srv
spec:
  group: polixy.linkerd.io
  names:
    kind: Server
    plural: servers
    singular: server
    shortNames: [srv]
  scope: Namespaced
  versions:
    - name: v1alpha1
      served: true
      storage: true

      additionalPrinterColumns:
        - jsonPath: .spec.port
          name: podSelector
          type: string
        - jsonPath: .spec.podSelector
          name: port
          type: string

      schema:
        openAPIV3Schema:
          type: object
          required: [spec]
          properties:
            spec:
              type: object
              required:
                - podSelector
                - port
              properties:

                podSelector:
                  type: object
                  description: >-
                    Selects pods in the same namespace.
                  properties:
                    matchLabels:
                      type: object
                      x-kubernetes-preserve-unknown-fields: true
                    matchExpressions:
                      type: array
                      items:
                        type: object
                        required: [key, operator, values]
                        properties:
                          key:
                            type: string
                          operator:
                            type: string
                            enum: [In, NotIn]
                          values:
                            type: array
                            items:
                              type: string

                port:
                  description: >-
                    A port name or number. Must exist in a pod spec.
                  x-kubernetes-int-or-string: true

                proxyProtocol:
                  description: >-
                    Configures protocol discovery for inbound connections.

                    Supersedes the `config.linkerd.io/opaque-ports` annotation.
                  type: string
                  default: unknown
                  enum:
                    - unknown
                    - HTTP/1
                    - HTTP/2
                    - gRPC
                    - opaque
                    - TLS
