Skip to content
This repository has been archived by the owner on Jan 9, 2025. It is now read-only.

feat: Take k8s manifest as input instead of docker compose #30

Merged
merged 9 commits into from
Jul 12, 2024

Conversation

laurentluce
Copy link
Contributor

@laurentluce laurentluce commented Jul 10, 2024

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 -

kardinal-cli/cmd/root.go Outdated Show resolved Hide resolved
@laurentluce laurentluce requested a review from lostbean July 11, 2024 15:02
@laurentluce laurentluce merged commit 4bcda1f into main Jul 12, 2024
11 checks passed
laurentluce pushed a commit that referenced this pull request Jul 12, 2024
🤖 I have created a release *beep* *boop*
---


##
[0.1.3](0.1.2...0.1.3)
(2024-07-12)


### Features

* remove old urls
([#21](#21))
([2ce038f](2ce038f))
* store Kontrol location
([#20](#20))
([ad42d22](ad42d22))
* Take k8s manifest as input instead of docker compose
([#30](#30))
([4bcda1f](4bcda1f))
* use install link alias
([#28](#28))
([40e9d75](40e9d75))


### Bug Fixes

* image for quick demo
([#32](#32))
([76d3ff3](76d3ff3))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants