1 /* 2 Copyright 2016 The Kubernetes Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package apiregistration 18 19 import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 20 21 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 22 23 // APIServiceList is a list of APIService objects. 24 type APIServiceList struct { 25 metav1.TypeMeta 26 metav1.ListMeta 27 28 Items []APIService 29 } 30 31 // ServiceReference holds a reference to Service.legacy.k8s.io 32 type ServiceReference struct { 33 // Namespace is the namespace of the service 34 Namespace string 35 // Name is the name of the service 36 Name string 37 // If specified, the port on the service that hosting the service. 38 // Default to 443 for backward compatibility. 39 // `port` should be a valid port number (1-65535, inclusive). 40 // +optional 41 Port int32 42 } 43 44 // APIServiceSpec contains information for locating and communicating with a server. 45 // Only https is supported, though you are able to disable certificate verification. 46 type APIServiceSpec struct { 47 // Service is a reference to the service for this API server. It must communicate 48 // on port 443. 49 // If the Service is nil, that means the handling for the API groupversion is handled locally on this server. 50 // The call will simply delegate to the normal handler chain to be fulfilled. 51 // +optional 52 Service *ServiceReference 53 // Group is the API group name this server hosts 54 Group string 55 // Version is the API version this server hosts. For example, "v1" 56 Version string 57 58 // InsecureSkipTLSVerify disables TLS certificate verification when communicating with this server. 59 // This is strongly discouraged. You should use the CABundle instead. 60 InsecureSkipTLSVerify bool 61 // CABundle is a PEM encoded CA bundle which will be used to validate an API server's serving certificate. 62 // If unspecified, system trust roots on the apiserver are used. 63 // +listType=atomic 64 // +optional 65 CABundle []byte 66 67 // GroupPriorityMinimum is the priority this group should have at least. Higher priority means that the group is preferred by clients over lower priority ones. 68 // Note that other versions of this group might specify even higher GroupPriorityMinimum values such that the whole group gets a higher priority. 69 // The primary sort is based on GroupPriorityMinimum, ordered highest number to lowest (20 before 10). 70 // The secondary sort is based on the alphabetical comparison of the name of the object. (v1.bar before v1.foo) 71 // We'd recommend something like: *.k8s.io (except extensions) at 18000 and 72 // PaaSes (OpenShift, Deis) are recommended to be in the 2000s 73 GroupPriorityMinimum int32 74 75 // VersionPriority controls the ordering of this API version inside of its group. Must be greater than zero. 76 // The primary sort is based on VersionPriority, ordered highest to lowest (20 before 10). 77 // Since it's inside of a group, the number can be small, probably in the 10s. 78 // In case of equal version priorities, the version string will be used to compute the order inside a group. 79 // If the version string is "kube-like", it will sort above non "kube-like" version strings, which are ordered 80 // lexicographically. "Kube-like" versions start with a "v", then are followed by a number (the major version), 81 // then optionally the string "alpha" or "beta" and another number (the minor version). These are sorted first 82 // by GA > beta > alpha (where GA is a version with no suffix such as beta or alpha), and then by comparing major 83 // version, then minor version. An example sorted list of versions: 84 // v10, v2, v1, v11beta2, v10beta3, v3beta1, v12alpha1, v11alpha2, foo1, foo10. 85 VersionPriority int32 86 } 87 88 // ConditionStatus indicates the status of a condition (true, false, or unknown). 89 type ConditionStatus string 90 91 // These are valid condition statuses. "ConditionTrue" means a resource is in the condition; 92 // "ConditionFalse" means a resource is not in the condition; "ConditionUnknown" means kubernetes 93 // can't decide if a resource is in the condition or not. In the future, we could add other 94 // intermediate conditions, e.g. ConditionDegraded. 95 const ( 96 ConditionTrue ConditionStatus = "True" 97 ConditionFalse ConditionStatus = "False" 98 ConditionUnknown ConditionStatus = "Unknown" 99 ) 100 101 // APIServiceConditionType is a valid value for APIServiceCondition.Type 102 type APIServiceConditionType string 103 104 const ( 105 // Available indicates that the service exists and is reachable 106 Available APIServiceConditionType = "Available" 107 ) 108 109 // APIServiceCondition describes conditions for an APIService 110 type APIServiceCondition struct { 111 // Type is the type of the condition. 112 Type APIServiceConditionType 113 // Status is the status of the condition. 114 // Can be True, False, Unknown. 115 Status ConditionStatus 116 // Last time the condition transitioned from one status to another. 117 LastTransitionTime metav1.Time 118 // Unique, one-word, CamelCase reason for the condition's last transition. 119 Reason string 120 // Human-readable message indicating details about last transition. 121 Message string 122 } 123 124 // APIServiceStatus contains derived information about an API server 125 type APIServiceStatus struct { 126 // Current service state of apiService. 127 // +listType=map 128 // +listMapKey=type 129 Conditions []APIServiceCondition 130 } 131 132 // +genclient 133 // +genclient:nonNamespaced 134 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 135 136 // APIService represents a server for a particular GroupVersion. 137 // Name must be "version.group". 138 type APIService struct { 139 metav1.TypeMeta 140 metav1.ObjectMeta 141 142 // Spec contains information for locating and communicating with a server 143 Spec APIServiceSpec 144 // Status contains derived information about an API server 145 Status APIServiceStatus 146 } 147