1 /* 2 Copyright 2019 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 apiserverinternal 18 19 import ( 20 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 21 ) 22 23 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 24 25 // StorageVersion of a specific resource. 26 type StorageVersion struct { 27 metav1.TypeMeta 28 // The name is <group>.<resource>. 29 metav1.ObjectMeta 30 31 // Spec is an empty spec. It is here to comply with Kubernetes API style. 32 Spec StorageVersionSpec 33 34 // API server instances report the version they can decode and the version they 35 // encode objects to when persisting objects in the backend. 36 Status StorageVersionStatus 37 } 38 39 // StorageVersionSpec is an empty spec. 40 type StorageVersionSpec struct{} 41 42 // StorageVersionStatus API server instances report the versions they can decode and the version they 43 // encode objects to when persisting objects in the backend. 44 type StorageVersionStatus struct { 45 // The reported versions per API server instance. 46 // +optional 47 StorageVersions []ServerStorageVersion 48 // If all API server instances agree on the same encoding storage version, 49 // then this field is set to that version. Otherwise this field is left empty. 50 // API servers should finish updating its storageVersionStatus entry before 51 // serving write operations, so that this field will be in sync with the reality. 52 // +optional 53 CommonEncodingVersion *string 54 55 // The latest available observations of the storageVersion's state. 56 // +optional 57 Conditions []StorageVersionCondition 58 } 59 60 // ServerStorageVersion An API server instance reports the version it can decode and the version it 61 // encodes objects to when persisting objects in the backend. 62 type ServerStorageVersion struct { 63 // The ID of the reporting API server. 64 APIServerID string 65 66 // The API server encodes the object to this version when persisting it in 67 // the backend (e.g., etcd). 68 EncodingVersion string 69 70 // The API server can decode objects encoded in these versions. 71 // The encodingVersion must be included in the decodableVersions. 72 DecodableVersions []string 73 74 // The API server can serve these versions. 75 // DecodableVersions must include all ServedVersions. 76 ServedVersions []string 77 } 78 79 // StorageVersionConditionType Indicates the storage version condition type 80 type StorageVersionConditionType string 81 82 const ( 83 //AllEncodingVersionsEqual Indicates that encoding storage versions reported by all servers are equal. 84 AllEncodingVersionsEqual StorageVersionConditionType = "AllEncodingVersionsEqual" 85 ) 86 87 // ConditionStatus indicates status of condition from "True", "False", or "Unknown" 88 type ConditionStatus string 89 90 const ( 91 // ConditionTrue indicates condition as "True" 92 ConditionTrue ConditionStatus = "True" 93 // ConditionFalse indicates condition as "False" 94 ConditionFalse ConditionStatus = "False" 95 // ConditionUnknown indicates condition as "Unknown" 96 ConditionUnknown ConditionStatus = "Unknown" 97 ) 98 99 // StorageVersionCondition Describes the state of the storageVersion at a certain point. 100 type StorageVersionCondition struct { 101 // Type of the condition. 102 // +optional 103 Type StorageVersionConditionType 104 // Status of the condition, one of True, False, Unknown. 105 // +required 106 Status ConditionStatus 107 // If set, this represents the .metadata.generation that the condition was set based upon. 108 // +optional 109 ObservedGeneration int64 110 // Last time the condition transitioned from one status to another. 111 LastTransitionTime metav1.Time 112 // The reason for the condition's last transition. 113 // +required 114 Reason string 115 // A human readable message indicating details about the transition. 116 // +required 117 Message string 118 } 119 120 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 121 122 // StorageVersionList A list of StorageVersions. 123 type StorageVersionList struct { 124 metav1.TypeMeta 125 // +optional 126 metav1.ListMeta 127 Items []StorageVersion 128 } 129