diff --git a/README.md b/README.md index f4b2ef7..e05f557 100644 --- a/README.md +++ b/README.md @@ -80,13 +80,11 @@ Specification descriptor: "namespace": null, "objects": { "deployments": { - "api_path": "apis/apps/v1beta1", "specification": { "### Kubernetes deployment object spec goes here" } }, "services": { - "api_path": "api/v1", "specification": { "### Kubernetes service object spec goes here" } diff --git a/examples/echoserver.json b/examples/echoserver.json index fd89beb..c56f775 100644 --- a/examples/echoserver.json +++ b/examples/echoserver.json @@ -3,8 +3,9 @@ "namespace": null, "objects": { "deployments": { - "api_path": "apis/apps/v1beta1", "specification": { + "kind": "Deployment", + "apiVersion": "apps/v1beta1", "metadata": { "name": "echoserver", "creationTimestamp": null, @@ -30,7 +31,7 @@ "containers": [ { "name": "echoserver", - "image": "gcr.io/google_containers/echoserver:1.6", + "image": "gcr.io/google_containers/echoserver:1.8", "ports": [ { "containerPort": 8080, @@ -71,8 +72,9 @@ } }, "services": { - "api_path": "api/v1", "specification": { + "kind": "Service", + "apiVersion": "v1", "metadata": { "name": "echoserver", "creationTimestamp": null, diff --git a/k8s-deployer.py b/k8s-deployer.py index 2898d2d..92b3fb8 100755 --- a/k8s-deployer.py +++ b/k8s-deployer.py @@ -99,9 +99,6 @@ def spec_validator(data): 'deployments': { 'type': 'object', 'properties': { - 'api_path': { - 'type': 'string' - }, 'specification': { 'type': 'object' } @@ -110,9 +107,6 @@ def spec_validator(data): 'services': { 'type': 'object', 'properties': { - 'api_path': { - 'type': 'string' - }, 'specification': { 'type': 'object' } @@ -170,7 +164,7 @@ def create_object(k8s_host, **kwargs): objects = kwargs['objects'] for obj in objects: - api_path = objects[obj]['api_path'] + api_path = K8S_API[obj] url = '{}/{}/namespaces/{}/{}'.format( k8s_host, api_path, namespace, obj @@ -230,8 +224,8 @@ def delete_object(k8s_host, **kwargs): objects = kwargs['objects'] for obj in objects.keys() + ['replicasets']: + api_path = K8S_API[obj] if obj == 'replicasets': - api_path = K8S_API['replicasets'] rs_label_selector = (kwargs['objects']['deployments'] ['specification']['spec']['selector']['matchLabels'] ) @@ -245,7 +239,6 @@ def delete_object(k8s_host, **kwargs): ) obj_name = req('GET', url)['items'][0]['metadata']['name'] else: - api_path = objects[obj]['api_path'] obj_name = (kwargs['objects']['services'] ['specification']['metadata']['name'] )