Skip to content

Commit

Permalink
*: add S3 utils to upload/download directory
Browse files Browse the repository at this point in the history
Signed-off-by: Gyuho Lee <leegyuho@amazon.com>
  • Loading branch information
gyuho committed Jun 20, 2020
1 parent d368c4c commit a982c1b
Show file tree
Hide file tree
Showing 14 changed files with 876 additions and 767 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG/CHANGELOG-1.4.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ See [code changes](https://github.com/aws/aws-k8s-tester/compare/v1.3.9...v1.4.0
- Move [`"scp"` executable binary path check before creating context timeouts](https://github.com/aws/aws-k8s-tester/commit/4c3950e6582745684a9d628c5c0ea355e3f7edc1).
- Fix and [improve retries](https://github.com/aws/aws-k8s-tester/commit/949cc1ea63131ce7d27808d7fc12d6e988d07978).

### `pkg/k8s-client`
### `pkg`

- Add [`pkg/aws/s3`](https://github.com/aws/aws-k8s-tester/commit/).
- Add [`pkg/k8s-client.EKSConfig.MetricsRawOutputDir` to store `kube-apiserver` `/metrics` output](https://github.com/aws/aws-k8s-tester/commit/9e7985fe8ffc948866e792d0984faafbf4e57c59).

### Dependency
Expand Down
33 changes: 33 additions & 0 deletions cmd/aws-k8s-tester/eks/create-stresser.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,26 @@ import (

"github.com/aws/aws-k8s-tester/eks/stresser"
"github.com/aws/aws-k8s-tester/eksconfig"
pkg_aws "github.com/aws/aws-k8s-tester/pkg/aws"
"github.com/aws/aws-k8s-tester/pkg/fileutil"
k8s_client "github.com/aws/aws-k8s-tester/pkg/k8s-client"
"github.com/aws/aws-k8s-tester/pkg/logutil"
"github.com/aws/aws-k8s-tester/pkg/randutil"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/s3"
"github.com/spf13/cobra"
"go.uber.org/zap"
)

var (
stresserKubeConfigPath string

stresserPartition string
stresserRegion string

stresserS3BucketName string
stresserS3DirName string

stresserClients int
stresserClientQPS float32
stresserClientBurst int
Expand All @@ -45,6 +54,10 @@ func newCreateStresser() *cobra.Command {
Run: createStresserFunc,
}
cmd.PersistentFlags().StringVar(&stresserKubeConfigPath, "kubeconfig", "", "kubeconfig path (optional, should be run in-cluster, useful for local testing)")
cmd.PersistentFlags().StringVar(&stresserPartition, "partition", "aws", "partition for AWS API")
cmd.PersistentFlags().StringVar(&stresserRegion, "region", "us-west-2", "region for AWS API")
cmd.PersistentFlags().StringVar(&stresserS3BucketName, "s3-bucket-name", "", "S3 bucket name to upload results")
cmd.PersistentFlags().StringVar(&stresserS3DirName, "s3-dir-name", "", "S3 directory name to upload results")
cmd.PersistentFlags().IntVar(&stresserClients, "clients", eksconfig.DefaultClients, "Number of clients to create")
cmd.PersistentFlags().Float32Var(&stresserClientQPS, "client-qps", eksconfig.DefaultClientQPS, "kubelet client setup for QPS")
cmd.PersistentFlags().IntVar(&stresserClientBurst, "client-burst", eksconfig.DefaultClientBurst, "kubelet client setup for burst")
Expand Down Expand Up @@ -93,6 +106,25 @@ func createStresserFunc(cmd *cobra.Command, args []string) {
os.Exit(1)
}

awsCfg := &pkg_aws.Config{
Logger: lg,
Partition: stresserPartition,
Region: stresserRegion,
}
awsSession, stsOutput, _, err := pkg_aws.New(awsCfg)
if err != nil {
fmt.Fprintf(os.Stderr, "failed to create AWS session %v\n", err)
os.Exit(1)
}
awsAccountID := aws.StringValue(stsOutput.Account)
awsUserID := aws.StringValue(stsOutput.UserId)
awsIAMRoleARN := aws.StringValue(stsOutput.Arn)
lg.Info("created AWS session",
zap.String("was-account-id", awsAccountID),
zap.String("was-user-id", awsUserID),
zap.String("was-iam-role-arn", awsIAMRoleARN),
)

stopc := make(chan struct{})

// to randomize results output files
Expand All @@ -105,6 +137,7 @@ func createStresserFunc(cmd *cobra.Command, args []string) {
loader := stresser.New(stresser.Config{
Logger: lg,
Stopc: stopc,
S3API: s3.New(awsSession),
Client: cli,
ClientTimeout: stresserClientTimeout,
Deadline: time.Now().Add(stresserDuration),
Expand Down
Loading

0 comments on commit a982c1b

Please sign in to comment.