Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implicitly handle load balancers #274

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions pkg/cluster/config/v1alpha2/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type Config struct {
// TypeMeta representing the type of the object and its API schema version.
metav1.TypeMeta `json:",inline"`

// nodes constains the list of nodes defined in the `kind` Config
// Nodes constains the list of nodes defined in the `kind` Config
Nodes []Node `json:"nodes"`
}

Expand All @@ -39,7 +39,7 @@ type Node struct {
// Replicas is the number of desired node replicas.
// Defaults to 1
Replicas *int32 `json:"replicas,omitempty"`
// Role defines the role of the nodw in the in the Kubernetes cluster managed by `kind`
// Role defines the role of the node in the in the Kubernetes cluster managed by `kind`
// Defaults to "control-plane"
Role NodeRole `json:"role,omitempty"`
// Image is the node image to use when running the cluster
Expand Down Expand Up @@ -70,7 +70,7 @@ const (
ExternalEtcdRole NodeRole = "external-etcd"
// ExternalLoadBalancerRole identifies a node that hosts an external load balancer for API server
// in HA configurations.
// WARNING: this node type is not yet implemented!
// Please note that `kind` nodes hosting external load balancer are not kubernetes nodes
// If multiple control-plane nodes exists, a node with this role will be added automatically if missing.
// Please note that `kind` nodes hosting external load balancer are not Kubernetes nodes.
ExternalLoadBalancerRole NodeRole = "external-load-balancer"
)
2 changes: 1 addition & 1 deletion pkg/cluster/config/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func (c *Config) Validate() error {
// All nodes in the config should be valid
for i, n := range c.Nodes {
if err := n.Validate(); err != nil {
errs = append(errs, errors.Errorf("invalid configuration for node %d", i))
errs = append(errs, errors.Errorf("invalid configuration for node %d: %v", i, err))
}
}

Expand Down
11 changes: 11 additions & 0 deletions pkg/cluster/internal/create/derivedconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"sigs.k8s.io/kind/pkg/util"

"github.com/pkg/errors"
log "github.com/sirupsen/logrus"
)

// DerivedConfig contains config-like data computed from pkg/cluster/config.Config
Expand Down Expand Up @@ -141,6 +142,16 @@ func Derive(c *config.Config) (*DerivedConfig, error) {
}
}

// Add a load balancer automatically if one does not exists already and if the number
// of control plane nodes is more than one
if d.ExternalLoadBalancer() == nil && len(d.ControlPlanes()) > 1 {
n := config.Node{
Role: config.ExternalLoadBalancerRole,
Image: d.BootStrapControlPlane().Image, // should always return non-nil in this branch
}
log.Info("Automatically creating a load balancer node")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Call me picky, but I would log this as "Default load balancer node added". Just to stress that the user did not provide a LB configuration

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the current message seems better to me.
also we use present continuous tense.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem with tense. I wanted to stress the fact that the LB is created using default values, as it was not specified. "automatically" doesn't convey that information.

d.Add(&n)
}
return d, nil
}

Expand Down