Skip to content

Commit

Permalink
Start EKS test infra (#209)
Browse files Browse the repository at this point in the history
* added EKS terraform set up

* add generator config

* fix security groups config

* add EKS cluster policy

* try to fix eks cluster startup issue

* fix provider

* try fixing connection refused error

* iterating

* add more k8s configs

* add cluster auth config

* add namespace and depends chaining

* fix namespace config

* add label selector

* added basic eks test runner

* fix terraform

* add node group

* add aws auth config

* syntax

* Fix syntax

* try to get node groups to attach in example

* fix syntax

* try running cwa

* fix resource creation order

* add logging?

* add cwagent test policy to node

* use managed policy

* update docs, implement validation

* update cluster and node naming

* fix test to query ClusterName properly

* add license header

* make fmt for terraform

* add todos, update doc for EKS permissions, formatting

* reintroduce node role in terraform

* update from minor code review comments

---------

Co-authored-by: Andrew Huynh <[email protected]>
  • Loading branch information
SaxyPandaBear and Andrew Huynh authored May 9, 2023
1 parent 737cef1 commit c0de3c1
Show file tree
Hide file tree
Showing 16 changed files with 913 additions and 218 deletions.
401 changes: 206 additions & 195 deletions docs/getting-start.md

Large diffs are not rendered by default.

37 changes: 24 additions & 13 deletions environment/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type MetaData struct {
S3Key string
CwaCommitSha string
CaCertPath string
EKSClusterName string
}

type MetaDataStrings struct {
Expand All @@ -41,6 +42,7 @@ type MetaDataStrings struct {
S3Key string
CwaCommitSha string
CaCertPath string
EKSClusterName string
}

func registerComputeType(dataString *MetaDataStrings) {
Expand All @@ -67,22 +69,25 @@ func registerECSData(dataString *MetaDataStrings) {
flag.StringVar(&(dataString.EcsServiceName), "cwagentECSServiceName", "", "Used to restart ecs task to apply new agent config")
}

func registerEKSData(d *MetaDataStrings) {
flag.StringVar(&(d.EKSClusterName), "eksClusterName", "", "EKS cluster name")
}

func registerPluginTestsToExecute(dataString *MetaDataStrings) {
flag.StringVar(&(dataString.EC2PluginTests), "plugins", "", "Comma-delimited list of plugins to test. Default is empty, which tests all")
}

func fillComputeType(e *MetaData, data *MetaDataStrings) *MetaData {
func fillComputeType(e *MetaData, data *MetaDataStrings) {
computeType, ok := computetype.FromString(data.ComputeType)
if !ok {
log.Panic("Invalid compute type. Needs to be EC2/ECS/EKS. Compute Type is a required flag. :" + data.ComputeType)
}
e.ComputeType = computeType
return e
}

func fillECSData(e *MetaData, data *MetaDataStrings) *MetaData {
func fillECSData(e *MetaData, data *MetaDataStrings) {
if e.ComputeType != computetype.ECS {
return e
return
}

ecsLaunchType, ok := ecslaunchtype.FromString(data.EcsLaunchType)
Expand All @@ -103,18 +108,16 @@ func fillECSData(e *MetaData, data *MetaDataStrings) *MetaData {
e.CwagentConfigSsmParamName = data.CwagentConfigSsmParamName
e.EcsServiceName = data.EcsServiceName
e.EcsClusterName = awsservice.GetClusterName(data.EcsClusterArn)

return e
}

func fillEC2PluginTests(e *MetaData, data *MetaDataStrings) *MetaData {
func fillEC2PluginTests(e *MetaData, data *MetaDataStrings) {
if e.ComputeType != computetype.EC2 {
return e
return
}

if len(data.EC2PluginTests) == 0 {
log.Println("Testing all EC2 plugins")
return e
return
}

plugins := strings.Split(strings.ReplaceAll(data.EC2PluginTests, " ", ""), ",")
Expand All @@ -124,13 +127,20 @@ func fillEC2PluginTests(e *MetaData, data *MetaDataStrings) *MetaData {
m[strings.ToLower(p)] = struct{}{}
}
e.EC2PluginTests = m
}

func fillEKSData(e *MetaData, data *MetaDataStrings) {
if e.ComputeType != computetype.EKS {
return
}

return e
e.EKSClusterName = data.EKSClusterName
}

func RegisterEnvironmentMetaDataFlags(metaDataStrings *MetaDataStrings) *MetaDataStrings {
registerComputeType(metaDataStrings)
registerECSData(metaDataStrings)
registerEKSData(metaDataStrings)
registerBucket(metaDataStrings)
registerS3Key(metaDataStrings)
registerCwaCommitSha(metaDataStrings)
Expand All @@ -141,9 +151,10 @@ func RegisterEnvironmentMetaDataFlags(metaDataStrings *MetaDataStrings) *MetaDat

func GetEnvironmentMetaData(data *MetaDataStrings) *MetaData {
metaData := &(MetaData{})
metaData = fillComputeType(metaData, data)
metaData = fillECSData(metaData, data)
metaData = fillEC2PluginTests(metaData, data)
fillComputeType(metaData, data)
fillECSData(metaData, data)
fillEKSData(metaData, data)
fillEC2PluginTests(metaData, data)
metaData.Bucket = data.Bucket
metaData.S3Key = data.S3Key
metaData.CwaCommitSha = data.CwaCommitSha
Expand Down
5 changes: 5 additions & 0 deletions generator/resources/eks_daemon_test_matrix.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[
{

}
]
3 changes: 3 additions & 0 deletions generator/test_case_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ var testTypeToTestDirMap = map[string][]string{
"ec2_acceptance": {
"./test/acceptance",
},
"eks_daemon": {
"./test/metric_value_benchmark",
},
}

func main() {
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
collectd.org v0.5.0
github.com/DataDog/datadog-go v4.8.3+incompatible
github.com/aws/aws-sdk-go v1.44.188
github.com/aws/aws-sdk-go-v2 v1.17.4
github.com/aws/aws-sdk-go-v2 v1.18.0
github.com/aws/aws-sdk-go-v2/config v1.18.10
github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue v1.10.0
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.21
Expand Down Expand Up @@ -38,8 +38,8 @@ require (
github.com/Microsoft/go-winio v0.6.0 // indirect
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.10 // indirect
github.com/aws/aws-sdk-go-v2/credentials v1.13.10 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.28 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.22 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.33 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.27 // indirect
github.com/aws/aws-sdk-go-v2/internal/ini v1.3.28 // indirect
github.com/aws/aws-sdk-go-v2/internal/v4a v1.0.18 // indirect
github.com/aws/aws-sdk-go-v2/service/dynamodbstreams v1.13.20 // indirect
Expand Down
9 changes: 6 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ github.com/aws/aws-sdk-go v1.44.188/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8
github.com/aws/aws-sdk-go-v2 v1.16.16/go.mod h1:SwiyXi/1zTUZ6KIAmLK5V5ll8SiURNUYOqTerZPaF9k=
github.com/aws/aws-sdk-go-v2 v1.17.1/go.mod h1:JLnGeGONAyi2lWXI1p0PCIOIy333JMVK1U7Hf0aRFLw=
github.com/aws/aws-sdk-go-v2 v1.17.3/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw=
github.com/aws/aws-sdk-go-v2 v1.17.4 h1:wyC6p9Yfq6V2y98wfDsj6OnNQa4w2BLGCLIxzNhwOGY=
github.com/aws/aws-sdk-go-v2 v1.17.4/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw=
github.com/aws/aws-sdk-go-v2 v1.18.0 h1:882kkTpSFhdgYRKVZ/VCgf7sd0ru57p2JCxz4/oN5RY=
github.com/aws/aws-sdk-go-v2 v1.18.0/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw=
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.10 h1:dK82zF6kkPeCo8J1e+tGx4JdvDIQzj7ygIoLg8WMuGs=
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.10/go.mod h1:VeTZetY5KRJLuD/7fkQXMU6Mw7H5m/KP2J5Iy9osMno=
github.com/aws/aws-sdk-go-v2/config v1.18.10 h1:Znce11DWswdh+5kOsIp+QaNfY9igp1QUN+fZHCKmeCI=
Expand All @@ -24,13 +25,15 @@ github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.49/go.mod h1:N9gSChQkKpdAj
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.23/go.mod h1:2DFxAQ9pfIRy0imBCJv+vZ2X6RKxves6fbnEuSry6b4=
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.25/go.mod h1:Zb29PYkf42vVYQY6pvSyJCJcFHlPIiY+YKdPtwnvMkY=
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.27/go.mod h1:a1/UpzeyBBerajpnP5nGZa9mGzsBn5cOKxm6NWQsvoI=
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.28 h1:r+XwaCLpIvCKjBIYy/HVZujQS9tsz5ohHG3ZIe0wKoE=
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.28/go.mod h1:3lwChorpIM/BhImY/hy+Z6jekmN92cXGPI1QJasVPYY=
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.33 h1:kG5eQilShqmJbv11XL1VpyDbaEJzWxd4zRiCG30GSn4=
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.33/go.mod h1:7i0PF1ME/2eUPFcjkVIwq+DOygHEoK92t5cDqNgYbIw=
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.17/go.mod h1:pRwaTYCJemADaqCbUAxltMoHKata7hmB5PjEXeu0kfg=
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.19/go.mod h1:6Q0546uHDp421okhmmGfbxzq2hBqbXFNpi4k+Q1JnQA=
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.21/go.mod h1:+Gxn8jYn5k9ebfHEqlhrMirFjSW0v0C9fI+KN5vk2kE=
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.22 h1:7AwGYXDdqRQYsluvKFmWoqpcOQJ4bH634SkYf3FNj/A=
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.22/go.mod h1:EqK7gVrIGAHyZItrD1D8B0ilgwMD1GiWAmbU4u/JHNk=
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.27 h1:vFQlirhuM8lLlpI7imKOMsjdQLuN9CPi+k44F/OFVsk=
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.27/go.mod h1:UrHnn3QV/d0pBZ6QBAEQcqFLf8FAzLmoUfPVIueOvoM=
github.com/aws/aws-sdk-go-v2/internal/ini v1.3.28 h1:KeTxcGdNnQudb46oOl4d90f2I33DF/c6q3RnZAmvQdQ=
github.com/aws/aws-sdk-go-v2/internal/ini v1.3.28/go.mod h1:yRZVr/iT0AqyHeep00SZ4YfBAKojXz08w3XMBscdi0c=
github.com/aws/aws-sdk-go-v2/internal/v4a v1.0.18 h1:H/mF2LNWwX00lD6FlYfKpLLZgUW7oIzCBkig78x4Xok=
Expand Down
Loading

0 comments on commit c0de3c1

Please sign in to comment.