Skip to content

Commit

Permalink
Kubernetes: add taints field to node pool create and update requests
Browse files Browse the repository at this point in the history
This change adds support for persistent node pool taints, a feature in
DOKS to associate Kubernetes taints with current and future nodes of a
pool.
  • Loading branch information
timoreimann committed Sep 21, 2020
1 parent f65aa7a commit 1c8fe6b
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,21 @@ type KubernetesClusterUpgradeRequest struct {
VersionSlug string `json:"version,omitempty"`
}

// Taint represents a Kubernetes taint that can be associated with a node pool
// (and, transitively, with all nodes of that pool).
type Taint struct {
Key string
Value string
Effect string
}

func (t Taint) String() string {
if t.Value == "" {
return fmt.Sprintf("%s:%s", t.Key, t.Effect)
}
return fmt.Sprintf("%s=%s:%s", t.Key, t.Value, t.Effect)
}

// KubernetesNodePoolCreateRequest represents a request to create a node pool for a
// Kubernetes cluster.
type KubernetesNodePoolCreateRequest struct {
Expand All @@ -91,6 +106,7 @@ type KubernetesNodePoolCreateRequest struct {
Count int `json:"count,omitempty"`
Tags []string `json:"tags,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
Taints []Taint `json:"taints,omitempty"`
AutoScale bool `json:"auto_scale,omitempty"`
MinNodes int `json:"min_nodes,omitempty"`
MaxNodes int `json:"max_nodes,omitempty"`
Expand All @@ -103,6 +119,7 @@ type KubernetesNodePoolUpdateRequest struct {
Count *int `json:"count,omitempty"`
Tags []string `json:"tags,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
Taints *[]Taint `json:"taints,omitempty"`
AutoScale *bool `json:"auto_scale,omitempty"`
MinNodes *int `json:"min_nodes,omitempty"`
MaxNodes *int `json:"max_nodes,omitempty"`
Expand Down Expand Up @@ -308,6 +325,7 @@ type KubernetesNodePool struct {
Count int `json:"count,omitempty"`
Tags []string `json:"tags,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
Taints []Taint `json:"taints,omitempty"`
AutoScale bool `json:"auto_scale,omitempty"`
MinNodes int `json:"min_nodes,omitempty"`
MaxNodes int `json:"max_nodes,omitempty"`
Expand Down

0 comments on commit 1c8fe6b

Please sign in to comment.