Skip to content

Commit

Permalink
fix(k8s): name releases based on their namespace
Browse files Browse the repository at this point in the history
This avoids potential conflicts when multiple sub-projects have the
same name.

BREAKING CHANGE:
Users may need to delete and re-init their projects when using the
Kubernetes plugins after installing this update, because Helm may get
confused by the changes.
  • Loading branch information
edvald authored and thsig committed Sep 17, 2018
1 parent d1c59d4 commit 5fe26e9
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions garden-cli/src/plugins/kubernetes/helm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ export const helmHandlers: Partial<ModuleAndServiceActions<HelmModule>> = {
const provider = ctx.provider
const chartPath = await getChartPath(module)
const valuesPath = getValuesPath(chartPath)
const releaseName = getReleaseName(ctx, service)
const namespace = await getAppNamespace(ctx, ctx.provider)
const releaseName = getReleaseName(namespace, service)

const releaseStatus = await getReleaseStatus(ctx.provider, releaseName)

Expand Down Expand Up @@ -170,7 +170,8 @@ export const helmHandlers: Partial<ModuleAndServiceActions<HelmModule>> = {

async deleteService(params: DeleteServiceParams): Promise<ServiceStatus> {
const { ctx, logEntry, service } = params
const releaseName = getReleaseName(ctx, service)
const namespace = await getAppNamespace(ctx, ctx.provider)
const releaseName = getReleaseName(namespace, service)
await helm(ctx.provider, "delete", "--purge", releaseName)
logEntry && logEntry.setSuccess("Service deleted")

Expand Down Expand Up @@ -241,7 +242,7 @@ async function getChartObjects(ctx: PluginContext, service: Service) {
const chartPath = await getChartPath(service.module)
const valuesPath = getValuesPath(chartPath)
const namespace = await getAppNamespace(ctx, ctx.provider)
const releaseName = getReleaseName(ctx, service)
const releaseName = getReleaseName(namespace, service)

const objects = <KubernetesObject[]>safeLoadAll(await helm(ctx.provider,
"template",
Expand Down Expand Up @@ -288,8 +289,8 @@ async function getServiceStatus(
return { state, version: version.versionString }
}

function getReleaseName(ctx: PluginContext, service: Service) {
return `garden--${ctx.projectName}--${service.name}`
function getReleaseName(namespace: string, service: Service) {
return `${namespace}--${service.name}`
}

async function getReleaseStatus(provider: KubernetesProvider, releaseName: string): Promise<ServiceStatus> {
Expand Down

0 comments on commit 5fe26e9

Please sign in to comment.