From 3e90c241e7868610c829249d52cc8ec98c909b59 Mon Sep 17 00:00:00 2001 From: Chuck Ha Date: Tue, 18 Jun 2019 10:42:25 -0400 Subject: [PATCH] Be careful with control-plane vs controlplane Signed-off-by: Chuck Ha --- capkactuators/machine.go | 8 +++++++- cmd/capkctl/main.go | 4 ++-- examples/simple-cluster.yaml | 3 +-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/capkactuators/machine.go b/capkactuators/machine.go index e734368..3b33259 100644 --- a/capkactuators/machine.go +++ b/capkactuators/machine.go @@ -34,6 +34,12 @@ import ( "sigs.k8s.io/kind/pkg/cluster/nodes" ) +const ( + // kind uses 'control-plane' and cluster-api uses 'controlplane'. Both use 'worker'. + + clusterAPIControlPlaneSetLabel = "controlplane" +) + type Machine struct { Core corev1.CoreV1Interface ClusterAPI v1alpha1.ClusterV1alpha1Interface @@ -69,7 +75,7 @@ func (m *Machine) Create(ctx context.Context, c *clusterv1.Cluster, machine *clu fmt.Printf("Is there a cluster? %v\n", clusterExists) setValue := getRole(machine) fmt.Printf("This node has a role of %q\n", setValue) - if setValue == constants.ControlPlaneNodeRoleValue { + if setValue == clusterAPIControlPlaneSetLabel { if len(controlPlanes) > 0 { fmt.Println("Adding a control plane") controlPlaneNode, err := actions.AddControlPlane(c.Name, machine.Spec.Versions.ControlPlane) diff --git a/cmd/capkctl/main.go b/cmd/capkctl/main.go index 90202e8..89d96bb 100644 --- a/cmd/capkctl/main.go +++ b/cmd/capkctl/main.go @@ -36,7 +36,7 @@ func (mo *machineOptions) initFlags(fs *flag.FlagSet) { mo.name = fs.String("name", "my-machine", "The name of the machine") mo.namespace = fs.String("namespace", "my-namespace", "The namespece of the machine") mo.clusterName = fs.String("cluster-name", "my-cluster", "The name of the cluster the machine belongs to") - mo.set = fs.String("set", "worker", "The role of the machine. Valid entries ['worker', 'control-plane']") + mo.set = fs.String("set", "worker", "The role of the machine. Valid entries ['worker', 'controlplane']") mo.version = fs.String("version", "v1.14.2", "The Kubernetes version to run") } @@ -53,7 +53,7 @@ func main() { controlPlane := flag.NewFlagSet("control-plane", flag.ExitOnError) controlPlaneOpts := new(machineOptions) controlPlaneOpts.initFlags(controlPlane) - *controlPlaneOpts.set = "control-plane" + *controlPlaneOpts.set = "controlplane" worker := flag.NewFlagSet("worker", flag.ExitOnError) workerOpts := new(machineOptions) diff --git a/examples/simple-cluster.yaml b/examples/simple-cluster.yaml index 848fa38..a95eccf 100644 --- a/examples/simple-cluster.yaml +++ b/examples/simple-cluster.yaml @@ -16,7 +16,6 @@ metadata: name: my-control-plane labels: cluster.k8s.io/cluster-name: my-cluster - annotations: set: "control-plane" spec: providerSpec: {} @@ -27,8 +26,8 @@ metadata: name: worker labels: cluster.k8s.io/cluster-name: my-cluster - annotations: set: "worker" + annotations: name: "my-cluster-worker" spec: providerSpec: {}