Skip to content

Commit

Permalink
Use original lb
Browse files Browse the repository at this point in the history
  • Loading branch information
saurav-c committed Apr 20, 2021
1 parent 4b58269 commit a390b5b
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@ cmd/keynode/keynode
cmd/manager/manager
cmd/routing/routing
cmd/monitor/monitor
cmd/worker/worker
client/client
cmd/cli/cli
cmd/benchmark/benchmark
cmd/benchmark/benchmarks.txt

config/tasc-config.yml

logs/
*.log
pids
Expand Down
13 changes: 10 additions & 3 deletions cluster/create_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

ec2_client = boto3.client('ec2', os.getenv('AWS_REGION', 'us-east-1'))

def create_cluster(txn_count, keynode_count, rtr_count, benchmark_count, config_file,
def create_cluster(txn_count, keynode_count, rtr_count, lb_count, benchmark_count, config_file,
branch_name, ssh_key, cluster_name, kops_bucket, aws_key_id, aws_key, anna_config_file):
prefix = './'
util.run_process(['./create_cluster_object.sh', kops_bucket, ssh_key], 'kops')
Expand Down Expand Up @@ -37,7 +37,11 @@ def create_cluster(txn_count, keynode_count, rtr_count, benchmark_count, config_
add_nodes(client, apps_client, config_file, 'tasc', txn_count,
aws_key_id, aws_key, True, prefix, branch_name)

print('Creating TASC service...')
print('Creating %d Load Balancers...' % (lb_count))
add_nodes(client, apps_client, config_file, 'lb', lb_count,
aws_key_id, aws_key, True, prefix, branch_name)

print('Creating TASC Load Balancing service...')
service_spec = util.load_yaml('yaml/services/tasc.yml', prefix)
client.create_namespaced_service(namespace=util.NAMESPACE,
body=service_spec)
Expand Down Expand Up @@ -95,6 +99,9 @@ def create_cluster(txn_count, keynode_count, rtr_count, benchmark_count, config_
parser.add_argument('-r', '--routers', nargs=1, type=int, metavar='L',
help='The number of (Anna) router nodes to start with ' +
'(required)', dest='routers', required=True)
parser.add_argument('-l', '--loadbalancer', nargs=1, type=int, metavar='L',
help='The number of load balancer nodes to start with ' +
'(required)', dest='lb', required=True)
parser.add_argument('-b', '--benchmark', nargs=1, type=int, metavar='L',
help='The number of benchmark nodes to start with ' +
'(required)', dest='benchmark', required=True)
Expand Down Expand Up @@ -123,6 +130,6 @@ def create_cluster(txn_count, keynode_count, rtr_count, benchmark_count, config_

args = parser.parse_args()

create_cluster(args.nodes[0], args.keynodes[0], args.routers[0],
create_cluster(args.nodes[0], args.keynodes[0], args.routers[0], args.lb[0],
args.benchmark[0], args.config, args.branch, args.sshkey, cluster_name,
kops_bucket, aws_key_id, aws_key, args.annaconfig)
17 changes: 17 additions & 0 deletions cluster/kops/yaml/igs/lb-ig.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: kops/v1alpha2
kind: InstanceGroup
metadata:
labels:
kops.k8s.io/cluster: CLUSTER_NAME
name: lb-instances
spec:
image: kope.io/k8s-1.11-debian-stretch-amd64-hvm-ebs-2018-08-17
machineType: c5.large
maxSize: FILLER
minSize: FILLER
rootVolumeSize: 32
role: Node
nodeLabels:
role: lb
subnets:
- us-east-1a
31 changes: 31 additions & 0 deletions cluster/yaml/ds/lb-ds.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: lb-nodes
labels:
role: lb
spec:
selector:
matchLabels:
role: lb
template:
metadata:
labels:
role: lb
spec:
nodeSelector:
role: lb
hostNetwork: true
containers:
- name: lb-container
image: sauravchh/tasc
imagePullPolicy: Always
env:
- name: BRANCH
value: master
- name: ROLE
value: lb
- name: AWS_ACCESS_KEY_ID
value: ACCESS_KEY_ID_DUMMY
- name: AWS_SECRET_ACCESS_KEY
value: AWS_SECRET_KEY_DUMMY
11 changes: 11 additions & 0 deletions cmd/lb/lb.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
cmn "github.com/saurav-c/tasc/lib/common"
log "github.com/sirupsen/logrus"
"math/rand"
"os"
"time"
Expand Down Expand Up @@ -64,6 +65,8 @@ func main() {
poller := zmq.NewPoller()
poller.Add(lbSocket, zmq.POLLIN)

logger := cmn.InitLogger("logs", "lb", log.DebugLevel)

updateStart := time.Now()
for true {
sockets, _ := poller.Poll(10 * time.Millisecond)
Expand All @@ -87,6 +90,7 @@ func main() {
}

addresses = newAddresses
go logAddresses(addresses)
updateStart = time.Now()
}
}
Expand Down Expand Up @@ -115,3 +119,10 @@ func getNodeAddress(addresses []v1.NodeAddress, tp v1.NodeAddressType) string {

return ""
}

func logAddresses(addrs []string) {
log.Info("TASC Node Addresses...")
for _, addr := range addrs {
log.Info("\t-" + addr)
}
}

0 comments on commit a390b5b

Please sign in to comment.