diff --git a/docs/basics/installation.md b/docs/basics/installation.md index d88a34d0ea..96a3812343 100644 --- a/docs/basics/installation.md +++ b/docs/basics/installation.md @@ -143,12 +143,6 @@ is set as the current context, Docker for Mac is preferred by default. (If you're not yet familiar with Garden configuration files, see: [Configuration files](../using-garden/configuration-files.md)) -### Hostname - -Garden needs the Kubernetes instance to have a hostname. By default Garden will use `.nip.io`. If you'd -like to use a custom hostname, you can specify it via the `ingressHostname` in the `local-kubernetes` provider config -(see above). - ### Anything else? Once the above is set up, the `local-kubernetes` plugin will automatically configure everything else Garden needs to diff --git a/garden-service/src/plugins/kubernetes/container/ingress.ts b/garden-service/src/plugins/kubernetes/container/ingress.ts index 4cc0fcb819..cbc9c10d1f 100644 --- a/garden-service/src/plugins/kubernetes/container/ingress.ts +++ b/garden-service/src/plugins/kubernetes/container/ingress.ts @@ -54,10 +54,13 @@ export async function createIngresses(api: KubeApi, namespace: string, service: const cert = certIngresses[0].certificate const annotations = { - "kubernetes.io/ingress.class": api.provider.config.ingressClass, "ingress.kubernetes.io/force-ssl-redirect": !!cert + "", } + if (api.provider.config.ingressClass) { + annotations["kubernetes.io/ingress.class"] = api.provider.config.ingressClass + } + const spec: any = { rules } if (!!cert) { diff --git a/garden-service/src/plugins/kubernetes/init.ts b/garden-service/src/plugins/kubernetes/init.ts index a61e967a90..93df0ac999 100644 --- a/garden-service/src/plugins/kubernetes/init.ts +++ b/garden-service/src/plugins/kubernetes/init.ts @@ -27,7 +27,7 @@ import { getAllNamespaces, } from "./namespace" import { KUBECTL_DEFAULT_TIMEOUT, kubectl } from "./kubectl" -import { name as providerName } from "./kubernetes" +import { name as providerName, KubernetesProvider } from "./kubernetes" import { isSystemGarden, getSystemGarden } from "./system" import { PluginContext } from "../../plugin-context" import { LogEntry } from "../../logger/log-entry" @@ -99,12 +99,9 @@ export async function getLocalEnvironmentStatus({ ctx, log }: GetEnvironmentStat const sysCtx = await sysGarden.getPluginContext(ctx.provider.name) const sysStatus = await sysGarden.actions.getStatus({ log }) - const serviceStatuses = ctx.provider.config._systemServices - ? pick(sysStatus.services, ctx.provider.config._systemServices) - : sysStatus.services + const serviceStatuses = pick(sysStatus.services, getSystemServices(ctx.provider)) const servicesReady = every(values(serviceStatuses).map(s => s.state === "ready")) - const systemReady = sysStatus.providers[ctx.provider.config.name].ready && servicesReady if (!systemReady) { @@ -329,11 +326,13 @@ async function configureSystemServices( log, }) - // only deploy services if configured to do so (minikube bundles the required services as addons) - if (!provider.config._systemServices || provider.config._systemServices.length > 0) { + // only deploy services if configured to do so (e.g. minikube bundles some required services as addons) + const systemServices = getSystemServices(ctx.provider) + + if (systemServices.length > 0) { const results = await sysGarden.actions.deployServices({ log, - serviceNames: provider.config._systemServices, + serviceNames: systemServices, force, }) @@ -346,3 +345,13 @@ async function configureSystemServices( } } } + +function getSystemServices(provider: KubernetesProvider) { + const names = ["kubernetes-dashboard"] + + if (provider.config.setupIngressController === "nginx") { + names.push("ingress-controller", "default-backend") + } + + return names +} diff --git a/garden-service/src/plugins/kubernetes/kubernetes.ts b/garden-service/src/plugins/kubernetes/kubernetes.ts index a6599210ca..c1bfc0f8b4 100644 --- a/garden-service/src/plugins/kubernetes/kubernetes.ts +++ b/garden-service/src/plugins/kubernetes/kubernetes.ts @@ -39,7 +39,7 @@ export interface KubernetesBaseConfig extends ProviderConfig { imagePullSecrets: SecretRef[] ingressHttpPort: number ingressHttpsPort: number - ingressClass: string + ingressClass?: string namespace?: string tlsCertificates: IngressTlsCertificate[] } @@ -120,10 +120,9 @@ const configSchema = kubernetesConfigBase .required(), deploymentRegistry: containerRegistryConfigSchema, ingressClass: Joi.string() - .default("nginx") .description(dedent` - The ingress class to use on configured Ingresses when deploying services. **Note that Garden - currently only supports the nginx ingress controller.** + The ingress class to use on configured Ingresses (via the \`kubernetes.io/ingress.class\` annotation) + when deploying \`container\` services. Use this if you have multiple ingress controllers in your cluster. `), ingressHttpPort: Joi.number() .default(80) diff --git a/garden-service/src/plugins/kubernetes/local.ts b/garden-service/src/plugins/kubernetes/local.ts index 5d67e03e7c..28a65a308e 100644 --- a/garden-service/src/plugins/kubernetes/local.ts +++ b/garden-service/src/plugins/kubernetes/local.ts @@ -53,7 +53,6 @@ async function setMinikubeDockerEnv() { export interface LocalKubernetesConfig extends KubernetesBaseConfig { _system?: Symbol - _systemServices?: string[] } const configSchema = kubernetesConfigBase @@ -64,12 +63,11 @@ const configSchema = kubernetesConfigBase "Specify which namespace to deploy services to (defaults to the project name). " + "Note that the framework generates other namespaces as well with this name as a prefix.", ), - ingressHostname: Joi.string() - .description("The hostname of the cluster's ingress controller."), + setupIngressController: Joi.string() + .allow("nginx", false, null) + .default("nginx") + .description("Set this to null or false to skip installing/enabling the `nginx` ingress controller."), _system: Joi.any().meta({ internal: true }), - _systemServices: Joi.array().items(Joi.string()) - .meta({ internal: true }) - .description("The system services which should be automatically deployed to the cluster."), }) .description("The provider configuration for the local-kubernetes plugin.") @@ -80,7 +78,6 @@ export async function gardenPlugin({ projectName, config, log }): Promise