Skip to content

Commit

Permalink
remove deprecated node labels
Browse files Browse the repository at this point in the history
  • Loading branch information
BenTheElder committed Dec 5, 2019
1 parent 64d846a commit 903e600
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 19 deletions.
9 changes: 0 additions & 9 deletions pkg/cluster/internal/providers/docker/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,6 @@ package docker
// clusterLabelKey is applied to each "node" docker container for identification
const clusterLabelKey = "io.x-k8s.kind.cluster"

// deprecatedClusterLabelKey is applied to each "node" docker container for identification
// This is the deprecated value of ClusterLabelKey, and will be removed in a future release
const deprecatedClusterLabelKey = "io.k8s.sigs.kind.cluster"

// nodeRoleLabelKey is applied to each "node" docker container for categorization
// of nodes by role
const nodeRoleLabelKey = "io.x-k8s.kind.role"

// DeprecatedNodeRoleLabelKey is applied to each "node" docker container for categorization
// of nodes by role.
// This is the deprecated value of NodeRoleKey, and will be removed in a future release
const deprecatedNodeRoleLabelKey = "io.k8s.sigs.kind.role"
2 changes: 1 addition & 1 deletion pkg/cluster/internal/providers/docker/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (n *node) String() string {

func (n *node) Role() (string, error) {
cmd := exec.Command("docker", "inspect",
"--format", fmt.Sprintf(`{{ index .Config.Labels "%s"}}`, deprecatedNodeRoleLabelKey),
"--format", fmt.Sprintf(`{{ index .Config.Labels "%s"}}`, nodeRoleLabelKey),
n.name,
)
lines, err := exec.OutputLines(cmd)
Expand Down
10 changes: 5 additions & 5 deletions pkg/cluster/internal/providers/docker/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ import (
"sigs.k8s.io/kind/pkg/exec"
"sigs.k8s.io/kind/pkg/log"

"sigs.k8s.io/kind/pkg/cluster/nodeutils"
"sigs.k8s.io/kind/pkg/internal/apis/config"
"sigs.k8s.io/kind/pkg/cluster/internal/providers/provider"
"sigs.k8s.io/kind/pkg/cluster/internal/providers/provider/common"
"sigs.k8s.io/kind/pkg/cluster/nodeutils"
"sigs.k8s.io/kind/pkg/internal/apis/config"
"sigs.k8s.io/kind/pkg/internal/cli"
)

Expand Down Expand Up @@ -77,9 +77,9 @@ func (p *Provider) ListClusters() ([]string, error) {
"-a", // show stopped nodes
"--no-trunc", // don't truncate
// filter for nodes with the cluster label
"--filter", "label="+deprecatedClusterLabelKey,
"--filter", "label="+clusterLabelKey,
// format to include the cluster name
"--format", fmt.Sprintf(`{{.Label "%s"}}`, deprecatedClusterLabelKey),
"--format", fmt.Sprintf(`{{.Label "%s"}}`, clusterLabelKey),
)
lines, err := exec.OutputLines(cmd)
if err != nil {
Expand All @@ -96,7 +96,7 @@ func (p *Provider) ListNodes(cluster string) ([]nodes.Node, error) {
"-a", // show stopped nodes
"--no-trunc", // don't truncate
// filter for nodes with the cluster label
"--filter", fmt.Sprintf("label=%s=%s", deprecatedClusterLabelKey, cluster),
"--filter", fmt.Sprintf("label=%s=%s", clusterLabelKey, cluster),
// format to include the cluster name
"--format", `{{.Names}}`,
)
Expand Down
8 changes: 4 additions & 4 deletions pkg/cluster/internal/providers/docker/provision.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ import (
"sigs.k8s.io/kind/pkg/errors"
"sigs.k8s.io/kind/pkg/exec"

"sigs.k8s.io/kind/pkg/internal/apis/config"
"sigs.k8s.io/kind/pkg/cluster/internal/loadbalancer"
"sigs.k8s.io/kind/pkg/cluster/internal/providers/provider/common"
"sigs.k8s.io/kind/pkg/internal/apis/config"
)

// planCreation creates a slice of funcs that will create the containers
Expand Down Expand Up @@ -133,7 +133,7 @@ func commonArgs(cluster string, cfg *config.Cluster) ([]string, error) {
"--tty", // allocate a tty for entrypoint logs
// label the node with the cluster ID
"--label", fmt.Sprintf("%s=%s", clusterLabelKey, cluster),
"--label", fmt.Sprintf("%s=%s", deprecatedClusterLabelKey, cluster),
"--label", fmt.Sprintf("%s=%s", clusterLabelKey, cluster),
}

// enable IPv6 if necessary
Expand Down Expand Up @@ -164,7 +164,7 @@ func runArgsForNode(node *config.Node, name string, args []string) []string {
"--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", deprecatedNodeRoleLabelKey, node.Role),
"--label", fmt.Sprintf("%s=%s", nodeRoleLabelKey, node.Role),
// 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 Expand Up @@ -201,7 +201,7 @@ func runArgsForLoadBalancer(cfg *config.Cluster, name string, args []string) ([]
"--hostname", name, // make hostname match container name
"--name", name, // ... and set the container name
// label the node with the role ID
"--label", fmt.Sprintf("%s=%s", deprecatedNodeRoleLabelKey, constants.ExternalLoadBalancerNodeRoleValue),
"--label", fmt.Sprintf("%s=%s", nodeRoleLabelKey, constants.ExternalLoadBalancerNodeRoleValue),
"--label", fmt.Sprintf("%s=%s", nodeRoleLabelKey, constants.ExternalLoadBalancerNodeRoleValue),
},
args...,
Expand Down

0 comments on commit 903e600

Please sign in to comment.