WIP: Working config

parent 4a3d5311
......@@ -7,16 +7,45 @@ import logging
helpers.set_logger()
@click.group()
def k8s():
@click.option("--applications", required=True, help="Comma separated list of containers to update")
@click.option("--server", required=True, help="Kubernetes server address")
@click.option("--token", required=True, help="Authentication token")
@click.option("--ca-file-path", required=True, help="Path to a file with the server's CA")
@click.pass_context
def k8s(ctx, applications, server, token, ca_file_path):
from kubernetes import client, config
configuration = client.Configuration()
configuration.host = "https://{}".format(server)
configuration.ssl_ca_cert = ca_file_path
configuration.debug = True
configuration.api_key={"authorization":"Bearer {}".format(token)}
ctx.obj = {'configuration': configuration, 'applications': applications}
pass
@k8s.command()
@click.option("--applications", required=True, help="Comma separated list of containers to update")
@click.pass_context
def monitor_deployment(ctx):
applications = ctx.obj.get('applications')
configuration = ctx.obj.get('configuration')
from .monitor_deployment import monitor_deployment
k8s_monitor = monitor_deployment.MonitorDeployment(configuration, applications)
k8s_monitor.list_all()
@k8s.command()
@click.option("--new-image", help="Full image path, minus the tag")
@click.option("--new-tag", help="Tag to update the container's image to")
@click.option("--file-paths", required=True, help="Comma separated string with paths to deployment specs")
@click.option("--dry-run", is_flag=True, help="If passed, then the new config is written to stdout instead of the originating file")
def update_deployment(applications, new_image, new_tag, file_paths, dry_run):
@click.pass_context
def update_deployment(ctx, new_image, new_tag, file_paths, dry_run):
applications = ctx.obj.get('applications')
configuration = ctx.obj.get('configuration')
from .update_deployment import update_deployment
k8s_update = update_deployment.UpdateDeployment(applications, new_image, new_tag, file_paths, dry_run)
......
#!/usr/bin/env python3
from kubernetes import client
class MonitorDeployment():
def __init__(self, configuration, applications):
client.Configuration.set_default(configuration)
self.api = client.CoreV1Api()
def list_all(self):
self.api.list_pod_for_all_namespaces(watch=False)
......@@ -6,7 +6,7 @@ with open("README.md", "r") as fh:
setuptools.setup(
name="akinaka",
python_requires='>=3.3.0',
version="0.2.22",
version="0.2.23",
author="Afraz",
author_email="afraz@olindata.com",
description="OlinData's aws cli Extras",
......@@ -18,7 +18,8 @@ setuptools.setup(
'boto3',
'datetime',
'click',
'pyyaml'
'pyyaml',
'kubernetes'
],
classifiers=[
"Programming Language :: Python :: 3",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment