Skip to content

Commit

Permalink
fix(k8s): startup error when using remote kubernetes provider
Browse files Browse the repository at this point in the history
  • Loading branch information
edvald committed Jun 10, 2019
1 parent 244313d commit b15b30f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 18 deletions.
1 change: 0 additions & 1 deletion garden-service/src/plugins/container/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,6 @@ export interface ContainerRegistryConfig {
export const containerRegistryConfigSchema = Joi.object()
.keys({
hostname: Joi.string()
.hostname()
.required()
.description("The hostname (and optionally port, if not the default port) of the registry.")
.example("gcr.io"),
Expand Down
9 changes: 1 addition & 8 deletions garden-service/src/plugins/kubernetes/kubernetes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,6 @@ export async function configureProvider({ projectName, config }: ConfigureProvid
}

if (config.buildMode === "cluster-docker") {
if (config.deploymentRegistry) {
throw new ConfigurationError(
`kubernetes: deploymentRegistry should not be set in config if using cluster-docker build mode`,
{ config },
)
}

// This is a special configuration, used in combination with the registry-proxy service,
// to make sure every node in the cluster can resolve the image from the registry we deploy in-cluster.
config.deploymentRegistry = {
Expand All @@ -55,7 +48,7 @@ export async function configureProvider({ projectName, config }: ConfigureProvid
// Deploy build services on init
config._systemServices.push("docker-daemon", "docker-registry", "registry-proxy")

} else if (!config.deploymentRegistry) {
} else if (config.name !== "local-kubernetes" && !config.deploymentRegistry) {
throw new ConfigurationError(
`kubernetes: must specify deploymentRegistry in config if using local build mode`,
{ config },
Expand Down
20 changes: 11 additions & 9 deletions garden-service/src/plugins/kubernetes/system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import * as semver from "semver"

import { STATIC_DIR, DEFAULT_API_VERSION } from "../../constants"
import { Garden } from "../../garden"
import { KubernetesProvider, KubernetesPluginContext } from "./config"
import { KubernetesProvider, KubernetesPluginContext, KubernetesConfig } from "./config"
import { LogEntry } from "../../logger/log-entry"
import { KubeApi } from "./api"
import { createNamespace } from "./namespace"
Expand All @@ -34,6 +34,15 @@ export const systemNamespace = "garden-system"
export const systemMetadataNamespace = "garden-system--metadata"

export async function getSystemGarden(provider: KubernetesProvider, variables: PrimitiveMap): Promise<Garden> {
const sysProvider: KubernetesConfig = {
...provider.config,

environments: ["default"],
name: provider.name,
namespace: systemNamespace,
_systemServices: [],
}

return Garden.factory(systemProjectPath, {
environmentName: "default",
config: {
Expand All @@ -45,14 +54,7 @@ export async function getSystemGarden(provider: KubernetesProvider, variables: P
environments: [
{ name: "default", variables: {} },
],
providers: [
{
name: "local-kubernetes",
context: provider.config.context,
namespace: systemNamespace,
_systemServices: [],
},
],
providers: [sysProvider],
variables,
},
})
Expand Down

0 comments on commit b15b30f

Please sign in to comment.