...

Source file src/github.com/openshift/api/apiserver/v1/types_apirequestcount.go

Documentation: github.com/openshift/api/apiserver/v1

     1  // Package v1 is an api version in the apiserver.openshift.io group
     2  package v1
     3  
     4  import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
     5  
     6  const (
     7  	// RemovedInReleaseLabel is a label which can be used to select APIRequestCounts based on the release
     8  	// in which they are removed.  The value is equivalent to .status.removedInRelease.
     9  	RemovedInReleaseLabel = "apirequestcounts.apiserver.openshift.io/removedInRelease"
    10  )
    11  
    12  // +genclient
    13  // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
    14  // +kubebuilder:resource:scope="Cluster"
    15  // +kubebuilder:subresource:status
    16  // +genclient:nonNamespaced
    17  // +openshift:compatibility-gen:level=1
    18  
    19  // APIRequestCount tracks requests made to an API. The instance name must
    20  // be of the form `resource.version.group`, matching the resource.
    21  //
    22  // Compatibility level 1: Stable within a major release for a minimum of 12 months or 3 minor releases (whichever is longer).
    23  type APIRequestCount struct {
    24  	metav1.TypeMeta `json:",inline"`
    25  
    26  	// metadata is the standard object's metadata.
    27  	// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
    28  	metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
    29  
    30  	// spec defines the characteristics of the resource.
    31  	// +kubebuilder:validation:Required
    32  	// +required
    33  	Spec APIRequestCountSpec `json:"spec"`
    34  
    35  	// status contains the observed state of the resource.
    36  	Status APIRequestCountStatus `json:"status,omitempty"`
    37  }
    38  
    39  type APIRequestCountSpec struct {
    40  
    41  	// numberOfUsersToReport is the number of users to include in the report.
    42  	// If unspecified or zero, the default is ten.  This is default is subject to change.
    43  	// +kubebuilder:default:=10
    44  	// +kubebuilder:validation:Minimum=0
    45  	// +kubebuilder:validation:Maximum=100
    46  	// +optional
    47  	NumberOfUsersToReport int64 `json:"numberOfUsersToReport"`
    48  }
    49  
    50  // +k8s:deepcopy-gen=true
    51  type APIRequestCountStatus struct {
    52  
    53  	// conditions contains details of the current status of this API Resource.
    54  	// +patchMergeKey=type
    55  	// +patchStrategy=merge
    56  	Conditions []metav1.Condition `json:"conditions" patchStrategy:"merge" patchMergeKey:"type"`
    57  
    58  	// removedInRelease is when the API will be removed.
    59  	// +kubebuilder:validation:MinLength=0
    60  	// +kubebuilder:validation:Pattern=^[0-9][0-9]*\.[0-9][0-9]*$
    61  	// +kubebuilder:validation:MaxLength=64
    62  	// +optional
    63  	RemovedInRelease string `json:"removedInRelease,omitempty"`
    64  
    65  	// requestCount is a sum of all requestCounts across all current hours, nodes, and users.
    66  	// +kubebuilder:validation:Minimum=0
    67  	// +required
    68  	RequestCount int64 `json:"requestCount"`
    69  
    70  	// currentHour contains request history for the current hour. This is porcelain to make the API
    71  	// easier to read by humans seeing if they addressed a problem. This field is reset on the hour.
    72  	// +optional
    73  	CurrentHour PerResourceAPIRequestLog `json:"currentHour"`
    74  
    75  	// last24h contains request history for the last 24 hours, indexed by the hour, so
    76  	// 12:00AM-12:59 is in index 0, 6am-6:59am is index 6, etc. The index of the current hour
    77  	// is updated live and then duplicated into the requestsLastHour field.
    78  	// +kubebuilder:validation:MaxItems=24
    79  	// +optional
    80  	Last24h []PerResourceAPIRequestLog `json:"last24h"`
    81  }
    82  
    83  // PerResourceAPIRequestLog logs request for various nodes.
    84  type PerResourceAPIRequestLog struct {
    85  
    86  	// byNode contains logs of requests per node.
    87  	// +kubebuilder:validation:MaxItems=512
    88  	// +optional
    89  	ByNode []PerNodeAPIRequestLog `json:"byNode"`
    90  
    91  	// requestCount is a sum of all requestCounts across nodes.
    92  	// +kubebuilder:validation:Minimum=0
    93  	// +required
    94  	RequestCount int64 `json:"requestCount"`
    95  }
    96  
    97  // PerNodeAPIRequestLog contains logs of requests to a certain node.
    98  type PerNodeAPIRequestLog struct {
    99  
   100  	// nodeName where the request are being handled.
   101  	// +kubebuilder:validation:MinLength=1
   102  	// +kubebuilder:validation:MaxLength=512
   103  	// +required
   104  	NodeName string `json:"nodeName"`
   105  
   106  	// requestCount is a sum of all requestCounts across all users, even those outside of the top 10 users.
   107  	// +kubebuilder:validation:Minimum=0
   108  	// +required
   109  	RequestCount int64 `json:"requestCount"`
   110  
   111  	// byUser contains request details by top .spec.numberOfUsersToReport users.
   112  	// Note that because in the case of an apiserver, restart the list of top users is determined on a best-effort basis,
   113  	// the list might be imprecise.
   114  	// In addition, some system users may be explicitly included in the list.
   115  	// +kubebuilder:validation:MaxItems=500
   116  	ByUser []PerUserAPIRequestCount `json:"byUser"`
   117  }
   118  
   119  // PerUserAPIRequestCount contains logs of a user's requests.
   120  type PerUserAPIRequestCount struct {
   121  
   122  	// userName that made the request.
   123  	// +kubebuilder:validation:MaxLength=512
   124  	UserName string `json:"username"`
   125  
   126  	// userAgent that made the request.
   127  	// The same user often has multiple binaries which connect (pods with many containers).  The different binaries
   128  	// will have different userAgents, but the same user.  In addition, we have userAgents with version information
   129  	// embedded and the userName isn't likely to change.
   130  	// +kubebuilder:validation:MaxLength=1024
   131  	UserAgent string `json:"userAgent"`
   132  
   133  	// requestCount of requests by the user across all verbs.
   134  	// +kubebuilder:validation:Minimum=0
   135  	// +required
   136  	RequestCount int64 `json:"requestCount"`
   137  
   138  	// byVerb details by verb.
   139  	// +kubebuilder:validation:MaxItems=10
   140  	ByVerb []PerVerbAPIRequestCount `json:"byVerb"`
   141  }
   142  
   143  // PerVerbAPIRequestCount requestCounts requests by API request verb.
   144  type PerVerbAPIRequestCount struct {
   145  
   146  	// verb of API request (get, list, create, etc...)
   147  	// +kubebuilder:validation:MaxLength=20
   148  	// +required
   149  	Verb string `json:"verb"`
   150  
   151  	// requestCount of requests for verb.
   152  	// +kubebuilder:validation:Minimum=0
   153  	// +required
   154  	RequestCount int64 `json:"requestCount"`
   155  }
   156  
   157  // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
   158  // +openshift:compatibility-gen:level=1
   159  
   160  // APIRequestCountList is a list of APIRequestCount resources.
   161  //
   162  // Compatibility level 1: Stable within a major release for a minimum of 12 months or 3 minor releases (whichever is longer).
   163  type APIRequestCountList struct {
   164  	metav1.TypeMeta `json:",inline"`
   165  
   166  	// metadata is the standard list's metadata.
   167  	// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
   168  	metav1.ListMeta `json:"metadata"`
   169  
   170  	Items []APIRequestCount `json:"items"`
   171  }
   172  

View as plain text