# K8s Deploy Contracts
#
# Type definitions for Kubernetes deployment schemas.

{
  PortType = [| 'TCP, 'UDP |],
  StorageClassName = [| 'manual, 'nfs_client, 'rook_cephfs |],
  AccessMode = [| 'ReadWriteOnce, 'ReadOnlyMany, 'ReadWriteMany, 'ReadWriteOncePod |],
  AbbrevMode = [| 'RWO, 'ROX, 'RWX, 'RWOP |],
  ReclaimPolicy = [| 'Recycle, 'Retain, 'Delete |],
  VolumeMode = [| 'unspecified, 'Filesystem, 'Block |],
  VolumeType = [| 'volumeClaim, 'configMap, 'secret, 'empty |],
  ServiceType = [| 'ClusterIP, 'NodePort, 'LoadBalancer, 'ExternalName, 'Headless, 'None |],
  ImagePullPolicy = [| 'IfNotPresent, 'Always, 'Never |],
  AffinityOperator = [| 'In, 'NotIn, 'Exists, 'DoesNotExist |],
  AffinityType = [| 'requiredDuringSchedulingIgnoredDuringExecution, 'preferredDuringSchedulingIgnoredDuringExecution |],
  TlsMode = [| 'SIMPLE, 'PASSTHROUGH, 'MULTI, 'empty |],
  ProxyProtocol = [| 'HTTP, 'HTTPS, 'TCP |],
  MatchType = [| 'tcp, 'http, 'tls |],
  ServiceMesh = [| 'istio, 'linkerd, 'cilium |],
  IngressController = [| 'nginx, 'traefik, 'contour, 'haproxy, 'istio_gateway |],
  LegacyProxy = [| 'istio, 'linkerd, 'nginx, 'traefik, 'contour, 'haproxy |],

  K8sPort = {
    name | String,
    typ | optional | String,
    container | optional | Number,
    nodePort | optional | Number,
    target | optional | Number,
  },

  K8sKeyVal = {
    key | String,
    value | String,
  },

  K8sKeyPath = {
    key | String,
    path | String,
  },

  K8sVolumeMount = {
    name | String,
    readOnly | Bool,
    mountPath | String,
    subPath | optional | String,
  },

  K8sVolumeClaim = {
    name | String,
    storageClassName | StorageClassName,
    modes,
    abbrev_mode | optional,
    reclaimPolicy | optional | ReclaimPolicy,
    storage | optional | String,
    typ | VolumeType,
    pvMode | optional | VolumeMode,
    pvcMode | optional | VolumeMode,
    hostPath | optional | String,
  },

  K8sConfigMap = {
    name | String,
  },

  K8sSecret = {
    name | String,
    items,
  },

  K8sVolume = {
    name | String,
    typ | VolumeType,
    persistentVolumeClaim | optional,
    items | optional,
    configMap | optional,
    secret | optional,
  },

  K8sService = {
    name | String,
    typ | ServiceType,
    externalName | optional | String,
    proto | String,
    ports,
    selector | optional,
    externalIPs | optional,
  },

  K8sResources = {
    memory | String,
    cpu | String,
  },

  K8sContainers = {
    name | String,
    resources_requests | optional,
    resources_limits | optional,
    image | String,
    cmd | optional | String,
    imagePull | ImagePullPolicy,
    env | optional,
    ports | optional,
    volumeMounts | optional,
  },

  K8sBackup = {
    name | String,
    typ | String,
    mount_path | String,
  },

  K8sAffinityMatch = {
    key | String,
    operator | AffinityOperator,
    values,
  },

  K8sAffinityLabelSelector = {
    typ | AffinityType,
    labelSelector,
    topologyKey | optional | String,
    matchLabelKeys | optional,
  },

  K8sAntyAffinityLabelSelector = {
    typ | AffinityType,
    labelSelector,
    topologyKey | optional | String,
    matchLabelKeys | optional,
    weight | Number,
  },

  K8sAffinity = {
    affinity | optional,
    antiAffinity | optional,
  },

  K8sDeploySpec = {
    replicas | Number,
    hostUsers | optional | Bool,
    containers,
    imagePullSecret | optional | String,
    nodeSelector | optional,
    nodeName | optional | String,
    affinity | optional,
    volumes | optional,
    secrets | optional,
  },

  K8sPrxyTLS = {
    httpsRedirect | optional | Bool,
    mode | optional | TlsMode,
    credentialName | optional | String,
  },

  K8sPrxyPort = {
    name | String,
    number | optional | Number,
    proto | ProxyProtocol,
  },

  K8sPrxyGatewayServer = {
    port,
    tls | optional,
    hosts | optional,
  },

  K8sPrxyVirtualServiceRoute = {
    port_number | Number,
    host | String,
  },

  K8sPrxyVirtualServiceMatchURL = {
    port | optional | Number,
    sniHost | optional,
  },

  K8sPrxyVirtualServiceMatch = {
    typ | MatchType,
    location | optional,
    route_destination | optional,
  },

  K8sPrxyVirtualService = {
    hosts,
    gateways,
    matches | optional,
  },

  K8sDefs = {
    name | String,
    ns | String,
    domain | String,
    full_domain | String,
    primary_dom | String,
    cluster_domain | String,
  },

  K8sServiceMeshConfig = {
    mtls_enabled | optional | Bool,
    tracing_enabled | optional | Bool,
  },

  K8sIngressConfig = {
    tls_enabled | optional | Bool,
    default_backend | optional | String,
  },

  K8sDeploy = {
    name | String,
    name_in_files | String,
    namespace | String,
    create_ns | Bool,
    full_domain | optional | String,
    labels,
    sel_labels,
    tpl_labels,
    spec,
    service_mesh | optional | ServiceMesh,
    service_mesh_ns | optional | String,
    service_mesh_config | optional,
    ingress_controller | optional | IngressController,
    ingress_ns | optional | String,
    ingress_config | optional,
    prxy | optional | LegacyProxy,
    prxy_ns | optional | String,
    prxyGatewayServers | optional,
    prxyVirtualService | optional,
    tls_path | optional | String,
    bin_apply | Bool,
    service | optional,
    backups | optional,
  },
}
