github.com/rumpl/bof@v23.0.0-rc.2+incompatible/api/types/swarm/node.go (about)

     1  package swarm // import "github.com/docker/docker/api/types/swarm"
     2  
     3  // Node represents a node.
     4  type Node struct {
     5  	ID string
     6  	Meta
     7  	// Spec defines the desired state of the node as specified by the user.
     8  	// The system will honor this and will *never* modify it.
     9  	Spec NodeSpec `json:",omitempty"`
    10  	// Description encapsulates the properties of the Node as reported by the
    11  	// agent.
    12  	Description NodeDescription `json:",omitempty"`
    13  	// Status provides the current status of the node, as seen by the manager.
    14  	Status NodeStatus `json:",omitempty"`
    15  	// ManagerStatus provides the current status of the node's manager
    16  	// component, if the node is a manager.
    17  	ManagerStatus *ManagerStatus `json:",omitempty"`
    18  }
    19  
    20  // NodeSpec represents the spec of a node.
    21  type NodeSpec struct {
    22  	Annotations
    23  	Role         NodeRole         `json:",omitempty"`
    24  	Availability NodeAvailability `json:",omitempty"`
    25  }
    26  
    27  // NodeRole represents the role of a node.
    28  type NodeRole string
    29  
    30  const (
    31  	// NodeRoleWorker WORKER
    32  	NodeRoleWorker NodeRole = "worker"
    33  	// NodeRoleManager MANAGER
    34  	NodeRoleManager NodeRole = "manager"
    35  )
    36  
    37  // NodeAvailability represents the availability of a node.
    38  type NodeAvailability string
    39  
    40  const (
    41  	// NodeAvailabilityActive ACTIVE
    42  	NodeAvailabilityActive NodeAvailability = "active"
    43  	// NodeAvailabilityPause PAUSE
    44  	NodeAvailabilityPause NodeAvailability = "pause"
    45  	// NodeAvailabilityDrain DRAIN
    46  	NodeAvailabilityDrain NodeAvailability = "drain"
    47  )
    48  
    49  // NodeDescription represents the description of a node.
    50  type NodeDescription struct {
    51  	Hostname  string            `json:",omitempty"`
    52  	Platform  Platform          `json:",omitempty"`
    53  	Resources Resources         `json:",omitempty"`
    54  	Engine    EngineDescription `json:",omitempty"`
    55  	TLSInfo   TLSInfo           `json:",omitempty"`
    56  	CSIInfo   []NodeCSIInfo     `json:",omitempty"`
    57  }
    58  
    59  // Platform represents the platform (Arch/OS).
    60  type Platform struct {
    61  	Architecture string `json:",omitempty"`
    62  	OS           string `json:",omitempty"`
    63  }
    64  
    65  // EngineDescription represents the description of an engine.
    66  type EngineDescription struct {
    67  	EngineVersion string              `json:",omitempty"`
    68  	Labels        map[string]string   `json:",omitempty"`
    69  	Plugins       []PluginDescription `json:",omitempty"`
    70  }
    71  
    72  // NodeCSIInfo represents information about a CSI plugin available on the node
    73  type NodeCSIInfo struct {
    74  	// PluginName is the name of the CSI plugin.
    75  	PluginName string `json:",omitempty"`
    76  	// NodeID is the ID of the node as reported by the CSI plugin. This is
    77  	// different from the swarm node ID.
    78  	NodeID string `json:",omitempty"`
    79  	// MaxVolumesPerNode is the maximum number of volumes that may be published
    80  	// to this node
    81  	MaxVolumesPerNode int64 `json:",omitempty"`
    82  	// AccessibleTopology indicates the location of this node in the CSI
    83  	// plugin's topology
    84  	AccessibleTopology *Topology `json:",omitempty"`
    85  }
    86  
    87  // PluginDescription represents the description of an engine plugin.
    88  type PluginDescription struct {
    89  	Type string `json:",omitempty"`
    90  	Name string `json:",omitempty"`
    91  }
    92  
    93  // NodeStatus represents the status of a node.
    94  type NodeStatus struct {
    95  	State   NodeState `json:",omitempty"`
    96  	Message string    `json:",omitempty"`
    97  	Addr    string    `json:",omitempty"`
    98  }
    99  
   100  // Reachability represents the reachability of a node.
   101  type Reachability string
   102  
   103  const (
   104  	// ReachabilityUnknown UNKNOWN
   105  	ReachabilityUnknown Reachability = "unknown"
   106  	// ReachabilityUnreachable UNREACHABLE
   107  	ReachabilityUnreachable Reachability = "unreachable"
   108  	// ReachabilityReachable REACHABLE
   109  	ReachabilityReachable Reachability = "reachable"
   110  )
   111  
   112  // ManagerStatus represents the status of a manager.
   113  type ManagerStatus struct {
   114  	Leader       bool         `json:",omitempty"`
   115  	Reachability Reachability `json:",omitempty"`
   116  	Addr         string       `json:",omitempty"`
   117  }
   118  
   119  // NodeState represents the state of a node.
   120  type NodeState string
   121  
   122  const (
   123  	// NodeStateUnknown UNKNOWN
   124  	NodeStateUnknown NodeState = "unknown"
   125  	// NodeStateDown DOWN
   126  	NodeStateDown NodeState = "down"
   127  	// NodeStateReady READY
   128  	NodeStateReady NodeState = "ready"
   129  	// NodeStateDisconnected DISCONNECTED
   130  	NodeStateDisconnected NodeState = "disconnected"
   131  )
   132  
   133  // Topology defines the CSI topology of this node. This type is a duplicate of
   134  // github.com/docker/docker/api/types.Topology. Because the type definition
   135  // is so simple and to avoid complicated structure or circular imports, we just
   136  // duplicate it here. See that type for full documentation
   137  type Topology struct {
   138  	Segments map[string]string `json:",omitempty"`
   139  }