gitee.com/liuxuezhan/go-micro-v1.18.0@v1.0.0/runtime/kubernetes/client/types.go (about)

     1  package client
     2  
     3  // Resource is API resource
     4  type Resource struct {
     5  	Name  string
     6  	Kind  string
     7  	Value interface{}
     8  }
     9  
    10  // Metadata defines api object metadata
    11  type Metadata struct {
    12  	Name        string            `json:"name,omitempty"`
    13  	Namespace   string            `json:"namespace,omitempty"`
    14  	Version     string            `json:"version,omitempty"`
    15  	Labels      map[string]string `json:"labels,omitempty"`
    16  	Annotations map[string]string `json:"annotations,omitempty"`
    17  }
    18  
    19  // ServicePort configures service ports
    20  type ServicePort struct {
    21  	Name     string `json:"name,omitempty"`
    22  	Port     int    `json:"port"`
    23  	Protocol string `json:"protocol,omitempty"`
    24  }
    25  
    26  // ServiceSpec provides service configuration
    27  type ServiceSpec struct {
    28  	Type     string            `json:"type,omitempty"`
    29  	Selector map[string]string `json:"selector,omitempty"`
    30  	Ports    []ServicePort     `json:"ports,omitempty"`
    31  }
    32  
    33  type LoadBalancerIngress struct {
    34  	IP       string `json:"ip,omitempty"`
    35  	Hostname string `json:"hostname,omitempty"`
    36  }
    37  
    38  type LoadBalancerStatus struct {
    39  	Ingress []LoadBalancerIngress `json:"ingress,omitempty"`
    40  }
    41  
    42  // ServiceStatus
    43  type ServiceStatus struct {
    44  	LoadBalancer LoadBalancerStatus `json:"loadBalancer,omitempty"`
    45  }
    46  
    47  // Service is kubernetes service
    48  type Service struct {
    49  	Metadata *Metadata      `json:"metadata"`
    50  	Spec     *ServiceSpec   `json:"spec,omitempty"`
    51  	Status   *ServiceStatus `json:"status,omitempty"`
    52  }
    53  
    54  // ServiceList
    55  type ServiceList struct {
    56  	Items []Service `json:"items"`
    57  }
    58  
    59  // ContainerPort
    60  type ContainerPort struct {
    61  	Name          string `json:"name,omitempty"`
    62  	HostPort      int    `json:"hostPort,omitempty"`
    63  	ContainerPort int    `json:"containerPort"`
    64  	Protocol      string `json:"protocol,omitempty"`
    65  }
    66  
    67  // EnvVar is environment variable
    68  type EnvVar struct {
    69  	Name  string `json:"name"`
    70  	Value string `json:"value,omitempty"`
    71  }
    72  
    73  // Container defined container runtime values
    74  type Container struct {
    75  	Name    string          `json:"name"`
    76  	Image   string          `json:"image"`
    77  	Env     []EnvVar        `json:"env,omitempty"`
    78  	Command []string        `json:"command,omitempty"`
    79  	Ports   []ContainerPort `json:"ports,omitempty"`
    80  }
    81  
    82  // PodSpec
    83  type PodSpec struct {
    84  	Containers []Container `json:"containers"`
    85  }
    86  
    87  // Template is micro deployment template
    88  type Template struct {
    89  	Metadata *Metadata `json:"metadata,omitempty"`
    90  	PodSpec  *PodSpec  `json:"spec,omitempty"`
    91  }
    92  
    93  // LabelSelector is a label query over a set of resources
    94  // NOTE: we do not support MatchExpressions at the moment
    95  type LabelSelector struct {
    96  	MatchLabels map[string]string `json:"matchLabels,omitempty"`
    97  }
    98  
    99  // DeploymentSpec defines micro deployment spec
   100  type DeploymentSpec struct {
   101  	Replicas int            `json:"replicas,omitempty"`
   102  	Selector *LabelSelector `json:"selector"`
   103  	Template *Template      `json:"template,omitempty"`
   104  }
   105  
   106  // DeploymentCondition describes the state of deployment
   107  type DeploymentCondition struct {
   108  	Type    string `json:"type"`
   109  	Reason  string `json:"reason,omitempty"`
   110  	Message string `json:"message,omitempty"`
   111  }
   112  
   113  // DeploymentStatus is returned when querying deployment
   114  type DeploymentStatus struct {
   115  	Replicas            int                   `json:"replicas,omitempty"`
   116  	UpdatedReplicas     int                   `json:"updatedReplicas,omitempty"`
   117  	ReadyReplicas       int                   `json:"readyReplicas,omitempty"`
   118  	AvailableReplicas   int                   `json:"availableReplicas,omitempty"`
   119  	UnavailableReplicas int                   `json:"unavailableReplicas,omitempty"`
   120  	Conditions          []DeploymentCondition `json:"conditions,omitempty"`
   121  }
   122  
   123  // Deployment is Kubernetes deployment
   124  type Deployment struct {
   125  	Metadata *Metadata         `json:"metadata"`
   126  	Spec     *DeploymentSpec   `json:"spec,omitempty"`
   127  	Status   *DeploymentStatus `json:"status,omitempty"`
   128  }
   129  
   130  // DeploymentList
   131  type DeploymentList struct {
   132  	Items []Deployment `json:"items"`
   133  }