Skip to content
This repository has been archived by the owner on Feb 6, 2024. It is now read-only.

Commit

Permalink
Merge pull request #7 from invidian/improvemennts
Browse files Browse the repository at this point in the history
UX improvements
  • Loading branch information
invidian authored May 28, 2019
2 parents 7bce770 + bd47fbc commit e5f4244
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 17 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,8 @@ tuned, and bare, simply issue:
Please note that you must always use scripts from the directory of your
respective cluster service mesh. If your cluster currently has istio installed,
please only use scripts from `scripts/istio/`.

## Cleaning up

After you finish running benchmarks, you can tear down infrastructure by going to `terraform` directory and running `terraform destroy`.
Once it's complete, it should be fine to remove `assets` directory.
16 changes: 10 additions & 6 deletions scripts/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,26 @@ function stderr() {
#---

function print_kubeconfig_path() {
stderr "Checking available kubeconfig file..."
local asset_dir="$1"

# check for kubeconfig already in use
[ -f "${KUBECONFIG:-}" ] && {
for i in {1..6}; do kubectl cluster-info >/dev/null 2>&1 && {
for i in {1..6}; do stderr "Running 'KUBECONFIG=$KUBECONFIG kubectl cluster-info'... ($i/6)"; kubectl cluster-info >/dev/null 2>&1 && {
stderr "Will use existing cluster with kubeconfig at '$KUBECONFIG'"
echo "$(readlink -f $KUBECONFIG)"
exit 0
} || sleep 5; done
}

export KUBECONFIG="$(readlink -f ${asset_dir}/auth/kubeconfig)"
for i in {1..6}; do kubectl cluster-info >/dev/null 2>&1 && {
stderr "Will use existing cluster with kubeconfig at '$KUBECONFIG'"
echo "$(readlink -f $KUBECONFIG)"
exit 0
} || sleep 5; done
[ -f "${KUBECONFIG:-}" ] && {
for i in {1..6}; do stderr "Running 'KUBECONFIG=$KUBECONFIG kubectl cluster-info'... ($i/6)"; kubectl cluster-info >/dev/null 2>&1 && {
stderr "Will use existing cluster with kubeconfig at '$KUBECONFIG'"
echo "$(readlink -f $KUBECONFIG)"
exit 0
} || sleep 5; done
}

stderr "No existing cluster / kubeconfg found."
}
Expand Down Expand Up @@ -65,6 +68,7 @@ function ask_create_cluster() {

rm -rf "$asset_dir"
pushd "${terraform_dir}"
terraform init
(terraform destroy || true) && terraform apply || {
echo "Failed to set up test cluster."
exit 1; }
Expand Down
2 changes: 1 addition & 1 deletion scripts/istio/benchmark-multi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ source "$script_dir/../common.sh"
asset_dir="${script_dir}/../../assets"
KUBECONFIG=$(print_kubeconfig_path "$asset_dir")
[ ! -f "$KUBECONFIG" ] && {
echo "No working cluster config found, aborting."
echo "No working cluster config found, aborting. Did you run '$script_dir/setup-cluster.sh' ?"
exit 1; }
export KUBECONFIG

Expand Down
2 changes: 1 addition & 1 deletion scripts/istio/benchmark.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ istio_type="tuned"
asset_dir="${script_dir}/../../assets"
KUBECONFIG=$(print_kubeconfig_path "$asset_dir")
[ ! -f "$KUBECONFIG" ] && {
echo "No working cluster config found, aborting."
echo "No working cluster config found, aborting. Did you run '$script_dir/setup-cluster.sh' ?"
exit 1; }
export KUBECONFIG

Expand Down
2 changes: 1 addition & 1 deletion scripts/linkerd/benchmark-multi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ source "$script_dir/../common.sh"
asset_dir="${script_dir}/../../assets"
KUBECONFIG=$(print_kubeconfig_path "$asset_dir")
[ ! -f "$KUBECONFIG" ] && {
echo "No working cluster config found, aborting."
echo "No working cluster config found, aborting. Did you run '$script_dir/setup-cluster.sh' ?"
exit 1; }
export KUBECONFIG

Expand Down
2 changes: 1 addition & 1 deletion scripts/linkerd/benchmark.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ linkerd=$(grok_cmd 5 "linkerd2-cli-edge-19.5.3-linux" $@)
asset_dir="${script_dir}/../../assets"
KUBECONFIG=$(print_kubeconfig_path "$asset_dir")
[ ! -f "$KUBECONFIG" ] && {
echo "No working cluster config found, aborting."
echo "No working cluster config found, aborting. Did you run '$script_dir/setup-cluster.sh' ?"
exit 1; }
export KUBECONFIG

Expand Down
4 changes: 2 additions & 2 deletions terraform/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
This directory contains Terraform code, which spawns a Kubernetes cluster in a
Packet datacenter to perform the benchmark on.

To configure your cluster, please copy the file `variables.auto.tfvars.template`
To configure your cluster, please copy the file `variables.auto.tfvars.template`
to `variables.auto.tfvars`, then edit `variables.auto.tfvars` and set the
variables as discussed below.

Expand All @@ -17,7 +17,7 @@ packet_project_id = "<packet project id>"

Optionally, you may also set:
```
cluster_name="my-lokomotive-benchmarkcluster"
cluster_name="my-lokomotive-benchmarkcluster"
facility="<packet dataceter>"
ssh_keys=["list of keys to grant ssh access to nodes"]
controller_node_type = "t1.small"
Expand Down
19 changes: 15 additions & 4 deletions terraform/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,14 @@ variable "facility" {
}
variable "ssh_keys" {
type = "list"
description = "List of SSH public key files or SSH public keys."
description = "List of SSH public keys."
default = []
}
variable "ssh_key_files" {
type = "list"
description = "List of SSH public key files."
default = [
"~/.ssh/.id_rsa.pub"
"~/.ssh/id_rsa.pub"
]
}
variable "controller_node_type" {
Expand All @@ -49,7 +54,13 @@ variable "worker_node_count" {
description = "Number of worker nodes in the cluster. Must be 2 or higher."
default = "2"
}
resource "null_resource" "ssh_keys" {
count = "${length("${var.ssh_key_files}")}"

triggers = {
ssh_key = "${file("${var.ssh_key_files[count.index]}")}"
}
}
data "aws_route53_zone" "cluster" {
name = "${var.dns_zone}."

Expand Down Expand Up @@ -80,7 +91,7 @@ module "packet-svc-mesh-benchmark" {
dns_zone = "${var.dns_zone}"
dns_zone_id = "${data.aws_route53_zone.cluster.zone_id}"

ssh_keys = ["$${var.ssh_keys}"]
ssh_keys = ["${var.ssh_keys}", "${null_resource.ssh_keys.*.triggers.ssh_key}"]
asset_dir = "../assets"

cluster_name = "${var.cluster_name}"
Expand Down Expand Up @@ -110,7 +121,7 @@ module "worker-pool-0" {
packet = "packet.default"
}

ssh_keys = ["$${var.ssh_keys}"]
ssh_keys = ["${var.ssh_keys}", "${null_resource.ssh_keys.*.triggers.ssh_key}"]

cluster_name = "${var.cluster_name}"
project_id = "${var.packet_project_id}"
Expand Down
3 changes: 2 additions & 1 deletion terraform/variables.auto.tfvars.template
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ packet_project_id = "<packet project id>"
facility="ams1"
cluster_name="lokomotive-benchmark"

ssh_keys=["~/.ssh/.id_rsa.pub"]
ssh_keys=["ssh-rsa AAAAB3NzaC1..."]
ssh_key_files=["~/.ssh/id_rsa.pub"]

controller_node_type = "t1.small"
worker_node_type = "t1.small"
Expand Down

0 comments on commit e5f4244

Please sign in to comment.