Skip to content

Commit

Permalink
Add node status to API object (all versions).
Browse files Browse the repository at this point in the history
  • Loading branch information
ddysher committed Dec 11, 2014
1 parent 5523e03 commit 0332c8d
Show file tree
Hide file tree
Showing 6 changed files with 228 additions and 0 deletions.
48 changes: 48 additions & 0 deletions pkg/api/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,54 @@ type NodeSpec struct {
type NodeStatus struct {
// Queried from cloud provider, if available.
HostIP string `json:"hostIP,omitempty"`
// NodePhase is the current lifecycle phase of the node.
Phase NodePhase `json:"phase,omitempty"`
// Conditions is an array of current node conditions.
Conditions []NodeCondition `json:"conditions,omitempty"`
}

type NodePhase string

// These are the valid phases of node.
const (
// NodePending means the node has been created/added by the system, but not configured.
NodePending NodePhase = "Pending"
// NodeRunning means the node has been configured and has Kubernetes components running.
NodeRunning NodePhase = "Running"
// NodeTerminated means the node has been removed from the cluster.
NodeTerminated NodePhase = "Terminated"
)

type NodeConditionKind string

// These are valid conditions of node. Currently, we don't have enough information to decide
// node condition. In the future, we will add more. The proposed set of conditions are:
// NodeReachable, NodeLive, NodeReady, NodeSchedulable, NodeRunnable.
const (
// NodeReachable means the node can be reached (in the sense of HTTP connection) from node controller.
NodeReachable NodeConditionKind = "Reachable"
// NodeReady means the node returns StatusOK for HTTP health check.
NodeReady NodeConditionKind = "Ready"
)

type NodeConditionStatus string

// These are valid condition status. "ConditionFull" means node is in the condition;
// "ConditionNone" means node is not in the condition; "ConditionUnknown" means kubernetes
// can't decide if node is in the condition or not. In the future, we could add other
// intermediate conditions, e.g. ConditionDegraded.
const (
ConditionFull NodeConditionStatus = "Full"
ConditionNone NodeConditionStatus = "None"
ConditionUnknown NodeConditionStatus = "Unknown"
)

type NodeCondition struct {
Kind NodeConditionKind `json:"kind"`
Status NodeConditionStatus `json:"status"`
LastTransitionTime util.Time `json:"lastTransitionTime,omitempty"`
Reason string `json:"reason,omitempty"`
Message string `json:"message,omitempty"`
}

// NodeResources is an object for conveying resource information about a node.
Expand Down
12 changes: 12 additions & 0 deletions pkg/api/v1beta1/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,12 @@ func init() {
if err := s.Convert(&in.ObjectMeta.Labels, &out.Labels, 0); err != nil {
return err
}
if err := s.Convert(&in.Status.Phase, &out.Status.Phase, 0); err != nil {
return err
}
if err := s.Convert(&in.Status.Conditions, &out.Status.Conditions, 0); err != nil {
return err
}

out.HostIP = in.Status.HostIP
return s.Convert(&in.Spec.Capacity, &out.NodeResources.Capacity, 0)
Expand All @@ -468,6 +474,12 @@ func init() {
if err := s.Convert(&in.Labels, &out.ObjectMeta.Labels, 0); err != nil {
return err
}
if err := s.Convert(&in.Status.Phase, &out.Status.Phase, 0); err != nil {
return err
}
if err := s.Convert(&in.Status.Conditions, &out.Status.Conditions, 0); err != nil {
return err
}

out.Status.HostIP = in.HostIP
return s.Convert(&in.NodeResources.Capacity, &out.Spec.Capacity, 0)
Expand Down
54 changes: 54 additions & 0 deletions pkg/api/v1beta1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,58 @@ type EndpointsList struct {
Items []Endpoints `json:"items" description:"list of service endpoint lists"`
}

// NodeStatus is information about the current status of a node.
type NodeStatus struct {
// NodePhase is the current lifecycle phase of the node.
Phase NodePhase `json:"phase,omitempty" description:"node phase is the current lifecycle phase of the node"`
// Conditions is an array of current node conditions.
Conditions []NodeCondition `json:"conditions,omitempty" description:"conditions is an array of current node conditions"`
}

type NodePhase string

// These are the valid phases of node.
const (
// NodePending means the node has been created/added by the system, but not configured.
NodePending NodePhase = "Pending"
// NodeRunning means the node has been configured and has Kubernetes components running.
NodeRunning NodePhase = "Running"
// NodeTerminated means the node has been removed from the cluster.
NodeTerminated NodePhase = "Terminated"
)

type NodeConditionKind string

// These are valid conditions of node. Currently, we don't have enough information to decide
// node condition. In the future, we will add more. The proposed set of conditions are:
// NodeReachable, NodeLive, NodeReady, NodeSchedulable, NodeRunnable.
const (
// NodeReachable means the node can be reached (in the sense of HTTP connection) from node controller.
NodeReachable NodeConditionKind = "Reachable"
// NodeReady means the node returns StatusOK for HTTP health check.
NodeReady NodeConditionKind = "Ready"
)

type NodeConditionStatus string

// These are valid condition status. "ConditionFull" means node is in the condition;
// "ConditionNone" means node is not in the condition; "ConditionUnknown" means kubernetes
// can't decide if node is in the condition or not. In the future, we could add other
// intermediate conditions, e.g. ConditionDegraded.
const (
ConditionFull NodeConditionStatus = "Full"
ConditionNone NodeConditionStatus = "None"
ConditionUnknown NodeConditionStatus = "Unknown"
)

type NodeCondition struct {
Kind NodeConditionKind `json:"kind" description:"kind of the condition, one of reachable, ready"`
Status NodeConditionStatus `json:"status" description:"status of the condition, one of full, none, unknown"`
LastTransitionTime util.Time `json:"lastTransitionTime,omitempty" description:"last time the condition transit from one status to another"`
Reason string `json:"reason,omitempty" description:"(brief) reason for the condition's last transition"`
Message string `json:"message,omitempty" description:"human readable message indicating details about last transition"`
}

// NodeResources represents resources on a Kubernetes system node
// see https://github.com/GoogleCloudPlatform/kubernetes/blob/master/docs/resources.md for more details.
type NodeResources struct {
Expand All @@ -520,6 +572,8 @@ type Minion struct {
HostIP string `json:"hostIP,omitempty" description:"IP address of the node"`
// Resources available on the node
NodeResources NodeResources `json:"resources,omitempty" description:"characterization of node resources"`
// Status describes the current status of a node
Status NodeStatus `json:"status,omitempty" description:"current status of node"`
// Labels for the node
Labels map[string]string `json:"labels,omitempty" description:"map of string keys and values that can be used to organize and categorize minions; labels of a minion assigned by the scheduler must match the scheduled pod's nodeSelector"`
}
Expand Down
12 changes: 12 additions & 0 deletions pkg/api/v1beta2/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,12 @@ func init() {
if err := s.Convert(&in.ObjectMeta.Labels, &out.Labels, 0); err != nil {
return err
}
if err := s.Convert(&in.Status.Phase, &out.Status.Phase, 0); err != nil {
return err
}
if err := s.Convert(&in.Status.Conditions, &out.Status.Conditions, 0); err != nil {
return err
}

out.HostIP = in.Status.HostIP
return s.Convert(&in.Spec.Capacity, &out.NodeResources.Capacity, 0)
Expand All @@ -398,6 +404,12 @@ func init() {
if err := s.Convert(&in.Labels, &out.ObjectMeta.Labels, 0); err != nil {
return err
}
if err := s.Convert(&in.Status.Phase, &out.Status.Phase, 0); err != nil {
return err
}
if err := s.Convert(&in.Status.Conditions, &out.Status.Conditions, 0); err != nil {
return err
}

out.Status.HostIP = in.HostIP
return s.Convert(&in.NodeResources.Capacity, &out.Spec.Capacity, 0)
Expand Down
54 changes: 54 additions & 0 deletions pkg/api/v1beta2/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,58 @@ type EndpointsList struct {
Items []Endpoints `json:"items" description:"list of service endpoint lists"`
}

// NodeStatus is information about the current status of a node.
type NodeStatus struct {
// NodePhase is the current lifecycle phase of the node.
Phase NodePhase `json:"phase,omitempty" description:"node phase is the current lifecycle phase of the node"`
// Conditions is an array of current node conditions.
Conditions []NodeCondition `json:"conditions,omitempty" description:"conditions is an array of current node conditions"`
}

type NodePhase string

// These are the valid phases of node.
const (
// NodePending means the node has been created/added by the system, but not configured.
NodePending NodePhase = "Pending"
// NodeRunning means the node has been configured and has Kubernetes components running.
NodeRunning NodePhase = "Running"
// NodeTerminated means the node has been removed from the cluster.
NodeTerminated NodePhase = "Terminated"
)

type NodeConditionKind string

// These are valid conditions of node. Currently, we don't have enough information to decide
// node condition. In the future, we will add more. The proposed set of conditions are:
// NodeReachable, NodeLive, NodeReady, NodeSchedulable, NodeRunnable.
const (
// NodeReachable means the node can be reached (in the sense of HTTP connection) from node controller.
NodeReachable NodeConditionKind = "Reachable"
// NodeReady means the node returns StatusOK for HTTP health check.
NodeReady NodeConditionKind = "Ready"
)

type NodeConditionStatus string

// These are valid condition status. "ConditionFull" means node is in the condition;
// "ConditionNone" means node is not in the condition; "ConditionUnknown" means kubernetes
// can't decide if node is in the condition or not. In the future, we could add other
// intermediate conditions, e.g. ConditionDegraded.
const (
ConditionFull NodeConditionStatus = "Full"
ConditionNone NodeConditionStatus = "None"
ConditionUnknown NodeConditionStatus = "Unknown"
)

type NodeCondition struct {
Kind NodeConditionKind `json:"kind" description:"kind of the condition, one of reachable, ready"`
Status NodeConditionStatus `json:"status" description:"status of the condition, one of full, none, unknown"`
LastTransitionTime util.Time `json:"lastTransitionTime,omitempty" description:"last time the condition transit from one status to another"`
Reason string `json:"reason,omitempty" description:"(brief) reason for the condition's last transition"`
Message string `json:"message,omitempty" description:"human readable message indicating details about last transition"`
}

// NodeResources represents resources on a Kubernetes system node
// see https://github.com/GoogleCloudPlatform/kubernetes/blob/master/docs/resources.md for more details.
type NodeResources struct {
Expand All @@ -485,6 +537,8 @@ type Minion struct {
HostIP string `json:"hostIP,omitempty" description:"IP address of the node"`
// Resources available on the node
NodeResources NodeResources `json:"resources,omitempty" description:"characterization of node resources"`
// Status describes the current status of a node
Status NodeStatus `json:"status,omitempty" description:"current status of node"`
// Labels for the node
Labels map[string]string `json:"labels,omitempty" description:"map of string keys and values that can be used to organize and categorize minions; labels of a minion assigned by the scheduler must match the scheduled pod's nodeSelector"`
}
Expand Down
48 changes: 48 additions & 0 deletions pkg/api/v1beta3/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,54 @@ type NodeSpec struct {
type NodeStatus struct {
// Queried from cloud provider, if available.
HostIP string `json:"hostIP,omitempty"`
// NodePhase is the current lifecycle phase of the node.
Phase NodePhase `json:"phase,omitempty"`
// Conditions is an array of current node conditions.
Conditions []NodeCondition `json:"conditions,omitempty"`
}

type NodePhase string

// These are the valid phases of node.
const (
// NodePending means the node has been created/added by the system, but not configured.
NodePending NodePhase = "Pending"
// NodeRunning means the node has been configured and has Kubernetes components running.
NodeRunning NodePhase = "Running"
// NodeTerminated means the node has been removed from the cluster.
NodeTerminated NodePhase = "Terminated"
)

type NodeConditionKind string

// These are valid conditions of node. Currently, we don't have enough information to decide
// node condition. In the future, we will add more. The proposed set of conditions are:
// NodeReachable, NodeLive, NodeReady, NodeSchedulable, NodeRunnable.
const (
// NodeReachable means the node can be reached (in the sense of HTTP connection) from node controller.
NodeReachable NodeConditionKind = "Reachable"
// NodeReady means the node returns StatusOK for HTTP health check.
NodeReady NodeConditionKind = "Ready"
)

type NodeConditionStatus string

// These are valid condition status. "ConditionFull" means node is in the condition;
// "ConditionNone" means node is not in the condition; "ConditionUnknown" means kubernetes
// can't decide if node is in the condition or not. In the future, we could add other
// intermediate conditions, e.g. ConditionDegraded.
const (
ConditionFull NodeConditionStatus = "Full"
ConditionNone NodeConditionStatus = "None"
ConditionUnknown NodeConditionStatus = "Unknown"
)

type NodeCondition struct {
Kind NodeConditionKind `json:"kind"`
Status NodeConditionStatus `json:"status"`
LastTransitionTime util.Time `json:"lastTransitionTime,omitempty"`
Reason string `json:"reason,omitempty"`
Message string `json:"message,omitempty"`
}

type ResourceName string
Expand Down

0 comments on commit 0332c8d

Please sign in to comment.