forked from Azure/fleet-networking
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
interface: define traffic manager apis (Azure#191)
- Loading branch information
1 parent
08bfefc
commit 7c5b6bf
Showing
7 changed files
with
1,083 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
package v1alpha1 | ||
|
||
import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
|
||
// +kubebuilder:object:root=true | ||
// +kubebuilder:resource:scope=Namespaced,categories={fleet-networking},shortName=tme | ||
// +kubebuilder:subresource:status | ||
// +kubebuilder:printcolumn:JSONPath=`.spec.profile.name`,name="Profile",type=string | ||
// +kubebuilder:printcolumn:JSONPath=`.spec.profile.namespace`,name="Profile-Namespace",type=string | ||
// +kubebuilder:printcolumn:JSONPath=`.spec.endpointRef.name`,name="Backend",type=string | ||
// +kubebuilder:printcolumn:JSONPath=`.status.conditions[?(@.type=='Accepted')].status`,name="Is-Accepted",type=string | ||
// +kubebuilder:printcolumn:JSONPath=`.metadata.creationTimestamp`,name="Age",type=date | ||
|
||
// TrafficManagerBackend is used to manage the Azure Traffic Manager Endpoints using cloud native way. | ||
// A backend contains one or more endpoints. Therefore, the controller may create multiple endpoints under the Traffic | ||
// Manager Profile. | ||
// https://learn.microsoft.com/en-us/azure/traffic-manager/traffic-manager-endpoint-types | ||
type TrafficManagerBackend struct { | ||
metav1.TypeMeta `json:",inline"` | ||
// +optional | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
// The desired state of TrafficManagerBackend. | ||
Spec TrafficManagerBackendSpec `json:"spec"` | ||
|
||
// The observed status of TrafficManagerBackend. | ||
// +optional | ||
Status TrafficManagerBackendStatus `json:"status,omitempty"` | ||
} | ||
|
||
type TrafficManagerBackendSpec struct { | ||
// +required | ||
// immutable | ||
// Which TrafficManagerProfile the backend should be attached to. | ||
Profile TrafficManagerProfileRef `json:"profile"` | ||
|
||
// The reference to a backend. | ||
// immutable | ||
// +required | ||
Backend TrafficManagerBackendRef `json:"backend"` | ||
|
||
// The total weight of endpoints behind the serviceImport when using the 'Weighted' traffic routing method. | ||
// Possible values are from 1 to 1000. | ||
// By default, the routing method is 'Weighted', so that it is required for now. | ||
// +optional | ||
// +kubebuilder:validation:Minimum=1 | ||
// +kubebuilder:validation:Maximum=1000 | ||
// For example, if there are two clusters exporting the service via public ip, each public ip will be configured | ||
// as "Weight"/2. | ||
Weight *int64 `json:"weight,omitempty"` | ||
} | ||
|
||
// TrafficManagerProfileRef is a reference to a trafficManagerProfile object in the same namespace as the TrafficManagerBackend object. | ||
type TrafficManagerProfileRef struct { | ||
// Name is the name of the referenced trafficManagerProfile. | ||
Name string `json:"name"` | ||
} | ||
|
||
// TrafficManagerBackendRef is the reference to a backend. | ||
// Currently, we only support one backend type: ServiceImport. | ||
type TrafficManagerBackendRef struct { | ||
// Name is the reference to the ServiceImport in the same namespace as the TrafficManagerBackend object. | ||
// +required | ||
Name string `json:"name"` | ||
} | ||
|
||
// TrafficManagerEndpointStatus is the status of Azure Traffic Manager endpoint which is successfully accepted under the traffic | ||
// manager Profile. | ||
type TrafficManagerEndpointStatus struct { | ||
// Name of the endpoint. | ||
// +required | ||
Name string `json:"name"` | ||
|
||
// The weight of this endpoint when using the 'Weighted' traffic routing method. | ||
// Possible values are from 1 to 1000. | ||
// +optional | ||
Weight *int64 `json:"weight,omitempty"` | ||
|
||
// The fully-qualified DNS name or IP address of the endpoint. | ||
// +optional | ||
Target *string `json:"target,omitempty"` | ||
|
||
// Cluster is where the endpoint is exported from. | ||
// +optional | ||
Cluster *ClusterStatus `json:"cluster,omitempty"` | ||
} | ||
|
||
type TrafficManagerBackendStatus struct { | ||
// Endpoints contains a list of accepted Azure endpoints which are created or updated under the traffic manager Profile. | ||
// +optional | ||
Endpoints []TrafficManagerEndpointStatus `json:"endpoints,omitempty"` | ||
|
||
// Current backend status. | ||
// +optional | ||
// +patchMergeKey=type | ||
// +patchStrategy=merge | ||
// +listType=map | ||
// +listMapKey=type | ||
Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type"` | ||
} | ||
|
||
// TrafficManagerBackendConditionType is a type of condition associated with a TrafficManagerBackendStatus. This type | ||
// should be used within the TrafficManagerBackendStatus.Conditions field. | ||
type TrafficManagerBackendConditionType string | ||
|
||
// TrafficManagerBackendConditionReason defines the set of reasons that explain why a particular backend has been raised. | ||
type TrafficManagerBackendConditionReason string | ||
|
||
const ( | ||
// TrafficManagerBackendConditionAccepted condition indicates whether endpoints have been created or updated for the profile. | ||
// This does not indicate whether or not the configuration has been propagated to the data plane. | ||
// | ||
// Possible reasons for this condition to be True are: | ||
// | ||
// * "Accepted" | ||
// | ||
// Possible reasons for this condition to be False are: | ||
// | ||
// * "Invalid" | ||
// * "Pending" | ||
TrafficManagerBackendConditionAccepted TrafficManagerBackendConditionReason = "Accepted" | ||
|
||
// TrafficManagerBackendReasonAccepted is used with the "Accepted" condition when the condition is True. | ||
TrafficManagerBackendReasonAccepted TrafficManagerBackendConditionReason = "Accepted" | ||
|
||
// TrafficManagerBackendReasonInvalid is used with the "Accepted" condition when one or | ||
// more endpoint references have an invalid or unsupported configuration | ||
// and cannot be configured on the Profile with more details in the message. | ||
TrafficManagerBackendReasonInvalid TrafficManagerBackendConditionReason = "Invalid" | ||
|
||
// TrafficManagerBackendReasonPending is used with the "Accepted" when creating or updating endpoint hits an internal error with | ||
// more details in the message and the controller will keep retry. | ||
TrafficManagerBackendReasonPending TrafficManagerBackendConditionReason = "Pending" | ||
) | ||
|
||
//+kubebuilder:object:root=true | ||
|
||
// TrafficManagerBackendList contains a list of TrafficManagerBackend. | ||
type TrafficManagerBackendList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
// +optional | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
// +listType=set | ||
Items []TrafficManagerBackend `json:"items"` | ||
} | ||
|
||
func init() { | ||
SchemeBuilder.Register(&TrafficManagerBackend{}, &TrafficManagerBackendList{}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
package v1alpha1 | ||
|
||
import ( | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
// +kubebuilder:object:root=true | ||
// +kubebuilder:resource:scope=Namespaced,categories={fleet-networking},shortName=tmp | ||
// +kubebuilder:subresource:status | ||
// +kubebuilder:printcolumn:JSONPath=`.status.dnsName`,name="DNS-Name",type=string | ||
// +kubebuilder:printcolumn:JSONPath=`.status.conditions[?(@.type=='Programmed')].status`,name="Is-Programmed",type=string | ||
// +kubebuilder:printcolumn:JSONPath=`.metadata.creationTimestamp`,name="Age",type=date | ||
|
||
// TrafficManagerProfile is used to manage a simple Azure Traffic Manager Profile using cloud native way. | ||
// https://learn.microsoft.com/en-us/azure/traffic-manager/traffic-manager-overview | ||
type TrafficManagerProfile struct { | ||
metav1.TypeMeta `json:",inline"` | ||
// +optional | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
// The desired state of TrafficManagerProfile. | ||
Spec TrafficManagerProfileSpec `json:"spec"` | ||
|
||
// The observed status of TrafficManagerProfile. | ||
// +optional | ||
Status TrafficManagerProfileStatus `json:"status,omitempty"` | ||
} | ||
|
||
// TrafficManagerProfileSpec defines the desired state of TrafficManagerProfile. | ||
// For now, only the "Weighted" traffic routing method is supported. | ||
type TrafficManagerProfileSpec struct { | ||
// The endpoint monitoring settings of the Traffic Manager profile. | ||
// +optional | ||
MonitorConfig *MonitorConfig `json:"monitorConfig,omitempty"` | ||
} | ||
|
||
// MonitorConfig defines the endpoint monitoring settings of the Traffic Manager profile. | ||
// https://learn.microsoft.com/en-us/azure/traffic-manager/traffic-manager-monitoring | ||
type MonitorConfig struct { | ||
// The monitor interval for endpoints in this profile. This is the interval at which Traffic Manager will check the health | ||
// of each endpoint in this profile. | ||
// You can specify two values here: 30 seconds (normal probing) and 10 seconds (fast probing). | ||
// +optional | ||
IntervalInSeconds *int64 `json:"intervalInSeconds,omitempty"` | ||
|
||
// The path relative to the endpoint domain name used to probe for endpoint health. | ||
// +optional | ||
Path *string `json:"path,omitempty"` | ||
|
||
// The TCP port used to probe for endpoint health. | ||
// +optional | ||
Port *int64 `json:"port,omitempty"` | ||
|
||
// The protocol (HTTP, HTTPS or TCP) used to probe for endpoint health. | ||
// +kubebuilder:validation:Enum=HTTP;HTTPS;TCP | ||
// +optional | ||
Protocol *TrafficManagerMonitorProtocol `json:"protocol,omitempty"` | ||
|
||
// The monitor timeout for endpoints in this profile. This is the time that Traffic Manager allows endpoints in this profile | ||
// to response to the health check. | ||
// +optional | ||
// * If the IntervalInSeconds is set to 30 seconds, then you can set the Timeout value between 5 and 10 seconds. | ||
// If no value is specified, it uses a default value of 10 seconds. | ||
// * If the IntervalInSeconds is set to 10 seconds, then you can set the Timeout value between 5 and 9 seconds. | ||
// If no Timeout value is specified, it uses a default value of 9 seconds. | ||
TimeoutInSeconds *int64 `json:"timeoutInSeconds,omitempty"` | ||
|
||
// The number of consecutive failed health check that Traffic Manager tolerates before declaring an endpoint in this profile | ||
// Degraded after the next failed health check. | ||
// +optional | ||
// +kubebuilder:validation:Minimum=0 | ||
// +kubebuilder:validation:Maximum=9 | ||
ToleratedNumberOfFailures *int64 `json:"toleratedNumberOfFailures,omitempty"` | ||
} | ||
|
||
// TrafficManagerMonitorProtocol defines the protocol used to probe for endpoint health. | ||
type TrafficManagerMonitorProtocol string | ||
|
||
const ( | ||
TrafficManagerMonitorProtocolHTTP TrafficManagerMonitorProtocol = "HTTP" | ||
TrafficManagerMonitorProtocolHTTPS TrafficManagerMonitorProtocol = "HTTPS" | ||
TrafficManagerMonitorProtocolTCP TrafficManagerMonitorProtocol = "TCP" | ||
) | ||
|
||
type TrafficManagerProfileStatus struct { | ||
// DNSName is the fully-qualified domain name (FQDN) of the Traffic Manager profile. | ||
// It consists of profile name and the DNS domain name used by Azure Traffic Manager to form the fully-qualified | ||
// domain name (FQDN) of the profile. | ||
// For example, "<TrafficManagerProfileName>.trafficmanager.net" | ||
// +optional | ||
DNSName *string `json:"dnsName,omitempty"` | ||
|
||
// Current profile status. | ||
// +optional | ||
// +patchMergeKey=type | ||
// +patchStrategy=merge | ||
// +listType=map | ||
// +listMapKey=type | ||
Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type"` | ||
} | ||
|
||
// TrafficManagerProfileConditionType is a type of condition associated with a | ||
// Traffic Manager Profile. This type should be used within the TrafficManagerProfileStatus.Conditions field. | ||
type TrafficManagerProfileConditionType string | ||
|
||
// TrafficManagerProfileConditionReason defines the set of reasons that explain why a | ||
// particular profile condition type has been raised. | ||
type TrafficManagerProfileConditionReason string | ||
|
||
const ( | ||
// TrafficManagerProfileConditionProgrammed condition indicates whether a profile has been generated that is assumed to be ready | ||
// soon in the underlying data plane. This does not indicate whether or not the configuration has been propagated | ||
// to the data plane. | ||
// | ||
// It is a positive-polarity summary condition, and so should always be | ||
// present on the resource with ObservedGeneration set. | ||
// | ||
// Possible reasons for this condition to be True are: | ||
// | ||
// * "Programmed" | ||
// | ||
// Possible reasons for this condition to be False are: | ||
// | ||
// * "Invalid" | ||
// * "DNSNameNotAvailable" | ||
// * "Pending" | ||
TrafficManagerProfileConditionProgrammed TrafficManagerProfileConditionType = "Programmed" | ||
|
||
// TrafficManagerProfileReasonProgrammed is used with the "Programmed" condition when the condition is true. | ||
TrafficManagerProfileReasonProgrammed TrafficManagerProfileConditionReason = "Programmed" | ||
|
||
// TrafficManagerProfileReasonInvalid is used with the "Programmed" when the profile is syntactically or semantically invalid. | ||
TrafficManagerProfileReasonInvalid TrafficManagerProfileConditionReason = "Invalid" | ||
|
||
// TrafficManagerProfileReasonDNSNameNotAvailable is used with the "Programmed" condition when the generated DNS name is not available. | ||
TrafficManagerProfileReasonDNSNameNotAvailable TrafficManagerProfileConditionReason = "DNSNameNotAvailable" | ||
|
||
// TrafficManagerProfileReasonPending is used with the "Programmed" when creating or updating the profile hits an internal error | ||
// with more details in the message and the controller will keep retry. | ||
TrafficManagerProfileReasonPending TrafficManagerProfileConditionReason = "Pending" | ||
) | ||
|
||
//+kubebuilder:object:root=true | ||
|
||
// TrafficManagerProfileList contains a list of TrafficManagerProfile. | ||
type TrafficManagerProfileList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
// +optional | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
// +listType=set | ||
Items []TrafficManagerProfile `json:"items"` | ||
} | ||
|
||
func init() { | ||
SchemeBuilder.Register(&TrafficManagerProfile{}, &TrafficManagerProfileList{}) | ||
} |
Oops, something went wrong.