Skip to content

Commit

Permalink
Merge pull request #64 from gyuho/v2
Browse files Browse the repository at this point in the history
*: rewrite, implement "kubetest2"
  • Loading branch information
gyuho authored Dec 5, 2019
2 parents d97ad2e + 2e28fc4 commit 1d05418
Show file tree
Hide file tree
Showing 171 changed files with 50,740 additions and 12,254 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
/*.log
/bin
/.idea
*.swp
*.swp
31 changes: 31 additions & 0 deletions CHANGELOG-0.5.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@


<hr>


## [v0.5.0](https://github.com/aws/aws-k8s-tester/releases/tag/v0.5.0) (2019-12 TBD)

See [code changes](https://github.com/aws/aws-k8s-tester/compare/v0.4.5...v0.5.0).

### `eks`

- Rewrite to [implement `kubetest2` and use `CloudFormation`](https://github.com/aws/aws-k8s-tester/pull/64).
- https://github.com/kubernetes/test-infra/tree/master/kubetest2
- https://godoc.org/k8s.io/test-infra/kubetest2
- https://godoc.org/github.com/aws/aws-k8s-tester/eksconfig
- https://godoc.org/github.com/aws/aws-k8s-tester/eks

### Dependency

- Upgrade [`github.com/aws/aws-sdk-go`](https://github.com/aws/aws-sdk-go/releases) from [`v1.25.30`](https://github.com/aws/aws-sdk-go/releases/tag/v1.25.30) to [`v1.25.47`](https://github.com/aws/aws-sdk-go/releases/tag/v1.25.47).
- Upgrade [`go.uber.org/zap`](https://github.com/uber-go/zap/releases) from [`v1.12.0`](https://github.com/uber-go/zap/releases/tag/v1.12.0) to [`v1.13.0`](https://github.com/uber-go/zap/releases/tag/v1.13.0).
- Replace [`github.com/blang/semver/releases`](https://github.com/blang/semver/releases) with [`github.com/gyuho/semver/releases`](https://github.com/gyuho/semver/releases) [`v3.6.2`](https://github.com/gyuho/semver/releases/tag/v3.6.2).

### Go

- Compile with [*Go 1.13.5*](https://golang.org/doc/devel/release.html#go1.13).


<hr>


47 changes: 2 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Make sure AWS credential is located in your machine:
cat ~/.aws/credentials

# confirm credential is valid
aws s3 ls
aws sts get-caller-identity --query Arn --output text
```

To install:
Expand All @@ -38,7 +38,7 @@ Once cluster is created, check cluster state using AWS CLI:

```bash
aws eks describe-cluster \
--name a8-eks-190225-nqsht \
--name [NAME] \
--query cluster.status

"ACTIVE"
Expand All @@ -58,46 +58,3 @@ Tear down the cluster (takes about 10 minutes):
```bash
aws-k8s-tester eks delete cluster --path /tmp/aws-k8s-tester-eks.yaml
```

### `aws-k8s-tester eks` beta cluster

Assume the AWS account ID is granted beta access:

```bash
cd ${GOPATH}/src/github.com/aws/aws-k8s-tester
go install -v ./cmd/aws-k8s-tester

aws-k8s-tester eks create config --path /tmp/aws-k8s-tester-eks-beta.yaml
sed -i.bak 's#eks-resolver-url: ""#eks-resolver-url: https://api.beta.us-west-2.wesley.amazonaws.com#g' /tmp/aws-k8s-tester-eks-beta.yaml

aws-k8s-tester eks create cluster --path /tmp/aws-k8s-tester-eks-beta.yaml
```

### `aws-k8s-tester eks` e2e tests

To test locally:

```bash
# set "AWS_K8S_TESTER_EKS_TAG" to avoid S3 bucket conflicts
# or just disable log uploads with "AWS_K8S_TESTER_EKS_UPLOAD_TESTER_LOGS=false"
cd ${GOPATH}/src/github.com/aws/aws-k8s-tester

# use darwin to run local tests on Mac
AWS_K8S_TESTER_EKS_KUBECTL_DOWNLOAD_URL=https://amazon-eks.s3-us-west-2.amazonaws.com/1.13.7/2019-06-11/bin/$(go env GOOS)/amd64/kubectl \
AWS_K8S_TESTER_EKS_KUBECONFIG_PATH=/tmp/aws-k8s-tester/kubeconfig \
AWS_K8S_TESTER_EKS_AWS_IAM_AUTHENTICATOR_DOWNLOAD_URL=https://amazon-eks.s3-us-west-2.amazonaws.com/1.13.7/2019-06-11/bin/$(go env GOOS)/amd64/aws-iam-authenticator \
AWS_K8S_TESTER_EKS_KUBERNETES_VERSION=1.14 \
AWS_K8S_TESTER_EKS_DESTROY_AFTER_CREATE=false \
AWS_K8S_TESTER_EKS_ENABLE_WORKER_NODE_HA=true \
AWS_K8S_TESTER_EKS_ENABLE_NODE_SSH=true \
AWS_K8S_TESTER_EKS_ENABLE_WORKER_NODE_PRIVILEGED_PORT_ACCESS=true \
AWS_K8S_TESTER_EKS_LOG_ACCESS=false \
AWS_K8S_TESTER_EKS_UPLOAD_TESTER_LOGS=false \
AWS_K8S_TESTER_EKS_UPLOAD_WORKER_NODE_LOGS=false \
AWS_K8S_TESTER_EKS_WORKER_NODE_PRIVATE_KEY_PATH=~/.ssh/kube_aws_rsa \
AWS_K8S_TESTER_EKS_WORKER_NODE_INSTANCE_TYPE=m3.xlarge \
AWS_K8S_TESTER_EKS_WORKER_NODE_ASG_MIN=1 \
AWS_K8S_TESTER_EKS_WORKER_NODE_ASG_MAX=1 \
AWS_K8S_TESTER_EKS_WORKER_NODE_ASG_DESIRED_CAPACITY=1 \
./tests/ginkgo.sh
```
12 changes: 7 additions & 5 deletions cmd/aws-k8s-tester/eks/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (

"github.com/aws/aws-k8s-tester/eks"
"github.com/aws/aws-k8s-tester/eksconfig"
"github.com/aws/aws-k8s-tester/ekstester"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -36,18 +35,21 @@ func checkClusterFunc(cmd *cobra.Command, args []string) {
os.Exit(1)
}

var tester ekstester.Tester
tester, err = eks.NewTester(cfg)
tester, err := eks.New(cfg)
if err != nil {
fmt.Fprintf(os.Stderr, "failed to create EKS deployer %v\n", err)
os.Exit(1)
}

err = tester.IsUp()
var up bool
up, err = tester.IsUp()
if err != nil {
fmt.Fprintf(os.Stderr, "failed to check cluster status %v\n", err)
os.Exit(1)
}

if !up {
fmt.Fprintln(os.Stderr, "failed to check cluster status: not up")
os.Exit(1)
}
fmt.Println("'aws-k8s-tester eks check cluster' success")
}
2 changes: 0 additions & 2 deletions cmd/aws-k8s-tester/eks/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ func NewCommand() *cobra.Command {
newCreate(),
newDelete(),
newCheck(),
newGet(),
newList(),
newS3Upload(),
newTest(),
)
return cmd
Expand Down
31 changes: 26 additions & 5 deletions cmd/aws-k8s-tester/eks/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (

"github.com/aws/aws-k8s-tester/eks"
"github.com/aws/aws-k8s-tester/eksconfig"
"github.com/aws/aws-k8s-tester/ekstester"
"github.com/aws/aws-k8s-tester/pkg/fileutil"
"github.com/spf13/cobra"
)
Expand All @@ -27,6 +26,7 @@ func newCreateConfig() *cobra.Command {
return &cobra.Command{
Use: "config",
Short: "Writes an aws-k8s-tester eks configuration with default values",
Long: "Configuration values are overwritten by environment variables.",
Run: configFunc,
}
}
Expand All @@ -39,18 +39,29 @@ func configFunc(cmd *cobra.Command, args []string) {
cfg := eksconfig.NewDefault()
cfg.ConfigPath = path
cfg.Sync()

fmt.Println("overwriting config file from environment variables")
err := cfg.UpdateFromEnvs()
if err != nil {
fmt.Fprintf(os.Stderr, "Failed to load configuration from environment variables: %s", err.Error())
fmt.Fprintf(os.Stderr, "failed to load configuration from environment variables: %v", err)
os.Exit(1)
}
cfg.Sync()

if err = cfg.ValidateAndSetDefaults(); err != nil {
fmt.Fprintf(os.Stderr, "failed to validate configuration %q (%v)\n", path, err)
os.Exit(1)
}
cfg.Sync()

fmt.Fprintf(os.Stderr, "wrote aws-k8s-tester eks configuration to %q\n", cfg.ConfigPath)
}

func newCreateCluster() *cobra.Command {
cmd := &cobra.Command{
Use: "cluster",
Short: "Create an EKS cluster",
Long: "Configuration values are overwritten by environment variables.",
Run: createClusterFunc,
}
return cmd
Expand All @@ -67,18 +78,28 @@ func createClusterFunc(cmd *cobra.Command, args []string) {
fmt.Fprintf(os.Stderr, "failed to load configuration %q (%v)\n", path, err)
os.Exit(1)
}

if err = cfg.ValidateAndSetDefaults(); err != nil {
fmt.Fprintf(os.Stderr, "failed to validate configuration %q (%v)\n", path, err)
os.Exit(1)
}
cfg.Sync()

fmt.Println("overwriting config file from environment variables")
err = cfg.UpdateFromEnvs()
if err != nil {
fmt.Fprintf(os.Stderr, "Failed to load configuration from environment variables: %s", err.Error())
fmt.Fprintf(os.Stderr, "failed to load configuration from environment variables: %v\n", err)
os.Exit(1)
}
cfg.Sync()

if err = cfg.ValidateAndSetDefaults(); err != nil {
fmt.Fprintf(os.Stderr, "failed to validate configuration %q (%v)\n", path, err)
os.Exit(1)
}
cfg.Sync()

var tester ekstester.Tester
tester, err = eks.NewTester(cfg)
tester, err := eks.New(cfg)
if err != nil {
fmt.Fprintf(os.Stderr, "failed to create EKS deployer %v\n", err)
os.Exit(1)
Expand Down
4 changes: 1 addition & 3 deletions cmd/aws-k8s-tester/eks/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (

"github.com/aws/aws-k8s-tester/eks"
"github.com/aws/aws-k8s-tester/eksconfig"
"github.com/aws/aws-k8s-tester/ekstester"
"github.com/aws/aws-k8s-tester/pkg/fileutil"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -40,8 +39,7 @@ func deleteClusterFunc(cmd *cobra.Command, args []string) {
os.Exit(1)
}

var tester ekstester.Tester
tester, err = eks.NewTester(cfg)
tester, err := eks.New(cfg)
if err != nil {
fmt.Fprintf(os.Stderr, "failed to create EKS deployer %v\n", err)
os.Exit(1)
Expand Down
85 changes: 0 additions & 85 deletions cmd/aws-k8s-tester/eks/get.go

This file was deleted.

53 changes: 0 additions & 53 deletions cmd/aws-k8s-tester/eks/s3-upload.go

This file was deleted.

Loading

0 comments on commit 1d05418

Please sign in to comment.