Skip to content

Commit

Permalink
fix(k8s): work around issue with Istio sidecars and ad-hoc pod runs
Browse files Browse the repository at this point in the history
  • Loading branch information
edvald committed Mar 14, 2019
1 parent c5f4c0e commit f8d5b44
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
26 changes: 17 additions & 9 deletions garden-service/src/plugins/kubernetes/container/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import { includes, extend } from "lodash"
import { DeploymentError } from "../../../exceptions"
import { RunResult } from "../../../types/plugin/outputs"
import { RunResult, RunTaskResult } from "../../../types/plugin/outputs"
import {
ExecInServiceParams,
RunModuleParams,
Expand Down Expand Up @@ -114,19 +114,27 @@ export async function runContainerService(
}

export async function runContainerTask(
{ ctx, task, interactive, runtimeContext, log }: RunTaskParams<ContainerModule>,
) {
{ ctx, module, task, interactive, runtimeContext }: RunTaskParams<ContainerModule>,
): Promise<RunTaskResult> {
extend(runtimeContext.envVars, task.spec.env || {})

const result = await runContainerModule({
ctx,
const k8sCtx = <KubernetesPluginContext>ctx
const context = k8sCtx.provider.config.context
const namespace = await getAppNamespace(k8sCtx, k8sCtx.provider)
const image = await containerHelpers.getLocalImageId(module)

const result = await runPod({
context,
namespace,
module,
envVars: runtimeContext.envVars,
args: task.spec.args || [],
image,
interactive,
log,
runtimeContext,
module: task.module,
command: task.spec.args || [],
ignoreError: false,
timeout: task.spec.timeout || 9999,
// Workaround to make sure sidecars are not injected, due to https://github.com/kubernetes/kubernetes/issues/25908
overrides: { metadata: { annotations: { "sidecar.istio.io/inject": "false" } } },
})

return {
Expand Down
7 changes: 6 additions & 1 deletion garden-service/src/plugins/kubernetes/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ interface RunPodParams {
interactive: boolean,
ignoreError: boolean,
timeout?: number,
overrides?: any,
}

export async function runPod(
{ context, namespace, module, image, envVars, args, interactive, ignoreError, timeout }: RunPodParams,
{ context, namespace, module, image, envVars, args, interactive, ignoreError, timeout, overrides }: RunPodParams,
): Promise<RunResult> {
const envArgs = Object.entries(envVars).map(([k, v]) => `--env=${k}=${v}`)

Expand All @@ -40,6 +41,10 @@ export async function runPod(
"-i",
]

if (overrides) {
opts.push("--overrides", `${JSON.stringify(overrides)}`)
}

if (interactive) {
opts.push("--tty")
}
Expand Down

0 comments on commit f8d5b44

Please sign in to comment.