Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Take k8s manifest as input instead of docker compose (#30)
The Kardinal CLI now takes as input a K8S manifest containing pairs of Service / Deployment specs. Those objects are added to the flow requests sent to the kontrol service. K8S manifest: ``` apiVersion: v1 kind: Service metadata: labels: app: redis-prod version: v1 name: redis-prod namespace: voting-app spec: ports: - name: tcp-redis port: 6379 protocol: TCP targetPort: 6379 selector: app: redis-prod --- apiVersion: apps/v1 kind: Deployment metadata: labels: app: redis-prod version: v1 name: redis-prod-v1 namespace: voting-app spec: replicas: 1 selector: matchLabels: app: redis-prod version: v1 strategy: rollingUpdate: maxSurge: 25% maxUnavailable: 25% type: RollingUpdate template: metadata: annotations: sidecar.istio.io/inject: "true" labels: app: redis-prod version: v1 spec: containers: - name: redis-prod image: bitnami/redis:6.0.8 env: - name: ALLOW_EMPTY_PASSWORD value: "yes" - name: REDIS_PORT_NUMBER value: "6379" resources: requests: cpu: 100m memory: 128Mi limits: cpu: 250m memory: 256Mi ports: - containerPort: 6379 name: redis --- apiVersion: v1 kind: Service metadata: labels: app: voting-app-ui version: v1 name: voting-app-ui namespace: voting-app spec: ports: - name: http port: 80 protocol: TCP targetPort: 80 --- apiVersion: v1 selector: app: voting-app-ui --- apiVersion: apps/v1 kind: Deployment metadata: labels: app: voting-app-ui version: v1 name: voting-app-ui-v1 namespace: voting-app spec: replicas: 1 selector: matchLabels: app: voting-app-ui version: v1 strategy: rollingUpdate: maxSurge: 25% maxUnavailable: 25% type: RollingUpdate template: metadata: annotations: sidecar.istio.io/inject: "true" labels: app: voting-app-ui version: v1 spec: containers: - name: azure-vote-front image: voting-app-ui imagePullPolicy: IfNotPresent resources: requests: cpu: 100m memory: 128Mi limits: cpu: 250m memory: 256Mi ports: - containerPort: 80 env: - name: REDIS value: "redis-prod" ``` POST request: ``` ### POST ('127.0.0.1', 62359) - HTTP/1.1 - /tenant/a1bc5679-db0b-4468-b2fb-6d9e47aa2910/flow/create ### Headers ### Host: localhost:8080 User-Agent: Go-http-client/1.1 Content-Length: 2394 Content-Type: application/json Accept-Encoding: gzip ### POST content ### { "image-locator": "voting-app", "service-configs": [ { "deployment": { "kind": "Deployment", "apiVersion": "apps/v1", "metadata": { "name": "redis-prod-v1", "namespace": "voting-app", "creationTimestamp": null, "labels": { "app": "redis-prod", "version": "v1" } }, "spec": { "replicas": 1, "selector": { "matchLabels": { "app": "redis-prod", "version": "v1" } }, "template": { "metadata": { "creationTimestamp": null, "labels": { "app": "redis-prod", "version": "v1" }, "annotations": { "sidecar.istio.io/inject": "true" } }, "spec": { "containers": [ { "name": "redis-prod", "image": "bitnami/redis:6.0.8", "ports": [ { "name": "redis", "containerPort": 6379 } ], "env": [ { "name": "ALLOW_EMPTY_PASSWORD", "value": "yes" }, { "name": "REDIS_PORT_NUMBER", "value": "6379" } ], "resources": { "limits": { "cpu": "250m", "memory": "256Mi" }, "requests": { "cpu": "100m", "memory": "128Mi" } } } ] } }, "strategy": { "type": "RollingUpdate", "rollingUpdate": { "maxUnavailable": "25%", "maxSurge": "25%" } } }, "status": {} }, "service": { "kind": "Service", "apiVersion": "v1", "metadata": { "name": "redis-prod", "namespace": "voting-app", "creationTimestamp": null, "labels": { "app": "redis-prod", "version": "v1" } }, "spec": { "ports": [ { "name": "tcp-redis", "protocol": "TCP", "port": 6379, "targetPort": 6379 } ], "selector": { "app": "redis-prod" } }, "status": { "loadBalancer": {} } } }, { "deployment": { "kind": "Deployment", "apiVersion": "apps/v1", "metadata": { "name": "voting-app-ui-v1", "namespace": "voting-app", "creationTimestamp": null, "labels": { "app": "voting-app-ui", "version": "v1" } }, "spec": { "replicas": 1, "selector": { "matchLabels": { "app": "voting-app-ui", "version": "v1" } }, "template": { "metadata": { "creationTimestamp": null, "labels": { "app": "voting-app-ui", "version": "v1" }, "annotations": { "sidecar.istio.io/inject": "true" } }, "spec": { "containers": [ { "name": "azure-vote-front", "image": "voting-app-ui", "ports": [ { "containerPort": 80 } ], "env": [ { "name": "REDIS", "value": "redis-prod" } ], "resources": { "limits": { "cpu": "250m", "memory": "256Mi" }, "requests": { "cpu": "100m", "memory": "128Mi" } }, "imagePullPolicy": "IfNotPresent" } ] } }, "strategy": { "type": "RollingUpdate", "rollingUpdate": { "maxUnavailable": "25%", "maxSurge": "25%" } } }, "status": {} }, "service": { "kind": "Service", "apiVersion": "v1", "metadata": { "name": "voting-app-ui", "namespace": "voting-app", "creationTimestamp": null, "labels": { "app": "voting-app-ui", "version": "v1" } }, "spec": { "ports": [ { "name": "http", "protocol": "TCP", "port": 80, "targetPort": 80 } ], "selector": { "app": "voting-app-ui" } }, "status": { "loadBalancer": {} } } } ], "service-name": "voting-app" } 127.0.0.1 - - [10/Jul/2024 14:24:07] "POST /tenant/a1bc5679-db0b-4468-b2fb-6d9e47aa2910/flow/create HTTP/1.1" 200 - ```
- Loading branch information