Created
September 5, 2018 08:20
-
-
Save guessi/2e0d413d4ee0366b5bc951b9041369ce to your computer and use it in GitHub Desktop.
kube-dns-replicas-calc.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import argparse | |
from math import ceil | |
from prettytable import PrettyTable | |
def resultTable(coresPerReplica, nodesPerReplica, m, M, s=10): | |
pretty_table = PrettyTable() | |
pretty_table.field_names = ["Node", "replicas"] | |
coresPerNode = 16 | |
for node in range(10, 301, s): | |
r1 = ceil(node * coresPerNode / coresPerReplica) | |
r2 = ceil(node / nodesPerReplica) | |
replicas = max(min(max(r1, r2), M), m) | |
pretty_table.add_row([node, replicas]) | |
print(pretty_table) | |
print("coresPerReplica: {0}, nodesPerReplica: {1}, " | |
"min: {2}, max: {3}".format(coresPerReplica, nodesPerReplica, m, M)) | |
if __name__ == "__main__": | |
parser = argparse.ArgumentParser(description='Calculator for kube_dns replicas count') | |
parser.add_argument('-M', action="store", dest="max_replicas", type=int, default=120) | |
parser.add_argument('-m', action="store", dest="min_replicas", type=int, default=6) | |
parser.add_argument('-c', action="store", dest="cores_per_replica", type=int, default=36) | |
parser.add_argument('-n', action="store", dest="nodes_per_replica", type=int, default=16) | |
parser.add_argument('-s', action="store", dest="steps", type=int, default=10) | |
args = parser.parse_args() | |
resultTable( | |
args.cores_per_replica, | |
args.nodes_per_replica, | |
args.min_replicas, | |
args.max_replicas, | |
args.steps | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment