diff --git a/core/src/plugins/kubernetes/sync.ts b/core/src/plugins/kubernetes/sync.ts index 71d2d431f3..2c044e3b6f 100644 --- a/core/src/plugins/kubernetes/sync.ts +++ b/core/src/plugins/kubernetes/sync.ts @@ -248,17 +248,35 @@ export function convertContainerSyncSpec( action: Resolved ): KubernetesDeploySyncSpec | undefined { const spec = action.getSpec() + const kind: SyncableKind = spec.daemon ? "DaemonSet" : "Deployment" + const target = { kind, name: action.name } + const sourcePath = action.basePath() + const syncSpec = spec.sync - if (!spec.sync) { + if (!syncSpec || !target) { return } - const kind: SyncableKind = spec.daemon ? "DaemonSet" : "Deployment" - const target = { kind, name: action.name } + const sync: KubernetesDeploySyncSpec = { + paths: convertSyncPaths(sourcePath, syncSpec.paths, target), + } - return { - paths: convertSyncPaths(action.basePath(), spec.sync.paths, target), + if (syncSpec.command || syncSpec.args) { + if (target.kind && target.name) { + sync.overrides = [ + { + target: { + kind: target.kind, + name: target.name, + }, + command: syncSpec.command, + args: syncSpec.args, + }, + ] + } } + + return sync } function convertSyncPaths( diff --git a/examples/code-synchronization/node-service/garden.yml b/examples/code-synchronization/node-service/garden.yml index a4f0de72f9..8c668d0ba3 100644 --- a/examples/code-synchronization/node-service/garden.yml +++ b/examples/code-synchronization/node-service/garden.yml @@ -1,25 +1,30 @@ -kind: Module +kind: Build +name: node-service +type: container + +--- +kind: Deploy description: Node greeting service name: node-service type: container -services: - - name: node-service - args: [npm, start] - sync: - command: [npm, run, dev] # Overrides the container's default when the service is deployed in sync mode - paths: - - source: src - target: /app/src - # Make sure to specify any paths that should not be synced! - exclude: [node_modules] - mode: one-way - ports: - - name: http - containerPort: 8080 - ingresses: - - path: /hello - port: http - healthCheck: - httpGet: - path: /_ah/health - port: http +build: node-service +spec: + args: [npm, start] + sync: + command: [npm, run, dev] # Overrides the container's default when the service is deployed in dev mode + paths: + - source: src + target: /app/src + # Make sure to specify any paths that should not be synced! + exclude: [node_modules] + mode: one-way + ports: + - name: http + containerPort: 8080 + ingresses: + - path: /hello + port: http + healthCheck: + httpGet: + path: /_ah/health + port: http diff --git a/examples/code-synchronization/node-service/src/app.js b/examples/code-synchronization/node-service/src/app.js index 2d958edd04..7df677c318 100644 --- a/examples/code-synchronization/node-service/src/app.js +++ b/examples/code-synchronization/node-service/src/app.js @@ -3,7 +3,7 @@ const express = require("express") const app = express() app.get("/hello", (req, res) => { - res.json({message: "Hello from Node!"}) + res.json({ message: "Hello from Node!" }) }) // This is the path GAE uses for health checks