Skip to content

Commit

Permalink
Allow specifying output file path for generate_kubeconfig
Browse files Browse the repository at this point in the history
Test Plan: Run with the option and without the option

Reviewers: gjalla, bgandhi, ysharma-contractor

Reviewed By: ysharma-contractor

Differential Revision: https://phabricator.dev.yugabyte.com/D18230
  • Loading branch information
iSignal committed Jul 14, 2022
1 parent a25df05 commit e1ee18a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion stable/yugabyte/generate_kubeconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def run_command(command_args, namespace=None, as_json=True):
parser.add_argument('-s', '--service_account', help='Service Account name', required=True)
parser.add_argument('-n', '--namespace', help='Kubernetes namespace', default='kube-system')
parser.add_argument('-c', '--context', help='kubectl context')
parser.add_argument('-o', '--output_file', help='output file path')
args = vars(parser.parse_args())

# if the context is not provided we use the current-context
Expand Down Expand Up @@ -61,7 +62,9 @@ def run_command(command_args, namespace=None, as_json=True):
exit("No usable secret found for '{}'.".format(args['service_account']))

context_name = '{}-{}'.format(args['service_account'], cluster_name)
kube_config = '/tmp/{}.conf'.format(args['service_account'])
kube_config = args['output_file']
if not kube_config:
kube_config = '/tmp/{}.conf'.format(args['service_account'])

with tempfile.NamedTemporaryFile() as ca_crt_file:
ca_crt = base64.b64decode(secret_data['data']['ca.crt'])
Expand Down

0 comments on commit e1ee18a

Please sign in to comment.