Skip to content
This repository has been archived by the owner on Sep 30, 2020. It is now read-only.

Commit

Permalink
Merge pull request #128 from mumoshu/exp-feat-consistency-for-node-pools
Browse files Browse the repository at this point in the history
Add several experimental features already introduced to main clusters to node pools
  • Loading branch information
mumoshu authored Dec 7, 2016
2 parents bd33d1f + feee27d commit a0a9352
Show file tree
Hide file tree
Showing 5 changed files with 330 additions and 1 deletion.
122 changes: 122 additions & 0 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1000,6 +1000,43 @@ func TestConfig(t *testing.T) {
}
}

hasDefaultExperimentalFeatures := func(c *Cluster, t *testing.T) {
expected := Experimental{
AuditLog: AuditLog{
Enabled: false,
MaxAge: 30,
LogPath: "/dev/stdout",
},
AwsEnvironment: AwsEnvironment{
Enabled: false,
},
EphemeralImageStorage: EphemeralImageStorage{
Enabled: false,
Disk: "xvdb",
Filesystem: "xfs",
},
LoadBalancer: LoadBalancer{
Enabled: false,
},
NodeDrainer: NodeDrainer{
Enabled: false,
},
NodeLabel: NodeLabel{
Enabled: false,
},
WaitSignal: WaitSignal{
Enabled: false,
MaxBatchSize: 1,
},
}

actual := c.Experimental

if !reflect.DeepEqual(expected, actual) {
t.Errorf("experimental settings didn't match :\nexpected=%v\nactual=%v", expected, actual)
}
}

minimalValidConfigYaml := minimalConfigYaml + `
availabilityZone: us-west-1c
`
Expand All @@ -1008,11 +1045,92 @@ availabilityZone: us-west-1c
configYaml string
assertConfig []ConfigTester
}{
{
context: "WithExperimentalFeatures",
configYaml: minimalValidConfigYaml + `
experimental:
auditLog:
enabled: true
maxage: 100
logpath: "/var/log/audit.log"
awsEnvironment:
enabled: true
environment:
CFNSTACK: '{ "Ref" : "AWS::StackId" }'
ephemeralImageStorage:
enabled: true
loadBalancer:
enabled: true
names:
- manuallymanagedlb
securityGroupIds:
- sg-12345678
nodeDrainer:
enabled: true
nodeLabel:
enabled: true
plugins:
rbac:
enabled: true
waitSignal:
enabled: true
`,
assertConfig: []ConfigTester{
hasDefaultEtcdSettings,
func(c *Cluster, t *testing.T) {
expected := Experimental{
AuditLog: AuditLog{
Enabled: true,
MaxAge: 100,
LogPath: "/var/log/audit.log",
},
AwsEnvironment: AwsEnvironment{
Enabled: true,
Environment: map[string]string{
"CFNSTACK": `{ "Ref" : "AWS::StackId" }`,
},
},
EphemeralImageStorage: EphemeralImageStorage{
Enabled: true,
Disk: "xvdb",
Filesystem: "xfs",
},
LoadBalancer: LoadBalancer{
Enabled: true,
Names: []string{"manuallymanagedlb"},
SecurityGroupIds: []string{"sg-12345678"},
},
NodeDrainer: NodeDrainer{
Enabled: true,
},
NodeLabel: NodeLabel{
Enabled: true,
},
Plugins: Plugins{
Rbac: Rbac{
Enabled: true,
},
},
WaitSignal: WaitSignal{
Enabled: true,
MaxBatchSize: 1,
},
}

actual := c.Experimental

if !reflect.DeepEqual(expected, actual) {
t.Errorf("experimental settings didn't match : expected=%v actual=%v", expected, actual)
}
},
},
},
{
context: "WithMinimalValidConfig",
configYaml: minimalValidConfigYaml,
assertConfig: []ConfigTester{
hasDefaultEtcdSettings,
hasDefaultExperimentalFeatures,
},
},
{
Expand All @@ -1022,6 +1140,7 @@ vpcId: vpc-1a2b3c4d
`,
assertConfig: []ConfigTester{
hasDefaultEtcdSettings,
hasDefaultExperimentalFeatures,
},
},
{
Expand All @@ -1032,6 +1151,7 @@ routeTableId: rtb-1a2b3c4d
`,
assertConfig: []ConfigTester{
hasDefaultEtcdSettings,
hasDefaultExperimentalFeatures,
},
},
{
Expand All @@ -1045,6 +1165,7 @@ workerSecurityGroupIds:
`,
assertConfig: []ConfigTester{
hasDefaultEtcdSettings,
hasDefaultExperimentalFeatures,
func(c *Cluster, t *testing.T) {
expectedWorkerSecurityGroupIds := []string{
`sg-12345678`, `sg-abcdefab`, `sg-23456789`, `sg-bcdefabc`,
Expand Down Expand Up @@ -1115,6 +1236,7 @@ etcdDataVolumeType: io1
etcdDataVolumeIOPS: 104
`,
assertConfig: []ConfigTester{
hasDefaultExperimentalFeatures,
func(c *Cluster, t *testing.T) {
expected := EtcdSettings{
EtcdCount: 2,
Expand Down
113 changes: 113 additions & 0 deletions nodepool/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package config
import (
"fmt"
"github.com/aws/aws-sdk-go/service/kms"
cfg "github.com/coreos/kube-aws/config"
"github.com/coreos/kube-aws/test/helper"
"reflect"
"strings"
Expand Down Expand Up @@ -72,15 +73,121 @@ etcdEndpoints: "10.0.0.1"
}
}

hasDefaultExperimentalFeatures := func(c *ProvidedConfig, t *testing.T) {
expected := cfg.Experimental{
AuditLog: cfg.AuditLog{
Enabled: false,
MaxAge: 30,
LogPath: "/dev/stdout",
},
AwsEnvironment: cfg.AwsEnvironment{
Enabled: false,
},
EphemeralImageStorage: cfg.EphemeralImageStorage{
Enabled: false,
Disk: "xvdb",
Filesystem: "xfs",
},
LoadBalancer: cfg.LoadBalancer{
Enabled: false,
},
NodeDrainer: cfg.NodeDrainer{
Enabled: false,
},
NodeLabel: cfg.NodeLabel{
Enabled: false,
},
WaitSignal: cfg.WaitSignal{
Enabled: false,
MaxBatchSize: 1,
},
}

actual := c.Experimental

if !reflect.DeepEqual(expected, actual) {
t.Errorf("experimental settings didn't match :\nexpected=%v\nactual=%v", expected, actual)
}
}

validCases := []struct {
context string
configYaml string
assertProvidedConfig []ConfigTester
}{
{
context: "WithExperimentalFeatures",
configYaml: minimalValidConfigYaml + `
experimental:
awsEnvironment:
enabled: true
environment:
CFNSTACK: '{ "Ref" : "AWS::StackId" }'
ephemeralImageStorage:
enabled: true
loadBalancer:
enabled: true
names:
- manuallymanagedlb
securityGroupIds:
- sg-12345678
nodeDrainer:
enabled: true
nodeLabel:
enabled: true
waitSignal:
enabled: true
`,
assertProvidedConfig: []ConfigTester{
hasDefaultLaunchSpecifications,
func(c *ProvidedConfig, t *testing.T) {
expected := cfg.Experimental{
AuditLog: cfg.AuditLog{
Enabled: false,
MaxAge: 30,
LogPath: "/dev/stdout",
},
AwsEnvironment: cfg.AwsEnvironment{
Enabled: true,
Environment: map[string]string{
"CFNSTACK": `{ "Ref" : "AWS::StackId" }`,
},
},
EphemeralImageStorage: cfg.EphemeralImageStorage{
Enabled: true,
Disk: "xvdb",
Filesystem: "xfs",
},
LoadBalancer: cfg.LoadBalancer{
Enabled: true,
Names: []string{"manuallymanagedlb"},
SecurityGroupIds: []string{"sg-12345678"},
},
NodeDrainer: cfg.NodeDrainer{
Enabled: true,
},
NodeLabel: cfg.NodeLabel{
Enabled: true,
},
WaitSignal: cfg.WaitSignal{
Enabled: true,
MaxBatchSize: 1,
},
}

actual := c.Experimental

if !reflect.DeepEqual(expected, actual) {
t.Errorf("experimental settings didn't match : expected=%v actual=%v", expected, actual)
}
},
},
},
{
context: "WithMinimalValidConfig",
configYaml: minimalValidConfigYaml,
assertProvidedConfig: []ConfigTester{
hasDefaultExperimentalFeatures,
hasDefaultLaunchSpecifications,
}},
{
Expand All @@ -89,6 +196,7 @@ etcdEndpoints: "10.0.0.1"
vpcId: vpc-1a2b3c4d
`,
assertProvidedConfig: []ConfigTester{
hasDefaultExperimentalFeatures,
hasDefaultLaunchSpecifications,
},
},
Expand All @@ -99,6 +207,7 @@ vpcId: vpc-1a2b3c4d
routeTableId: rtb-1a2b3c4d
`,
assertProvidedConfig: []ConfigTester{
hasDefaultExperimentalFeatures,
hasDefaultLaunchSpecifications,
},
},
Expand All @@ -110,6 +219,7 @@ worker:
targetCapacity: 10
`,
assertProvidedConfig: []ConfigTester{
hasDefaultExperimentalFeatures,
hasDefaultLaunchSpecifications,
},
},
Expand All @@ -128,6 +238,7 @@ worker:
rootVolumeSize: 100
`,
assertProvidedConfig: []ConfigTester{
hasDefaultExperimentalFeatures,
func(c *ProvidedConfig, t *testing.T) {
expected := []LaunchSpecification{
{
Expand Down Expand Up @@ -175,6 +286,7 @@ worker:
rootVolumeIOPS: 500
`,
assertProvidedConfig: []ConfigTester{
hasDefaultExperimentalFeatures,
func(c *ProvidedConfig, t *testing.T) {
expected := []LaunchSpecification{
{
Expand Down Expand Up @@ -217,6 +329,7 @@ workerSecurityGroupIds:
- sg-bcdefabc
`,
assertProvidedConfig: []ConfigTester{
hasDefaultExperimentalFeatures,
hasDefaultLaunchSpecifications,
func(c *ProvidedConfig, t *testing.T) {
expectedWorkerSecurityGroupIds := []string{
Expand Down
8 changes: 8 additions & 0 deletions nodepool/config/templates/cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,18 @@ useCalico: {{.UseCalico}}
# experimental:
# nodeDrainer:
# enabled: true
# nodeLabel:
# enabled: true
# awsEnvironment:
# enabled: true
# environment:
# CFNSTACK: '{ "Ref" : "AWS::StackId" }'
# waitSignal:
# enabled: true
# loadBalancer:
# enabled: true
# names: [ "manuallymanagedelb" ]
# securityGroupIds: [ "sg-87654321" ]

# AWS Tags for cloudformation stack resources
#stackTags:
Expand Down
Loading

0 comments on commit a0a9352

Please sign in to comment.