mirror of https://github.com/kubernetes/kops.git
Move the instancegroup role into NodeupConfig
This commit is contained in:
parent
8c3b4e4f43
commit
a5f5acc09d
|
@ -66,9 +66,7 @@ func (c *NodeupModelContext) Init() error {
|
||||||
}
|
}
|
||||||
c.kubernetesVersion = *k8sVersion
|
c.kubernetesVersion = *k8sVersion
|
||||||
|
|
||||||
if c.InstanceGroup == nil {
|
if c.NodeupConfig.InstanceGroupRole == kops.InstanceGroupRoleMaster {
|
||||||
klog.Warningf("cannot determine role, InstanceGroup not set")
|
|
||||||
} else if c.InstanceGroup.Spec.Role == kops.InstanceGroupRoleMaster {
|
|
||||||
c.IsMaster = true
|
c.IsMaster = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,7 @@ func (f *FileAssetsBuilder) Build(c *fi.ModelBuilderContext) error {
|
||||||
func (f *FileAssetsBuilder) buildFileAssets(c *fi.ModelBuilderContext, assets []kops.FileAssetSpec, tracker map[string]bool) error {
|
func (f *FileAssetsBuilder) buildFileAssets(c *fi.ModelBuilderContext, assets []kops.FileAssetSpec, tracker map[string]bool) error {
|
||||||
for _, asset := range assets {
|
for _, asset := range assets {
|
||||||
// @check if the file asset applies to us. If no roles applied we assume its applied to all roles
|
// @check if the file asset applies to us. If no roles applied we assume its applied to all roles
|
||||||
if len(asset.Roles) > 0 && !containsRole(f.InstanceGroup.Spec.Role, asset.Roles) {
|
if len(asset.Roles) > 0 && !containsRole(f.NodeupConfig.InstanceGroupRole, asset.Roles) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
// @check if e have a path and if not use the default path
|
// @check if e have a path and if not use the default path
|
||||||
|
|
|
@ -44,7 +44,7 @@ func (h *HookBuilder) Build(c *fi.ModelBuilderContext) error {
|
||||||
for j, hook := range *spec {
|
for j, hook := range *spec {
|
||||||
isInstanceGroup := i == 0
|
isInstanceGroup := i == 0
|
||||||
// filter roles if required
|
// filter roles if required
|
||||||
if len(hook.Roles) > 0 && !containsRole(h.InstanceGroup.Spec.Role, hook.Roles) {
|
if len(hook.Roles) > 0 && !containsRole(h.NodeupConfig.InstanceGroupRole, hook.Roles) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ import (
|
||||||
"k8s.io/klog"
|
"k8s.io/klog"
|
||||||
"k8s.io/kops/nodeup/pkg/distros"
|
"k8s.io/kops/nodeup/pkg/distros"
|
||||||
"k8s.io/kops/pkg/apis/kops"
|
"k8s.io/kops/pkg/apis/kops"
|
||||||
|
"k8s.io/kops/pkg/apis/nodeup"
|
||||||
"k8s.io/kops/pkg/assets"
|
"k8s.io/kops/pkg/assets"
|
||||||
"k8s.io/kops/pkg/client/simple/vfsclientset"
|
"k8s.io/kops/pkg/client/simple/vfsclientset"
|
||||||
"k8s.io/kops/pkg/pki"
|
"k8s.io/kops/pkg/pki"
|
||||||
|
@ -48,6 +49,7 @@ func Test_InstanceGroupKubeletMerge(t *testing.T) {
|
||||||
&NodeupModelContext{
|
&NodeupModelContext{
|
||||||
Cluster: cluster,
|
Cluster: cluster,
|
||||||
InstanceGroup: instanceGroup,
|
InstanceGroup: instanceGroup,
|
||||||
|
NodeupConfig: nodeup.NewConfig(cluster, instanceGroup),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
if err := b.Init(); err != nil {
|
if err := b.Init(); err != nil {
|
||||||
|
@ -91,6 +93,7 @@ func TestTaintsApplied(t *testing.T) {
|
||||||
&NodeupModelContext{
|
&NodeupModelContext{
|
||||||
Cluster: cluster,
|
Cluster: cluster,
|
||||||
InstanceGroup: ig,
|
InstanceGroup: ig,
|
||||||
|
NodeupConfig: nodeup.NewConfig(cluster, ig),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
if err := b.Init(); err != nil {
|
if err := b.Init(); err != nil {
|
||||||
|
@ -205,12 +208,14 @@ func BuildNodeupModelContext(basedir string) (*NodeupModelContext, error) {
|
||||||
Cluster: model.Cluster,
|
Cluster: model.Cluster,
|
||||||
Architecture: "amd64",
|
Architecture: "amd64",
|
||||||
Distribution: distros.DistributionXenial,
|
Distribution: distros.DistributionXenial,
|
||||||
|
NodeupConfig: &nodeup.Config{},
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(model.InstanceGroups) == 0 {
|
if len(model.InstanceGroups) == 0 {
|
||||||
// We tolerate this - not all tests need an instance group
|
// We tolerate this - not all tests need an instance group
|
||||||
} else if len(model.InstanceGroups) == 1 {
|
} else if len(model.InstanceGroups) == 1 {
|
||||||
nodeUpModelContext.InstanceGroup = model.InstanceGroups[0]
|
nodeUpModelContext.InstanceGroup = model.InstanceGroups[0]
|
||||||
|
nodeUpModelContext.NodeupConfig = nodeup.NewConfig(model.Cluster, nodeUpModelContext.InstanceGroup)
|
||||||
} else {
|
} else {
|
||||||
return nil, fmt.Errorf("unexpected number of instance groups in %s, found %d", basedir, len(model.InstanceGroups))
|
return nil, fmt.Errorf("unexpected number of instance groups in %s, found %d", basedir, len(model.InstanceGroups))
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,4 +5,5 @@ go_library(
|
||||||
srcs = ["config.go"],
|
srcs = ["config.go"],
|
||||||
importpath = "k8s.io/kops/pkg/apis/nodeup",
|
importpath = "k8s.io/kops/pkg/apis/nodeup",
|
||||||
visibility = ["//visibility:public"],
|
visibility = ["//visibility:public"],
|
||||||
|
deps = ["//pkg/apis/kops:go_default_library"],
|
||||||
)
|
)
|
||||||
|
|
|
@ -16,6 +16,8 @@ limitations under the License.
|
||||||
|
|
||||||
package nodeup
|
package nodeup
|
||||||
|
|
||||||
|
import "k8s.io/kops/pkg/apis/kops"
|
||||||
|
|
||||||
// Config is the configuration for the nodeup binary
|
// Config is the configuration for the nodeup binary
|
||||||
type Config struct {
|
type Config struct {
|
||||||
// Tags enable/disable chunks of the model
|
// Tags enable/disable chunks of the model
|
||||||
|
@ -31,6 +33,8 @@ type Config struct {
|
||||||
ClusterLocation *string `json:",omitempty"`
|
ClusterLocation *string `json:",omitempty"`
|
||||||
// InstanceGroupName is the name of the instance group
|
// InstanceGroupName is the name of the instance group
|
||||||
InstanceGroupName string `json:",omitempty"`
|
InstanceGroupName string `json:",omitempty"`
|
||||||
|
// InstanceGroupRole is the instance group role.
|
||||||
|
InstanceGroupRole kops.InstanceGroupRole
|
||||||
// ClusterName is the name of the cluster
|
// ClusterName is the name of the cluster
|
||||||
ClusterName string `json:",omitempty"`
|
ClusterName string `json:",omitempty"`
|
||||||
// ProtokubeImage is the docker image to load for protokube (bootstrapping)
|
// ProtokubeImage is the docker image to load for protokube (bootstrapping)
|
||||||
|
@ -63,3 +67,9 @@ type StaticManifest struct {
|
||||||
// Path is the path to the manifest
|
// Path is the path to the manifest
|
||||||
Path string `json:"path,omitempty"`
|
Path string `json:"path,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewConfig(cluster *kops.Cluster, instanceGroup *kops.InstanceGroup) *Config {
|
||||||
|
return &Config{
|
||||||
|
InstanceGroupRole: instanceGroup.Spec.Role,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -114,7 +114,7 @@ func TestBootstrapUserData(t *testing.T) {
|
||||||
group := makeTestInstanceGroup(x.Role, x.HookSpecRoles, x.FileAssetSpecRoles)
|
group := makeTestInstanceGroup(x.Role, x.HookSpecRoles, x.FileAssetSpecRoles)
|
||||||
|
|
||||||
renderNodeUpConfig := func(ig *kops.InstanceGroup) (*nodeup.Config, error) {
|
renderNodeUpConfig := func(ig *kops.InstanceGroup) (*nodeup.Config, error) {
|
||||||
return &nodeup.Config{}, nil
|
return nodeup.NewConfig(cluster, ig), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
bs := &BootstrapScript{
|
bs := &BootstrapScript{
|
||||||
|
|
|
@ -1254,7 +1254,7 @@ func (c *ApplyClusterCmd) BuildNodeUpConfig(assetBuilder *assets.AssetBuilder, i
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
config := &nodeup.Config{}
|
config := nodeup.NewConfig(cluster, ig)
|
||||||
config.Tags = append(config.Tags, nodeUpTags.List()...)
|
config.Tags = append(config.Tags, nodeUpTags.List()...)
|
||||||
|
|
||||||
for _, a := range c.Assets {
|
for _, a := range c.Assets {
|
||||||
|
|
Loading…
Reference in New Issue