Skip to content

Commit 55839d9

Browse files
committed
Make authenticationMode:CONFIG_MAP default on Outposts
1 parent 2ca7b65 commit 55839d9

File tree

4 files changed

+62
-2
lines changed

4 files changed

+62
-2
lines changed

pkg/apis/eksctl.io/v1alpha5/defaults.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ func SetClusterConfigDefaults(cfg *ClusterConfig) {
5656

5757
if cfg.AccessConfig == nil {
5858
cfg.AccessConfig = &AccessConfig{
59-
AuthenticationMode: ekstypes.AuthenticationModeApiAndConfigMap,
59+
AuthenticationMode: getDefaultAuthenticationMode(cfg.IsControlPlaneOnOutposts()),
6060
}
6161
} else if cfg.AccessConfig.AuthenticationMode == "" {
62-
cfg.AccessConfig.AuthenticationMode = ekstypes.AuthenticationModeApiAndConfigMap
62+
cfg.AccessConfig.AuthenticationMode = getDefaultAuthenticationMode(cfg.IsControlPlaneOnOutposts())
6363
}
6464

6565
if cfg.PrivateCluster == nil {
@@ -244,6 +244,13 @@ func getDefaultVolumeType(nodeGroupOnOutposts bool) string {
244244
return DefaultNodeVolumeType
245245
}
246246

247+
func getDefaultAuthenticationMode(nodeGroupOnOutposts bool) ekstypes.AuthenticationMode {
248+
if nodeGroupOnOutposts {
249+
return ekstypes.AuthenticationModeConfigMap
250+
}
251+
return ekstypes.AuthenticationModeApiAndConfigMap
252+
}
253+
247254
func setContainerRuntimeDefault(ng *NodeGroup, clusterVersion string) {
248255
if ng.ContainerRuntime != nil {
249256
return

pkg/apis/eksctl.io/v1alpha5/defaults_test.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import (
44
"github.com/aws/aws-sdk-go-v2/aws"
55
. "github.com/onsi/ginkgo/v2"
66
. "github.com/onsi/gomega"
7+
8+
ekstypes "github.com/aws/aws-sdk-go-v2/service/eks/types"
79
)
810

911
var _ = Describe("ClusterConfig validation", func() {
@@ -327,6 +329,29 @@ var _ = Describe("ClusterConfig validation", func() {
327329

328330
})
329331

332+
Context("Authentication Mode", func() {
333+
var (
334+
cfg *ClusterConfig
335+
)
336+
337+
BeforeEach(func() {
338+
cfg = NewClusterConfig()
339+
})
340+
341+
It("should be set to API_AND_CONFIG_MAP by default", func() {
342+
SetClusterConfigDefaults(cfg)
343+
Expect(cfg.AccessConfig.AuthenticationMode).To(Equal(ekstypes.AuthenticationModeApiAndConfigMap))
344+
})
345+
346+
It("should be set to CONFIG_MAP when control plane is on outposts", func() {
347+
cfg.Outpost = &Outpost{
348+
ControlPlaneOutpostARN: "arn:aws:outposts:us-west-2:1234:outpost/op-1234",
349+
}
350+
SetClusterConfigDefaults(cfg)
351+
Expect(cfg.AccessConfig.AuthenticationMode).To(Equal(ekstypes.AuthenticationModeConfigMap))
352+
})
353+
})
354+
330355
Describe("ClusterConfig", func() {
331356
var cfg *ClusterConfig
332357

pkg/apis/eksctl.io/v1alpha5/outposts_validation_test.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ import (
66
. "github.com/onsi/ginkgo/v2"
77
. "github.com/onsi/gomega"
88

9+
"github.com/aws/aws-sdk-go-v2/aws"
10+
ekstypes "github.com/aws/aws-sdk-go-v2/service/eks/types"
11+
912
api "github.com/weaveworks/eksctl/pkg/apis/eksctl.io/v1alpha5"
1013
)
1114

@@ -22,10 +25,29 @@ var _ = Describe("Outposts validation", func() {
2225
clusterConfig.Outpost = &api.Outpost{
2326
ControlPlaneOutpostARN: "arn:aws:outposts:us-west-2:1234:outpost/op-1234",
2427
}
28+
api.SetClusterConfigDefaults(clusterConfig)
2529
oe.updateDefaultConfig(clusterConfig)
2630
err := api.ValidateClusterConfig(clusterConfig)
2731
Expect(err).To(MatchError(ContainSubstring(oe.expectedErr)))
2832
},
33+
Entry("Authentication Mode - API", outpostsEntry{
34+
updateDefaultConfig: func(c *api.ClusterConfig) {
35+
c.AccessConfig.AuthenticationMode = ekstypes.AuthenticationModeApi
36+
},
37+
expectedErr: fmt.Sprintf("accessConfig.AuthenticationMode must be set to %s on Outposts", ekstypes.AuthenticationModeConfigMap),
38+
}),
39+
Entry("Authentication mode - API_AND_CONFIG_MAP", outpostsEntry{
40+
updateDefaultConfig: func(c *api.ClusterConfig) {
41+
c.AccessConfig.AuthenticationMode = ekstypes.AuthenticationModeApiAndConfigMap
42+
},
43+
expectedErr: fmt.Sprintf("accessConfig.AuthenticationMode must be set to %s on Outposts", ekstypes.AuthenticationModeConfigMap),
44+
}),
45+
Entry("BootstrapClusterCreatorAdminPermissions - false", outpostsEntry{
46+
updateDefaultConfig: func(c *api.ClusterConfig) {
47+
c.AccessConfig.BootstrapClusterCreatorAdminPermissions = aws.Bool(false)
48+
},
49+
expectedErr: "accessConfig.BootstrapClusterCreatorAdminPermissions can't be set to false on Outposts",
50+
}),
2951
Entry("Addons", outpostsEntry{
3052
updateDefaultConfig: func(c *api.ClusterConfig) {
3153
c.Addons = []*api.Addon{

pkg/apis/eksctl.io/v1alpha5/validation.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,12 @@ func ValidateClusterConfig(cfg *ClusterConfig) error {
153153
return err
154154
}
155155

156+
if cfg.AccessConfig.AuthenticationMode != ekstypes.AuthenticationModeConfigMap {
157+
return fmt.Errorf("accessConfig.AuthenticationMode must be set to %s on Outposts", ekstypes.AuthenticationModeConfigMap)
158+
}
159+
if IsDisabled(cfg.AccessConfig.BootstrapClusterCreatorAdminPermissions) {
160+
return fmt.Errorf("accessConfig.BootstrapClusterCreatorAdminPermissions can't be set to false on Outposts")
161+
}
156162
if cfg.IPv6Enabled() {
157163
return errors.New("IPv6 is not supported on Outposts")
158164
}

0 commit comments

Comments
 (0)