Azure / k8s-deploy

GitHub Action for deploying to Kubernetes clusters
MIT License
252 stars 103 forks source link

Fix “Service” route-method of the Blue-Green strategy with some manifest files #283

Closed otetard closed 1 year ago

otetard commented 1 year ago

With the current implementation of the “Service” route-method of the Blue-Green strategy, if the manifest file contains Service object before Deployment ones, then, Service isn’t updated with the right labels selector.

Sample affected manifest file ```yaml apiVersion: v1 kind: Service metadata: name: nginx-service spec: selector: app: nginx ports: - protocol: TCP port: 80 targetPort: 80 --- apiVersion: apps/v1 kind: Deployment metadata: name: nginx-deployment labels: app: nginx spec: replicas: 1 selector: matchLabels: app: nginx template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx ports: - containerPort: 80 ```

To fix this issue, update getManifestObjects() function in the src/strategyHelpers/blueGreen/blueGreenHelper.ts file to first extract all objects from the manifest file, and then identify “routed” service entities. This way, even if the Deployment object is declared after the “routed” Service, Blue-Green strategy will be able to not update the Service until the routing switch (done in routeBlueGreenForDeploy(), in src/strategyHelpers/blueGreen/route.ts).

otetard commented 1 year ago

@microsoft-github-policy-service agree