Skip to content

Commit

Permalink
fix(k8s): use module ns in getServiceResource
Browse files Browse the repository at this point in the history
When provided, we now use the custom namespace defined in
`module.spec.namespace` for `helm` and `kubernetes` modules
when getting the module's `serviceResource`.
  • Loading branch information
thsig committed Nov 1, 2021
1 parent 58cb571 commit 62dadfc
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions core/src/plugins/kubernetes/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { gardenAnnotationKey, base64, deline, stableStringify } from "../../util
import { inClusterRegistryHostname, MAX_CONFIGMAP_DATA_SIZE, systemDockerAuthSecretName } from "./constants"
import { ContainerEnvVars } from "../container/config"
import { ConfigurationError, DeploymentError, PluginError } from "../../exceptions"
import { ServiceResourceSpec, KubernetesProvider } from "./config"
import { ServiceResourceSpec, KubernetesProvider, KubernetesPluginContext } from "./config"
import { LogEntry } from "../../logger/log-entry"
import { PluginContext } from "../../plugin-context"
import { HelmModule } from "./helm/config"
Expand All @@ -31,7 +31,7 @@ import { ProviderMap } from "../../config/provider"
import { PodRunner } from "./run"
import { isSubset } from "../../util/is-subset"
import { checkPodStatus } from "./status/pod"
import { getAppNamespace } from "./namespace"
import { getModuleNamespace } from "./namespace"

export const skopeoImage = "gardendev/skopeo:1.41.0-2"

Expand Down Expand Up @@ -562,7 +562,13 @@ export async function getServiceResource({

if (resourceSpec.podSelector && !isEmpty(resourceSpec.podSelector)) {
const api = await KubeApi.factory(log, ctx, provider)
const namespace = await getAppNamespace(ctx, log, provider)
const k8sCtx = ctx as KubernetesPluginContext
const namespace = await getModuleNamespace({
ctx: k8sCtx,
log,
module,
provider: k8sCtx.provider,
})

const pods = await getReadyPods(api, namespace, resourceSpec.podSelector)
const pod = sample(pods)
Expand Down

0 comments on commit 62dadfc

Please sign in to comment.