diff --git a/garden-service/src/docs/config.ts b/garden-service/src/docs/config.ts index 6d10b331aa..cd18d96d4a 100644 --- a/garden-service/src/docs/config.ts +++ b/garden-service/src/docs/config.ts @@ -24,7 +24,7 @@ import { execModuleSpecSchema } from "../plugins/exec" import { projectSchema } from "../config/project" import { baseModuleSpecSchema } from "../config/module" import handlebars = require("handlebars") -import { configSchema as localK8sConfigSchema } from "../plugins/kubernetes/local" +import { configSchema as localK8sConfigSchema } from "../plugins/kubernetes/local/local" import { configSchema as k8sConfigSchema } from "../plugins/kubernetes/kubernetes" import { configSchema as openfaasConfigSchema } from "../plugins/openfaas/openfaas" import { openfaasModuleSpecSchema } from "../plugins/openfaas/openfaas" diff --git a/garden-service/src/garden.ts b/garden-service/src/garden.ts index a6d62d2e97..c8c0c4d4ec 100644 --- a/garden-service/src/garden.ts +++ b/garden-service/src/garden.ts @@ -444,15 +444,16 @@ export class Garden { // call configureProvider action if provided const configureHandler = actions.configureProvider - if (configureHandler) { - const configureOutput = await configureHandler({ config: providerConfig }) - providerConfig = configureOutput.config - } if (plugin.configSchema) { providerConfig = validate(providerConfig, plugin.configSchema, { context: `${pluginName} configuration` }) } + if (configureHandler) { + const configureOutput = await configureHandler({ config: providerConfig }) + providerConfig = configureOutput.config + } + if (providerIndex === -1) { this.environment.providers.push({ name: pluginName, config: providerConfig }) } else { diff --git a/garden-service/src/plugins/kubernetes/local.ts b/garden-service/src/plugins/kubernetes/local/local.ts similarity index 88% rename from garden-service/src/plugins/kubernetes/local.ts rename to garden-service/src/plugins/kubernetes/local/local.ts index d6762e5c54..7e03027970 100644 --- a/garden-service/src/plugins/kubernetes/local.ts +++ b/garden-service/src/plugins/kubernetes/local/local.ts @@ -10,16 +10,16 @@ import * as execa from "execa" import { safeLoad } from "js-yaml" import * as Joi from "joi" import { join } from "path" -import { GardenPlugin, PluginFactoryParams } from "../../types/plugin/plugin" +import { GardenPlugin, PluginFactoryParams } from "../../../types/plugin/plugin" import { gardenPlugin as k8sPlugin, KubernetesBaseConfig, kubernetesConfigBase, -} from "./kubernetes" +} from "../kubernetes" import { readFile } from "fs-extra" import { homedir } from "os" -import { getLocalEnvironmentStatus, prepareLocalEnvironment } from "./init" -import { ConfigureProviderParams } from "../../types/plugin/params" +import { getLocalEnvironmentStatus, prepareLocalEnvironment } from "../init" +import { ConfigureProviderParams } from "../../../types/plugin/params" // TODO: split this into separate plugins to handle Docker for Mac and Minikube @@ -52,6 +52,7 @@ async function setMinikubeDockerEnv() { export interface LocalKubernetesConfig extends KubernetesBaseConfig { _system?: Symbol + setupIngressController: string | boolean | null } export const configSchema = kubernetesConfigBase @@ -80,6 +81,7 @@ export function gardenPlugin({ projectName, log }: PluginFactoryParams): GardenP plugin.actions!.configureProvider = async ({ config }: ConfigureProviderParams) => { let context = config.context let defaultHostname = config.defaultHostname + let setupIngressController = config.setupIngressController if (!context) { // automatically detect supported kubectl context if not explicitly configured @@ -117,11 +119,15 @@ export function gardenPlugin({ projectName, log }: PluginFactoryParams): GardenP defaultHostname = `${projectName}.${minikubeIp}.nip.io` } - await Promise.all([ - // TODO: wait for ingress addon to be ready, if it was previously disabled - execa("minikube", ["addons", "enable", "ingress"]), - setMinikubeDockerEnv(), - ]) + if (config.setupIngressController === "nginx") { + log.silly("Using minikube's ingress addon") + await execa("minikube", ["addons", "enable", "ingress"]) + // make sure the prepare handler doesn't also set up the ingress controller + setupIngressController = false + } + + await setMinikubeDockerEnv() + } else { if (!defaultHostname) { defaultHostname = `${projectName}.local.app.garden` @@ -142,6 +148,7 @@ export function gardenPlugin({ projectName, log }: PluginFactoryParams): GardenP ingressHttpsPort: 443, ingressClass: "nginx", namespace: config.namespace || projectName, + setupIngressController, tlsCertificates: config.tlsCertificates, _system: config._system, } diff --git a/garden-service/src/plugins/kubernetes/status.ts b/garden-service/src/plugins/kubernetes/status.ts index e85c77f347..24e5fe686d 100644 --- a/garden-service/src/plugins/kubernetes/status.ts +++ b/garden-service/src/plugins/kubernetes/status.ts @@ -184,22 +184,24 @@ export async function checkDeploymentStatus( if (event.involvedObject.kind === "Pod") { const logs = await getPodLogs(api, namespace, [event.involvedObject.name]) - out.logs = dedent` - - kubectl -n ${namespace} --context=${api.context} logs ${event.involvedObject.name} + if (logs) { + out.logs = dedent` + + kubectl -n ${namespace} --context=${api.context} logs ${event.involvedObject.name} - ${logs} - ` + ` + logs + } } else { const pods = await getPods(api, namespace, statusRes.spec.selector.matchLabels) const logs = await getPodLogs(api, namespace, pods.map(pod => pod.metadata.name)) - out.logs = dedent` - - kubectl -n ${namespace} --context=${api.context} logs ${obj.kind.toLowerCase()}/${obj.metadata.name} + if (logs) { + out.logs = dedent` + + kubectl -n ${namespace} --context=${api.context} logs ${obj.kind.toLowerCase()}/${obj.metadata.name} - ${logs} - ` + ` + logs + } } return out diff --git a/garden-service/src/plugins/plugins.ts b/garden-service/src/plugins/plugins.ts index 822b78e156..0708f3647e 100644 --- a/garden-service/src/plugins/plugins.ts +++ b/garden-service/src/plugins/plugins.ts @@ -13,7 +13,7 @@ const container = require("./container/container") const gcf = require("./google/google-cloud-functions") const localGcf = require("./local/local-google-cloud-functions") const kubernetes = require("./kubernetes/kubernetes") -const localKubernetes = require("./kubernetes/local") +const localKubernetes = require("./kubernetes/local/local") const npmPackage = require("./npm-package") const gae = require("./google/google-app-engine") const openfaas = require("./openfaas/openfaas")