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

Add a default NodeLabel with the InstanceGroup name #3783

Merged
Merged
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
1 change: 1 addition & 0 deletions cmd/kops/create_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -999,6 +999,7 @@ func RunCreateCluster(f *util.Factory, out io.Writer, c *CreateClusterOptions) e
if err != nil {
return err
}
fullGroup.AddInstanceGroupNodeLabel()
fullInstanceGroups = append(fullInstanceGroups, fullGroup)
}

Expand Down
3 changes: 3 additions & 0 deletions cmd/kops/create_ig.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ func RunCreateInstanceGroup(f *util.Factory, cmd *cobra.Command, args []string,
ig.Spec.Subnets = options.Subnets

ig, err = cloudup.PopulateInstanceGroupSpec(cluster, ig, channel)

ig.AddInstanceGroupNodeLabel()

if err != nil {
return err
}
Expand Down
13 changes: 13 additions & 0 deletions pkg/apis/kops/instancegroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ import (

const LabelClusterName = "kops.k8s.io/cluster"

// NodeLabelInstanceGroup is a node label set to the name of the instance group
const NodeLabelInstanceGroup = "kops.k8s.io/instancegroup"

// Deprecated - use the new labels & taints node-role.kubernetes.io/master and node-role.kubernetes.io/node
const TaintNoScheduleMaster15 = "dedicated=master:NoSchedule"

Expand Down Expand Up @@ -152,3 +155,13 @@ func (g *InstanceGroup) IsMaster() bool {
return false
}
}

func (g *InstanceGroup) AddInstanceGroupNodeLabel() {
if g.Spec.NodeLabels == nil {
nodeLabels := make(map[string]string)
nodeLabels[NodeLabelInstanceGroup] = g.Name
g.Spec.NodeLabels = nodeLabels
} else {
g.Spec.NodeLabels[NodeLabelInstanceGroup] = g.Name
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ spec:
machineType: m3.medium
maxSize: 1
minSize: 1
nodeLabels:
kops.k8s.io/instancegroup: master-us-test-1a
role: Master
subnets:
- us-test-1a
Expand All @@ -76,6 +78,8 @@ spec:
machineType: t2.medium
maxSize: 2
minSize: 2
nodeLabels:
kops.k8s.io/instancegroup: nodes
role: Node
subnets:
- us-test-1a
8 changes: 8 additions & 0 deletions tests/integration/create_cluster/ha/expected-v1alpha1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ spec:
machineType: m3.medium
maxSize: 1
minSize: 1
nodeLabels:
kops.k8s.io/instancegroup: master-us-test-1a
role: Master
zones:
- us-test-1a
Expand All @@ -84,6 +86,8 @@ spec:
machineType: m3.medium
maxSize: 1
minSize: 1
nodeLabels:
kops.k8s.io/instancegroup: master-us-test-1b
role: Master
zones:
- us-test-1b
Expand All @@ -102,6 +106,8 @@ spec:
machineType: m3.medium
maxSize: 1
minSize: 1
nodeLabels:
kops.k8s.io/instancegroup: master-us-test-1c
role: Master
zones:
- us-test-1c
Expand All @@ -120,6 +126,8 @@ spec:
machineType: t2.medium
maxSize: 2
minSize: 2
nodeLabels:
kops.k8s.io/instancegroup: nodes
role: Node
zones:
- us-test-1a
Expand Down
8 changes: 8 additions & 0 deletions tests/integration/create_cluster/ha/expected-v1alpha2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ spec:
machineType: m3.medium
maxSize: 1
minSize: 1
nodeLabels:
kops.k8s.io/instancegroup: master-us-test-1a
role: Master
subnets:
- us-test-1a
Expand All @@ -92,6 +94,8 @@ spec:
machineType: m3.medium
maxSize: 1
minSize: 1
nodeLabels:
kops.k8s.io/instancegroup: master-us-test-1b
role: Master
subnets:
- us-test-1b
Expand All @@ -110,6 +114,8 @@ spec:
machineType: m3.medium
maxSize: 1
minSize: 1
nodeLabels:
kops.k8s.io/instancegroup: master-us-test-1c
role: Master
subnets:
- us-test-1c
Expand All @@ -128,6 +134,8 @@ spec:
machineType: t2.medium
maxSize: 2
minSize: 2
nodeLabels:
kops.k8s.io/instancegroup: nodes
role: Node
subnets:
- us-test-1a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ spec:
machineType: m3.medium
maxSize: 1
minSize: 1
nodeLabels:
kops.k8s.io/instancegroup: master-us-test-1a
role: Master
zones:
- us-test-1a
Expand All @@ -90,6 +92,8 @@ spec:
machineType: m3.medium
maxSize: 1
minSize: 1
nodeLabels:
kops.k8s.io/instancegroup: master-us-test-1b
role: Master
zones:
- us-test-1b
Expand All @@ -108,6 +112,8 @@ spec:
machineType: m3.medium
maxSize: 1
minSize: 1
nodeLabels:
kops.k8s.io/instancegroup: master-us-test-1c
role: Master
zones:
- us-test-1c
Expand All @@ -126,6 +132,8 @@ spec:
machineType: t2.medium
maxSize: 2
minSize: 2
nodeLabels:
kops.k8s.io/instancegroup: nodes
role: Node
zones:
- us-test-1a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ spec:
machineType: m3.medium
maxSize: 1
minSize: 1
nodeLabels:
kops.k8s.io/instancegroup: master-us-test-1a
role: Master
subnets:
- us-test-1a
Expand All @@ -98,6 +100,8 @@ spec:
machineType: m3.medium
maxSize: 1
minSize: 1
nodeLabels:
kops.k8s.io/instancegroup: master-us-test-1b
role: Master
subnets:
- us-test-1b
Expand All @@ -116,6 +120,8 @@ spec:
machineType: m3.medium
maxSize: 1
minSize: 1
nodeLabels:
kops.k8s.io/instancegroup: master-us-test-1c
role: Master
subnets:
- us-test-1c
Expand All @@ -134,6 +140,8 @@ spec:
machineType: t2.medium
maxSize: 2
minSize: 2
nodeLabels:
kops.k8s.io/instancegroup: nodes
role: Node
subnets:
- us-test-1a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ spec:
machineType: n1-standard-1
maxSize: 1
minSize: 1
nodeLabels:
kops.k8s.io/instancegroup: master-us-test1-a
role: Master
subnets:
- us-test1
Expand All @@ -85,6 +87,8 @@ spec:
machineType: n1-standard-1
maxSize: 1
minSize: 1
nodeLabels:
kops.k8s.io/instancegroup: master-us-test1-b
role: Master
subnets:
- us-test1
Expand All @@ -105,6 +109,8 @@ spec:
machineType: n1-standard-1
maxSize: 1
minSize: 1
nodeLabels:
kops.k8s.io/instancegroup: master-us-test1-c
role: Master
subnets:
- us-test1
Expand All @@ -125,6 +131,8 @@ spec:
machineType: n1-standard-2
maxSize: 2
minSize: 2
nodeLabels:
kops.k8s.io/instancegroup: nodes
role: Node
subnets:
- us-test1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ spec:
machineType: m3.medium
maxSize: 1
minSize: 1
nodeLabels:
kops.k8s.io/instancegroup: master-us-test-1a-1
role: Master
subnets:
- us-test-1a
Expand All @@ -96,6 +98,8 @@ spec:
machineType: m3.medium
maxSize: 1
minSize: 1
nodeLabels:
kops.k8s.io/instancegroup: master-us-test-1a-2
role: Master
subnets:
- us-test-1a
Expand All @@ -114,6 +118,8 @@ spec:
machineType: m3.medium
maxSize: 1
minSize: 1
nodeLabels:
kops.k8s.io/instancegroup: master-us-test-1a-3
role: Master
subnets:
- us-test-1a
Expand All @@ -132,6 +138,8 @@ spec:
machineType: m3.medium
maxSize: 1
minSize: 1
nodeLabels:
kops.k8s.io/instancegroup: master-us-test-1b-1
role: Master
subnets:
- us-test-1b
Expand All @@ -150,6 +158,8 @@ spec:
machineType: m3.medium
maxSize: 1
minSize: 1
nodeLabels:
kops.k8s.io/instancegroup: master-us-test-1b-2
role: Master
subnets:
- us-test-1b
Expand All @@ -168,6 +178,8 @@ spec:
machineType: t2.medium
maxSize: 2
minSize: 2
nodeLabels:
kops.k8s.io/instancegroup: nodes
role: Node
subnets:
- us-test-1a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ spec:
machineType: m3.medium
maxSize: 1
minSize: 1
nodeLabels:
kops.k8s.io/instancegroup: master-us-test-1a
role: Master
zones:
- us-test-1a
Expand All @@ -72,6 +74,8 @@ spec:
machineType: t2.medium
maxSize: 2
minSize: 2
nodeLabels:
kops.k8s.io/instancegroup: nodes
role: Node
zones:
- us-test-1a
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ spec:
machineType: m3.medium
maxSize: 1
minSize: 1
nodeLabels:
kops.k8s.io/instancegroup: master-us-test-1a
role: Master
subnets:
- us-test-1a
Expand All @@ -76,6 +78,8 @@ spec:
machineType: t2.medium
maxSize: 2
minSize: 2
nodeLabels:
kops.k8s.io/instancegroup: nodes
role: Node
subnets:
- us-test-1a
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ spec:
machineType: t2.micro
maxSize: 1
minSize: 1
nodeLabels:
kops.k8s.io/instancegroup: bastions
role: Bastion
zones:
- utility-us-test-1a
Expand All @@ -78,6 +80,8 @@ spec:
machineType: m3.medium
maxSize: 1
minSize: 1
nodeLabels:
kops.k8s.io/instancegroup: master-us-test-1a
role: Master
zones:
- us-test-1a
Expand All @@ -96,6 +100,8 @@ spec:
machineType: t2.medium
maxSize: 2
minSize: 2
nodeLabels:
kops.k8s.io/instancegroup: nodes
role: Node
zones:
- us-test-1a
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ spec:
machineType: t2.micro
maxSize: 1
minSize: 1
nodeLabels:
kops.k8s.io/instancegroup: bastions
role: Bastion
subnets:
- utility-us-test-1a
Expand All @@ -84,6 +86,8 @@ spec:
machineType: m3.medium
maxSize: 1
minSize: 1
nodeLabels:
kops.k8s.io/instancegroup: master-us-test-1a
role: Master
subnets:
- us-test-1a
Expand All @@ -102,6 +106,8 @@ spec:
machineType: t2.medium
maxSize: 2
minSize: 2
nodeLabels:
kops.k8s.io/instancegroup: nodes
role: Node
subnets:
- us-test-1a
Loading