node.go 4.4 KB

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