kubesphere.io/api@v0.0.0-20231107125330-c9a03957060c/gateway/v1alpha1/gateway_types.go (about)

     1  /*
     2  Copyright 2021 The KubeSphere 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 v1alpha1
    18  
    19  import (
    20  	corev1 "k8s.io/api/core/v1"
    21  	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    22  	runtime "k8s.io/apimachinery/pkg/runtime"
    23  )
    24  
    25  // GatewaySpec defines the desired state of Gateway
    26  type GatewaySpec struct {
    27  	Controller ControllerSpec `json:"controller,omitempty"`
    28  	Service    ServiceSpec    `json:"service,omitempty"`
    29  	Deployment DeploymentSpec `json:"deployment,omitempty"`
    30  }
    31  
    32  type ControllerSpec struct {
    33  	// +optional
    34  	Replicas *int32 `json:"replicas,omitempty"`
    35  	// +optional
    36  	Annotations map[string]string `json:"annotations,omitempty"`
    37  	// +optional
    38  	Config map[string]string `json:"config,omitempty"`
    39  	// +optional
    40  	Scope Scope `json:"scope,omitempty"`
    41  	// +optional
    42  	TCP map[string]string `json:"tcp,omitempty"`
    43  	// +optional
    44  	UDP map[string]string `json:"udp,omitempty"`
    45  }
    46  
    47  type ServiceSpec struct {
    48  	// +optional
    49  	Annotations map[string]string `json:"annotations,omitempty"`
    50  	// +optional
    51  	Type corev1.ServiceType `json:"type,omitempty"`
    52  }
    53  
    54  type DeploymentSpec struct {
    55  	// +optional
    56  	Replicas *int32 `json:"replicas,omitempty"`
    57  	// +optional
    58  	Annotations map[string]string `json:"annotations,omitempty"`
    59  	// +optional
    60  	Resources corev1.ResourceRequirements `json:"resources,omitempty"`
    61  }
    62  
    63  type Scope struct {
    64  	Enabled   bool   `json:"enabled,omitempty"`
    65  	Namespace string `json:"namespace,omitempty"`
    66  }
    67  
    68  //+kubebuilder:object:root=true
    69  //+kubebuilder:subresource:status
    70  //+genclient
    71  
    72  // Gateway is the Schema for the gateways API
    73  type Gateway struct {
    74  	metav1.TypeMeta   `json:",inline"`
    75  	metav1.ObjectMeta `json:"metadata,omitempty"`
    76  
    77  	Spec GatewaySpec `json:"spec,omitempty"`
    78  
    79  	// +kubebuilder:pruning:PreserveUnknownFields
    80  	Status runtime.RawExtension `json:"status,omitempty"`
    81  }
    82  
    83  //+kubebuilder:object:root=true
    84  
    85  // GatewayList contains a list of Gateway
    86  type GatewayList struct {
    87  	metav1.TypeMeta `json:",inline"`
    88  	metav1.ListMeta `json:"metadata,omitempty"`
    89  	Items           []Gateway `json:"items"`
    90  }
    91  
    92  func init() {
    93  	SchemeBuilder.Register(&Gateway{}, &GatewayList{})
    94  }