Getting options ready for k8s module usage

parent 9bbcfef3
Pipeline #2036 passed with stages
in 1 minute and 36 seconds
......@@ -9,7 +9,7 @@ aws_client = AWS_Client()
@click.option("--applications", required=True, help="Comma separated list of containers to update")
@click.option("--server", required=True, help="Kubernetes server domain (without protocol)")
@click.option("--server", required=True, help="URL that Kubernetes control plane can be reached (with protocol)")
@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")
......@@ -17,7 +17,7 @@ def k8s(ctx, applications, server, token, ca_file_path):
from kubernetes import client, config
configuration = client.Configuration() = "https://{}".format(server) = server
configuration.ssl_ca_cert = ca_file_path
configuration.debug = True
configuration.api_key={"authorization":"Bearer {}".format(token)}
......@@ -41,7 +41,7 @@ def monitor_deployment(ctx):
@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")
@click.option("--dry-run", is_flag=True, help="Flag: Write config to stdout instead of the originating file")
def update_deployment(ctx, new_image, new_tag, file_paths, dry_run):
applications = ctx.obj.get('applications')
......@@ -11,6 +11,7 @@ class MonitorDeployment():
self.api = client.CoreV1Api()
# kubectl --certificate-authority ca.crt --server $K8S_URL --token $K8S_TOKEN apply -f full_spec.yml
def deploy_update(self):
......@@ -39,6 +39,7 @@ class UpdateDeployment():
def update_spec(self, file_path):
specs = self.read_specs(file_path)
found = False
for spec in specs:
if spec['kind'] == 'Deployment' or spec['kind'] == 'Pod':
......@@ -51,6 +52,8 @@ class UpdateDeployment():
for container in spec_path:
if container['name'] in self.applications:
found = True
if self.new_image:
image = self.new_image
......@@ -63,6 +66,8 @@ class UpdateDeployment():
container['image'] = "{image}:{tag}".format(image = image, tag = tag)
logging.warning("Didn't find any containers from the array {}, and didn't change any files".format(self.applications))
return specs
def write_new_spec(self):
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