Skip to content

Commit

Permalink
Add EKS provider for infra (#384)
Browse files Browse the repository at this point in the history
This change adds EKS commands for the creation/deletion of clusters,
nodegroups, and resources similar to the existing GKE commands in
infra. The documentation for deploying prombench for EKS is also
added. The changes in this commit are not sufficient for running
funcbench on EKS.

Signed-off-by: Drumil Patel <[email protected]>
  • Loading branch information
weastel committed Sep 5, 2020
1 parent fb17601 commit c162e41
Show file tree
Hide file tree
Showing 14 changed files with 997 additions and 27 deletions.
4 changes: 4 additions & 0 deletions funcbench/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,15 @@ clean: resource_delete cluster_delete
cluster_create:
$(INFRA_CMD) $(PROVIDER) cluster create -a ${AUTH_FILE} \
-v GKE_PROJECT_ID:${GKE_PROJECT_ID} -v ZONE:${ZONE} -v CLUSTER_NAME:funcbench-${PR_NUMBER} -v PR_NUMBER:${PR_NUMBER} \
-v EKS_WORKER_ROLE_ARN:${EKS_WORKER_ROLE_ARN} -v EKS_CLUSTER_ROLE_ARN:${EKS_CLUSTER_ROLE_ARN} \
-v EKS_SUBNET_IDS:${EKS_SUBNET_IDS} \
-f manifests/cluster_$(PROVIDER).yaml

cluster_delete:
$(INFRA_CMD) $(PROVIDER) cluster delete -a ${AUTH_FILE} \
-v GKE_PROJECT_ID:${GKE_PROJECT_ID} -v ZONE:${ZONE} -v CLUSTER_NAME:funcbench-${PR_NUMBER} -v PR_NUMBER:${PR_NUMBER} \
-v EKS_WORKER_ROLE_ARN:${EKS_WORKER_ROLE_ARN} -v EKS_CLUSTER_ROLE_ARN:${EKS_CLUSTER_ROLE_ARN} \
-v EKS_SUBNET_IDS:${EKS_SUBNET_IDS} \
-f manifests/cluster_$(PROVIDER).yaml

resource_apply:
Expand Down
26 changes: 26 additions & 0 deletions funcbench/manifests/cluster_eks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
cluster:
name: {{ .CLUSTER_NAME }}
version: 1.16
rolearn: {{ .ROLE_ARN }}
resourcesvpcconfig:
endpointpublicaccess: true
subnetids:
{{ range $subnetId := split .SUBNET_IDS .SEPARATOR }}
- {{ $subnetId }}
{{ end }}
nodegroups:
- nodegroupname: {{ .CLUSTER_NAME }}
noderole: {{ .NODE_ROLE }}
disksize: 100
subnets:
{{ range $subnetId := split .SUBNET_IDS .SEPARATOR }}
- {{ $subnetId }}
{{ end }}
instancetypes:
- r6g.xlarge
scalingconfig:
desiredsize: 1
maxsize: 1
minsize: 1
labels:
node-name: funcbench-{{ .PR_NUMBER }}
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.12

require (
cloud.google.com/go v0.56.0
github.com/aws/aws-sdk-go v1.34.5
github.com/go-git/go-git-fixtures/v4 v4.0.1
github.com/go-git/go-git/v5 v5.1.0
github.com/google/go-github/v29 v29.0.3
Expand All @@ -24,5 +25,6 @@ require (
k8s.io/apiextensions-apiserver v0.18.4
k8s.io/apimachinery v0.18.4
k8s.io/client-go v0.18.4
sigs.k8s.io/aws-iam-authenticator v0.5.1
sigs.k8s.io/kind v0.8.1
)
54 changes: 54 additions & 0 deletions go.sum

Large diffs are not rendered by default.

33 changes: 33 additions & 0 deletions infra/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,39 @@ Commands:
kind resource delete -f manifestsFileOrFolder -v hashStable:COMMIT1 -v
hashTesting:COMMIT2
eks info
eks info -v hashStable:COMMIT1 -v hashTesting:COMMIT2
eks cluster create
eks cluster create -a credentials -f FileOrFolder
eks cluster delete
eks cluster delete -a credentials -f FileOrFolder
eks nodes create
eks nodes create -a authFile -f FileOrFolder -v ZONE:eu-west-1 -v
CLUSTER_NAME:test -v EKS_SUBNET_IDS: subnetId1,subnetId2,subnetId3
eks nodes delete
eks nodes delete -a authFile -f FileOrFolder -v ZONE:eu-west-1 -v
CLUSTER_NAME:test -v EKS_SUBNET_IDS: subnetId1,subnetId2,subnetId3
eks nodes check-running
eks nodes check-running -a credentails -f FileOrFolder -v ZONE:eu-west-1 -v
CLUSTER_NAME:test -v EKS_SUBNET_IDS: subnetId1,subnetId2,subnetId3
eks nodes check-deleted
eks nodes check-deleted -a authFile -f FileOrFolder -v ZONE:eu-west-1 -v
CLUSTER_NAME:test -v EKS_SUBNET_IDS: subnetId1,subnetId2,subnetId3
eks resource apply
eks resource apply -a credentials -f manifestsFileOrFolder -v
hashStable:COMMIT1 -v hashTesting:COMMIT2
eks resource delete
eks resource delete -a credentials -f manifestsFileOrFolder -v
hashStable:COMMIT1 -v hashTesting:COMMIT2
```

Expand Down
45 changes: 45 additions & 0 deletions infra/infra.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (

"github.com/pkg/errors"
"github.com/prometheus/test-infra/pkg/provider"
"github.com/prometheus/test-infra/pkg/provider/eks"
"github.com/prometheus/test-infra/pkg/provider/gke"
kind "github.com/prometheus/test-infra/pkg/provider/kind"
"gopkg.in/alecthomas/kingpin.v2"
Expand Down Expand Up @@ -107,6 +108,50 @@ func main() {
k8sKINDResource.Command("delete", "kind resource delete -f manifestsFileOrFolder -v hashStable:COMMIT1 -v hashTesting:COMMIT2").
Action(k.ResourceDelete)

// EKS based commands
e := eks.New(dr)
k8sEKS := app.Command("eks", "Amazon Elastic Kubernetes Service - https://aws.amazon.com/eks").
Action(e.SetupDeploymentResources)
k8sEKS.Flag("auth", "filename which consist eks credentials.").
PlaceHolder("credentials").
Short('a').
StringVar(&e.Auth)

k8sEKS.Command("info", "eks info -v hashStable:COMMIT1 -v hashTesting:COMMIT2").
Action(e.GetDeploymentVars)

// EKS Cluster operations
k8sEKSCluster := k8sEKS.Command("cluster", "manage EKS clusters").
Action(e.NewEKSClient).
Action(e.EKSDeploymentParse)
k8sEKSCluster.Command("create", "eks cluster create -a credentials -f FileOrFolder").
Action(e.ClusterCreate)
k8sEKSCluster.Command("delete", "eks cluster delete -a credentials -f FileOrFolder").
Action(e.ClusterDelete)

// Cluster node-pool operations
k8sEKSNodeGroup := k8sEKS.Command("nodes", "manage EKS clusters nodegroups").
Action(e.NewEKSClient).
Action(e.EKSDeploymentParse)
k8sEKSNodeGroup.Command("create", "eks nodes create -a authFile -f FileOrFolder -v ZONE:eu-west-1 -v CLUSTER_NAME:test -v EKS_SUBNET_IDS: subnetId1,subnetId2,subnetId3").
Action(e.NodeGroupCreate)
k8sEKSNodeGroup.Command("delete", "eks nodes delete -a authFile -f FileOrFolder -v ZONE:eu-west-1 -v CLUSTER_NAME:test -v EKS_SUBNET_IDS: subnetId1,subnetId2,subnetId3").
Action(e.NodeGroupDelete)
k8sEKSNodeGroup.Command("check-running", "eks nodes check-running -a credentails -f FileOrFolder -v ZONE:eu-west-1 -v CLUSTER_NAME:test -v EKS_SUBNET_IDS: subnetId1,subnetId2,subnetId3").
Action(e.AllNodeGroupsRunning)
k8sEKSNodeGroup.Command("check-deleted", "eks nodes check-deleted -a authFile -f FileOrFolder -v ZONE:eu-west-1 -v CLUSTER_NAME:test -v EKS_SUBNET_IDS: subnetId1,subnetId2,subnetId3").
Action(e.AllNodeGroupsDeleted)

// K8s resource operations.
k8sEKSResource := k8sEKS.Command("resource", `Apply and delete different k8s resources - deployments, services, config maps etc.Required variables -v ZONE:us-east-2 -v CLUSTER_NAME:test `).
Action(e.NewEKSClient).
Action(e.K8SDeploymentsParse).
Action(e.NewK8sProvider)
k8sEKSResource.Command("apply", "eks resource apply -a credentials -f manifestsFileOrFolder -v hashStable:COMMIT1 -v hashTesting:COMMIT2").
Action(e.ResourceApply)
k8sEKSResource.Command("delete", "eks resource delete -a credentials -f manifestsFileOrFolder -v hashStable:COMMIT1 -v hashTesting:COMMIT2").
Action(e.ResourceDelete)

if _, err := app.Parse(os.Args[1:]); err != nil {
fmt.Fprintln(os.Stderr, errors.Wrapf(err, "Error parsing commandline arguments"))
app.Usage(os.Args[1:])
Expand Down
Loading

0 comments on commit c162e41

Please sign in to comment.