
// This file was autogenerated by go-to-protobuf. Do not edit it manually!

syntax = "proto2";

package github.com.openshift.api.networkoperator.v1;

import "k8s.io/apimachinery/pkg/apis/meta/v1/generated.proto";
import "k8s.io/apimachinery/pkg/runtime/schema/generated.proto";

// Package-wide variables from generator "generated".
option go_package = "github.com/openshift/api/networkoperator/v1";

// EgressRouter is a feature allowing the user to define an egress router
// that acts as a bridge between pods and external systems. The egress router runs
// a service that redirects egress traffic originating from a pod or a group of
// pods to a remote external system or multiple destinations as per configuration.
//
// It is consumed by the cluster-network-operator.
// More specifically, given an EgressRouter CR with <name>, the CNO will create and manage:
// - A service called <name>
// - An egress pod called <name>
// - A NAD called <name>
//
// Compatibility level 1: Stable within a major release for a minimum of 12 months or 3 minor releases (whichever is longer).
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
//
// EgressRouter is a single egressrouter pod configuration object.
// +k8s:openapi-gen=true
// +openshift:compatibility-gen:level=1
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:resource:path=egressrouters,scope=Namespaced
// +openshift:api-approved.openshift.io=https://github.com/openshift/api/pull/851
// +openshift:file-pattern=operatorOrdering=001
// +kubebuilder:metadata:annotations=include.release.openshift.io/self-managed-high-availability=true
// +kubebuilder:metadata:annotations=include.release.openshift.io/ibm-cloud-managed=true
// +kubebuilder:printcolumn:name="Condition",type=string,JSONPath=".status.conditions[*].type"
// +kubebuilder:printcolumn:name="Status",type=string,JSONPath=".status.conditions[*].status"
message EgressRouter {
  // metadata is the standard object's metadata.
  // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
  optional .k8s.io.apimachinery.pkg.apis.meta.v1.ObjectMeta metadata = 1;

  // Specification of the desired egress router.
  // +required
  optional EgressRouterSpec spec = 2;

  // Observed status of EgressRouter.
  optional EgressRouterStatus status = 3;
}

// EgressRouterAddress contains a pair of IP CIDR and gateway to be configured on the router's interface
message EgressRouterAddress {
  // ip is the address to configure on the router's interface. Can be IPv4 or IPv6.
  // +required
  optional string ip = 1;

  // IP address of the next-hop gateway, if it cannot be automatically determined. Can be IPv4 or IPv6.
  optional string gateway = 2;
}

// EgressRouterInterface contains the configuration of interface to create/use.
message EgressRouterInterface {
  // Arguments specific to the interfaceType macvlan
  // +kubebuilder:default:={mode: Bridge}
  optional MacvlanConfig macvlan = 1;
}

// EgressRouterList is the list of egress router pods requested.
//
// Compatibility level 1: Stable within a major release for a minimum of 12 months or 3 minor releases (whichever is longer).
// +openshift:compatibility-gen:level=1
message EgressRouterList {
  // metadata is the standard list's metadata.
  // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
  optional .k8s.io.apimachinery.pkg.apis.meta.v1.ListMeta metadata = 1;

  repeated EgressRouter items = 2;
}

// EgressRouterSpec contains the configuration for an egress router.
// Mode, networkInterface and addresses fields must be specified along with exactly one "Config" that matches the mode.
// Each config consists of parameters specific to that mode.
// +k8s:openapi-gen=true
message EgressRouterSpec {
  // mode depicts the mode that is used for the egress router. The default mode is "Redirect" and is the only supported mode currently.
  // +required
  // +kubebuilder:validation:Enum="Redirect"
  // +kubebuilder:default:="Redirect"
  optional string mode = 1;

  // redirect represents the configuration parameters specific to redirect mode.
  optional RedirectConfig redirect = 2;

  // Specification of interface to create/use. The default is macvlan.
  // Currently only macvlan is supported.
  // +required
  // +kubebuilder:default:={macvlan: {mode: Bridge}}
  optional EgressRouterInterface networkInterface = 3;

  // List of IP addresses to configure on the pod's secondary interface.
  // +required
  repeated EgressRouterAddress addresses = 4;
}

// EgressRouterStatus contains the observed status of EgressRouter. Read-only.
message EgressRouterStatus {
  // Observed status of the egress router
  // +required
  // +listType=map
  // +listMapKey=type
  repeated EgressRouterStatusCondition conditions = 1;
}

// EgressRouterStatusCondition represents the state of the egress router's
// managed and monitored components.
// +k8s:deepcopy-gen=true
message EgressRouterStatusCondition {
  // type specifies the aspect reported by this condition; one of Available, Progressing, Degraded
  // +kubebuilder:validation:Enum="Available";"Progressing";"Degraded"
  // +required
  optional string type = 1;

  // status of the condition, one of True, False, Unknown.
  // +kubebuilder:validation:Enum="True";"False";"Unknown"
  // +required
  optional string status = 2;

  // lastTransitionTime is the time of the last update to the current status property.
  // +required
  // +nullable
  optional .k8s.io.apimachinery.pkg.apis.meta.v1.Time lastTransitionTime = 3;

  // reason is the CamelCase reason for the condition's current status.
  optional string reason = 4;

  // message provides additional information about the current condition.
  // This is only to be consumed by humans.  It may contain Line Feed
  // characters (U+000A), which should be rendered as new lines.
  optional string message = 5;
}

// L4RedirectRule defines a DNAT redirection from a given port to a destination IP and port.
message L4RedirectRule {
  // IP specifies the remote destination's IP address. Can be IPv4 or IPv6.
  // +required
  optional string destinationIP = 1;

  // port is the port number to which clients should send traffic to be redirected.
  // +required
  // +kubebuilder:validation:Maximum:=65535
  // +kubebuilder:validation:Minimum:=1
  optional int32 port = 2;

  // protocol can be TCP, SCTP or UDP.
  // +required
  // +kubebuilder:validation:Enum="TCP";"UDP";"SCTP"
  optional string protocol = 3;

  // targetPort allows specifying the port number on the remote destination to which the traffic gets redirected to.
  // If unspecified, the value from "Port" is used.
  // +kubebuilder:validation:Maximum:=65535
  // +kubebuilder:validation:Minimum:=1
  optional int32 targetPort = 4;
}

// MacvlanConfig consists of arguments specific to the macvlan EgressRouterInterfaceType
message MacvlanConfig {
  // mode depicts the mode that is used for the macvlan interface; one of Bridge|Private|VEPA|Passthru. The default mode is "Bridge".
  // +required
  // +kubebuilder:validation:Enum="Bridge";"Private";"VEPA";"Passthru"
  // +kubebuilder:default:="Bridge"
  optional string mode = 1;

  // Name of the master interface. Need not be specified if it can be inferred from the IP address.
  optional string master = 2;
}

// RedirectConfig represents the configuration parameters specific to redirect mode.
message RedirectConfig {
  // List of L4RedirectRules that define the DNAT redirection from the pod to the destination in redirect mode.
  repeated L4RedirectRule redirectRules = 1;

  // fallbackIP specifies the remote destination's IP address. Can be IPv4 or IPv6.
  // If no redirect rules are specified, all traffic from the router are redirected to this IP.
  // If redirect rules are specified, then any connections on any other port (undefined in the rules) on the router will be redirected to this IP.
  // If redirect rules are specified and no fallback IP is provided, connections on other ports will simply be rejected.
  optional string fallbackIP = 2;
}

