Skip to content

Commit

Permalink
Build fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Neil Jerram committed Mar 2, 2021
1 parent ecfe5e2 commit b9597b1
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 9 deletions.
8 changes: 8 additions & 0 deletions pkg/apis/config/v1alpha4/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,14 @@ type Node struct {
// The node-level patches will be applied after the cluster-level patches
// have been applied. (See Cluster.KubeadmConfigPatchesJSON6902)
KubeadmConfigPatchesJSON6902 []PatchJSON6902 `yaml:"kubeadmConfigPatchesJSON6902,omitempty"`

// Docker networks to attach to. Defaults to the Docker default ("bridge").
Networks []string

// Loopback IP.
Loopback string

Routes []string
}

// NodeRole defines possible role for nodes in a Kubernetes cluster managed by `kind`
Expand Down
3 changes: 0 additions & 3 deletions pkg/cluster/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ package constants
// DefaultClusterName is the default cluster Context name
const DefaultClusterName = "kind"

const NodeLoopbackKey = "io.k8s.sigs.kind.loopback"
const NodeRoutesKey = "io.k8s.sigs.kind.routes"

/* node role value constants */
const (
// ControlPlaneNodeRoleValue identifies a node that hosts a Kubernetes
Expand Down
5 changes: 3 additions & 2 deletions pkg/cluster/internal/create/actions/loopback/loopback.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ package loopback

import (
"fmt"
"sigs.k8s.io/kind/pkg/errors"
"sigs.k8s.io/kind/pkg/internal/cluster/create/actions"
"strings"

"sigs.k8s.io/kind/pkg/cluster/internal/create/actions"
"sigs.k8s.io/kind/pkg/errors"
)

// kubeadmInitAction implements action for executing the kubadm init
Expand Down
2 changes: 2 additions & 0 deletions pkg/cluster/internal/providers/docker/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ const clusterLabelKey = "io.x-k8s.kind.cluster"
// nodeRoleLabelKey is applied to each "node" docker container for categorization
// of nodes by role
const nodeRoleLabelKey = "io.x-k8s.kind.role"
const nodeLoopbackKey = "io.x-k8s.kind.loopback"
const nodeRoutesKey = "io.x-k8s.kind.routes"
4 changes: 2 additions & 2 deletions pkg/cluster/internal/providers/docker/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func (n *node) Role() (string, error) {

func (n *node) Loopback() (string, error) {
cmd := exec.Command("docker", "inspect",
"--format", fmt.Sprintf(`{{ index .Config.Labels "%s"}}`, constants.NodeLoopbackKey),
"--format", fmt.Sprintf(`{{ index .Config.Labels "%s"}}`, nodeLoopbackKey),
n.name,
)
lines, err := exec.OutputLines(cmd)
Expand All @@ -67,7 +67,7 @@ func (n *node) Loopback() (string, error) {

func (n *node) Routes() (string, error) {
cmd := exec.Command("docker", "inspect",
"--format", fmt.Sprintf(`{{ index .Config.Labels "%s"}}`, constants.NodeRoutesKey),
"--format", fmt.Sprintf(`{{ index .Config.Labels "%s"}}`, nodeRoutesKey),
n.name,
)
lines, err := exec.OutputLines(cmd)
Expand Down
4 changes: 2 additions & 2 deletions pkg/cluster/internal/providers/docker/provision.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,8 @@ func runArgsForNode(node *config.Node, clusterIPFamily config.ClusterIPFamily, n
"--name", name, // ... and set the container name
// label the node with the role ID
"--label", fmt.Sprintf("%s=%s", nodeRoleLabelKey, node.Role),
"--label", fmt.Sprintf("%s=%s", constants.NodeLoopbackKey, node.Loopback),
"--label", fmt.Sprintf("%s=%s", constants.NodeRoutesKey, strings.Join(node.Routes, ",")),
"--label", fmt.Sprintf("%s=%s", nodeLoopbackKey, node.Loopback),
"--label", fmt.Sprintf("%s=%s", nodeRoutesKey, strings.Join(node.Routes, ",")),
// running containers in a container requires privileged
// NOTE: we could try to replicate this with --cap-add, and use less
// privileges, but this flag also changes some mounts that are necessary
Expand Down
8 changes: 8 additions & 0 deletions pkg/cluster/internal/providers/podman/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ func (n *node) Role() (string, error) {
return lines[0], nil
}

func (n *node) Loopback() (string, error) {
return "", errors.New("unimplemented")
}

func (n *node) Routes() (string, error) {
return "", errors.New("unimplemented")
}

func (n *node) IP() (ipv4 string, ipv6 string, err error) {
// retrieve the IP address of the node using podman inspect
cmd := exec.Command("podman", "inspect",
Expand Down

0 comments on commit b9597b1

Please sign in to comment.