kubevirt.io/api@v1.2.0/pool/v1alpha1/types.go (about) 1 /* 2 * This file is part of the KubeVirt project 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 * Copyright 2021 Red Hat, Inc. 17 * 18 */ 19 20 package v1alpha1 21 22 import ( 23 k8sv1 "k8s.io/api/core/v1" 24 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 25 26 virtv1 "kubevirt.io/api/core/v1" 27 ) 28 29 const ( 30 VirtualMachinePoolKind = "VirtualMachinePool" 31 ) 32 33 // VirtualMachinePool resource contains a VirtualMachine configuration 34 // that can be used to replicate multiple VirtualMachine resources. 35 // 36 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 37 // +k8s:openapi-gen=true 38 // +genclient 39 type VirtualMachinePool struct { 40 metav1.TypeMeta `json:",inline"` 41 metav1.ObjectMeta `json:"metadata,omitempty"` 42 43 Spec VirtualMachinePoolSpec `json:"spec" valid:"required"` 44 Status VirtualMachinePoolStatus `json:"status,omitempty"` 45 } 46 47 // +k8s:openapi-gen=true 48 type VirtualMachineTemplateSpec struct { 49 // +kubebuilder:pruning:PreserveUnknownFields 50 // +nullable 51 ObjectMeta metav1.ObjectMeta `json:"metadata,omitempty"` 52 // VirtualMachineSpec contains the VirtualMachine specification. 53 Spec virtv1.VirtualMachineSpec `json:"spec,omitempty" valid:"required"` 54 } 55 56 // +k8s:openapi-gen=true 57 type VirtualMachinePoolConditionType string 58 59 const ( 60 // VirtualMachinePoolReplicaFailure is added in a pool when one of its vms 61 // fails to be created. 62 VirtualMachinePoolReplicaFailure VirtualMachinePoolConditionType = "ReplicaFailure" 63 64 // VirtualMachinePoolReplicaPaused is added in a pool when the pool got paused by the controller. 65 // After this condition was added, it is safe to remove or add vms by hand and adjust the replica count manually 66 VirtualMachinePoolReplicaPaused VirtualMachinePoolConditionType = "ReplicaPaused" 67 ) 68 69 // +k8s:openapi-gen=true 70 type VirtualMachinePoolCondition struct { 71 Type VirtualMachinePoolConditionType `json:"type"` 72 Status k8sv1.ConditionStatus `json:"status"` 73 // +nullable 74 LastProbeTime metav1.Time `json:"lastProbeTime,omitempty"` 75 // +nullable 76 LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty"` 77 Reason string `json:"reason,omitempty"` 78 Message string `json:"message,omitempty"` 79 } 80 81 // +k8s:openapi-gen=true 82 type VirtualMachinePoolStatus struct { 83 Replicas int32 `json:"replicas,omitempty" optional:"true"` 84 85 ReadyReplicas int32 `json:"readyReplicas,omitempty" optional:"true"` 86 87 // +listType=atomic 88 Conditions []VirtualMachinePoolCondition `json:"conditions,omitempty" optional:"true"` 89 90 // Canonical form of the label selector for HPA which consumes it through the scale subresource. 91 LabelSelector string `json:"labelSelector,omitempty"` 92 } 93 94 // +k8s:openapi-gen=true 95 type VirtualMachinePoolSpec struct { 96 // Number of desired pods. This is a pointer to distinguish between explicit 97 // zero and not specified. Defaults to 1. 98 // +optional 99 Replicas *int32 `json:"replicas,omitempty"` 100 101 // Label selector for pods. Existing Poolss whose pods are 102 // selected by this will be the ones affected by this deployment. 103 Selector *metav1.LabelSelector `json:"selector" valid:"required"` 104 105 // Template describes the VM that will be created. 106 VirtualMachineTemplate *VirtualMachineTemplateSpec `json:"virtualMachineTemplate" valid:"required"` 107 108 // Indicates that the pool is paused. 109 // +optional 110 Paused bool `json:"paused,omitempty" protobuf:"varint,7,opt,name=paused"` 111 } 112 113 // VirtualMachinePoolList is a list of VirtualMachinePool resources. 114 // 115 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 116 // +k8s:openapi-gen=true 117 type VirtualMachinePoolList struct { 118 metav1.TypeMeta `json:",inline"` 119 metav1.ListMeta `json:"metadata,omitempty"` 120 Items []VirtualMachinePool `json:"items"` 121 }