github.com/annwntech/go-micro/v2@v2.9.5/util/kubernetes/client/types.go (about)

     1  package client
     2  
     3  // ContainerPort
     4  type ContainerPort struct {
     5  	Name          string `json:"name,omitempty"`
     6  	HostPort      int    `json:"hostPort,omitempty"`
     7  	ContainerPort int    `json:"containerPort"`
     8  	Protocol      string `json:"protocol,omitempty"`
     9  }
    10  
    11  // EnvVar is environment variable
    12  type EnvVar struct {
    13  	Name  string `json:"name"`
    14  	Value string `json:"value,omitempty"`
    15  }
    16  
    17  type Condition struct {
    18  	Started string `json:"startedAt,omitempty"`
    19  	Reason  string `json:"reason,omitempty"`
    20  	Message string `json:"message,omitempty"`
    21  }
    22  
    23  // Container defined container runtime values
    24  type Container struct {
    25  	Name    string          `json:"name"`
    26  	Image   string          `json:"image"`
    27  	Env     []EnvVar        `json:"env,omitempty"`
    28  	Command []string        `json:"command,omitempty"`
    29  	Args    []string        `json:"args,omitempty"`
    30  	Ports   []ContainerPort `json:"ports,omitempty"`
    31  }
    32  
    33  // DeploymentSpec defines micro deployment spec
    34  type DeploymentSpec struct {
    35  	Replicas int            `json:"replicas,omitempty"`
    36  	Selector *LabelSelector `json:"selector"`
    37  	Template *Template      `json:"template,omitempty"`
    38  }
    39  
    40  // DeploymentCondition describes the state of deployment
    41  type DeploymentCondition struct {
    42  	LastUpdateTime string `json:"lastUpdateTime"`
    43  	Type           string `json:"type"`
    44  	Reason         string `json:"reason,omitempty"`
    45  	Message        string `json:"message,omitempty"`
    46  }
    47  
    48  // DeploymentStatus is returned when querying deployment
    49  type DeploymentStatus struct {
    50  	Replicas            int                   `json:"replicas,omitempty"`
    51  	UpdatedReplicas     int                   `json:"updatedReplicas,omitempty"`
    52  	ReadyReplicas       int                   `json:"readyReplicas,omitempty"`
    53  	AvailableReplicas   int                   `json:"availableReplicas,omitempty"`
    54  	UnavailableReplicas int                   `json:"unavailableReplicas,omitempty"`
    55  	Conditions          []DeploymentCondition `json:"conditions,omitempty"`
    56  }
    57  
    58  // Deployment is Kubernetes deployment
    59  type Deployment struct {
    60  	Metadata *Metadata         `json:"metadata"`
    61  	Spec     *DeploymentSpec   `json:"spec,omitempty"`
    62  	Status   *DeploymentStatus `json:"status,omitempty"`
    63  }
    64  
    65  // DeploymentList
    66  type DeploymentList struct {
    67  	Items []Deployment `json:"items"`
    68  }
    69  
    70  // LabelSelector is a label query over a set of resources
    71  // NOTE: we do not support MatchExpressions at the moment
    72  type LabelSelector struct {
    73  	MatchLabels map[string]string `json:"matchLabels,omitempty"`
    74  }
    75  
    76  type LoadBalancerIngress struct {
    77  	IP       string `json:"ip,omitempty"`
    78  	Hostname string `json:"hostname,omitempty"`
    79  }
    80  
    81  type LoadBalancerStatus struct {
    82  	Ingress []LoadBalancerIngress `json:"ingress,omitempty"`
    83  }
    84  
    85  // Metadata defines api object metadata
    86  type Metadata struct {
    87  	Name        string            `json:"name,omitempty"`
    88  	Namespace   string            `json:"namespace,omitempty"`
    89  	Version     string            `json:"version,omitempty"`
    90  	Labels      map[string]string `json:"labels,omitempty"`
    91  	Annotations map[string]string `json:"annotations,omitempty"`
    92  }
    93  
    94  // PodSpec is a pod
    95  type PodSpec struct {
    96  	Containers         []Container `json:"containers"`
    97  	ServiceAccountName string      `json:"serviceAccountName"`
    98  }
    99  
   100  // PodList
   101  type PodList struct {
   102  	Items []Pod `json:"items"`
   103  }
   104  
   105  // Pod is the top level item for a pod
   106  type Pod struct {
   107  	Metadata *Metadata  `json:"metadata"`
   108  	Spec     *PodSpec   `json:"spec,omitempty"`
   109  	Status   *PodStatus `json:"status"`
   110  }
   111  
   112  // PodStatus
   113  type PodStatus struct {
   114  	Conditions []PodCondition    `json:"conditions,omitempty"`
   115  	Containers []ContainerStatus `json:"containerStatuses"`
   116  	PodIP      string            `json:"podIP"`
   117  	Phase      string            `json:"phase"`
   118  	Reason     string            `json:"reason"`
   119  }
   120  
   121  // PodCondition describes the state of pod
   122  type PodCondition struct {
   123  	Type    string `json:"type"`
   124  	Reason  string `json:"reason,omitempty"`
   125  	Message string `json:"message,omitempty"`
   126  }
   127  
   128  type ContainerStatus struct {
   129  	State ContainerState `json:"state"`
   130  }
   131  
   132  type ContainerState struct {
   133  	Running    *Condition `json:"running"`
   134  	Terminated *Condition `json:"terminated"`
   135  	Waiting    *Condition `json:"waiting"`
   136  }
   137  
   138  // Resource is API resource
   139  type Resource struct {
   140  	Name  string
   141  	Kind  string
   142  	Value interface{}
   143  }
   144  
   145  // ServicePort configures service ports
   146  type ServicePort struct {
   147  	Name     string `json:"name,omitempty"`
   148  	Port     int    `json:"port"`
   149  	Protocol string `json:"protocol,omitempty"`
   150  }
   151  
   152  // ServiceSpec provides service configuration
   153  type ServiceSpec struct {
   154  	ClusterIP string            `json:"clusterIP"`
   155  	Type      string            `json:"type,omitempty"`
   156  	Selector  map[string]string `json:"selector,omitempty"`
   157  	Ports     []ServicePort     `json:"ports,omitempty"`
   158  }
   159  
   160  // ServiceStatus
   161  type ServiceStatus struct {
   162  	LoadBalancer LoadBalancerStatus `json:"loadBalancer,omitempty"`
   163  }
   164  
   165  // Service is kubernetes service
   166  type Service struct {
   167  	Metadata *Metadata      `json:"metadata"`
   168  	Spec     *ServiceSpec   `json:"spec,omitempty"`
   169  	Status   *ServiceStatus `json:"status,omitempty"`
   170  }
   171  
   172  // ServiceList
   173  type ServiceList struct {
   174  	Items []Service `json:"items"`
   175  }
   176  
   177  // Template is micro deployment template
   178  type Template struct {
   179  	Metadata *Metadata `json:"metadata,omitempty"`
   180  	PodSpec  *PodSpec  `json:"spec,omitempty"`
   181  }
   182  
   183  // Namespace is a Kubernetes Namespace
   184  type Namespace struct {
   185  	Metadata *Metadata `json:"metadata,omitempty"`
   186  }
   187  
   188  // NamespaceList
   189  type NamespaceList struct {
   190  	Items []Namespace `json:"items"`
   191  }
   192  
   193  // ImagePullSecret
   194  type ImagePullSecret struct {
   195  	Name string `json:"name"`
   196  }
   197  
   198  // Secret
   199  type Secret struct {
   200  	Type     string            `json:"type,omitempty"`
   201  	Data     map[string]string `json:"data"`
   202  	Metadata *Metadata         `json:"metadata"`
   203  }
   204  
   205  // ServiceAccount
   206  type ServiceAccount struct {
   207  	Metadata         *Metadata         `json:"metadata,omitempty"`
   208  	ImagePullSecrets []ImagePullSecret `json:"imagePullSecrets,omitempty"`
   209  }