-
Notifications
You must be signed in to change notification settings - Fork 38
/
cluster.go
90 lines (77 loc) · 1.73 KB
/
cluster.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package cluster
import (
"github.com/awslabs/eksdemo/pkg/cmd"
"github.com/awslabs/eksdemo/pkg/eksctl"
"github.com/awslabs/eksdemo/pkg/resource"
"github.com/awslabs/eksdemo/pkg/resource/nodegroup"
"github.com/awslabs/eksdemo/pkg/template"
)
func NewResource() *resource.Resource {
res := &resource.Resource{
Command: cmd.Command{
Name: "cluster",
Description: "EKS Cluster",
Aliases: []string{"clusters"},
CreateArgs: []string{"NAME"},
Args: []string{"NAME"},
},
Getter: &Getter{},
Manager: &eksctl.ResourceManager{
Resource: "cluster",
ConfigTemplate: &template.TextTemplate{
Template: eksctl.EksctlHeader + EksctlTemplate + nodegroup.EksctlTemplate,
},
DeleteFlags: []string{"--disable-nodegroup-eviction"},
},
}
return addOptions(res)
}
const EksctlTemplate = `
addons:
- name: vpc-cni
version: latest
configurationValues: |-
{{- if and (ne .KubernetesVersion "1.24") (not .DisableNetworkPolicy) }}
enableNetworkPolicy: "true"
{{- end }}
env:
ENABLE_PREFIX_DELEGATION: {{ printf "%t" .PrefixAssignment | printf "%q" }}
{{- if .IPv6 }}
- name: coredns
- name: kube-proxy
{{- end }}
cloudWatch:
clusterLogging:
enableTypes: ["*"]
{{- if .Fargate }}
fargateProfiles:
- name: default
selectors:
- namespace: fargate
{{- end }}
{{- if not .NoRoles }}
iam:
withOIDC: true
serviceAccounts:
{{- range .IrsaRoles }}
{{- $.IrsaTemplate.Render .Options }}
{{- end }}
{{- end }}
{{- if .IPv6 }}
kubernetesNetworkConfig:
ipFamily: IPv6
{{- end }}
{{- if .Private }}
privateCluster:
enabled: true
{{- end }}
vpc:
cidr: {{ .VpcCidr }}
hostnameType: {{ .HostnameType }}
{{- if .Zones }}
availabilityZones:
{{- range .Zones }}
- {{.}}
{{- end }}
{{- end }}
`