-
Notifications
You must be signed in to change notification settings - Fork 273
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improvement(k8s): default in-cluster registry namespace to project name
This means that by default builds are shared between users when sharing a cluster. Image _layers_ were anyway shared, but this change will accelerate builds and tests through reducing the number of steps involved when all layers already exist. Co-authored-by: swist <[email protected]>
- Loading branch information
Showing
4 changed files
with
110 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
garden-service/test/unit/src/plugins/kubernetes/kubernetes.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/* | ||
* Copyright (C) 2018-2020 Garden Technologies, Inc. <[email protected]> | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
import { configureProvider } from "../../../../../src/plugins/kubernetes/kubernetes" | ||
import { KubernetesConfig, defaultResources, defaultStorage } from "../../../../../src/plugins/kubernetes/config" | ||
import { defaultSystemNamespace } from "../../../../../src/plugins/kubernetes/system" | ||
import { makeDummyGarden } from "../../../../../src/cli/cli" | ||
import { expect } from "chai" | ||
import { TempDirectory, makeTempDir } from "../../../../helpers" | ||
|
||
describe("kubernetes configureProvider", () => { | ||
const basicConfig: KubernetesConfig = { | ||
name: "kubernetes", | ||
buildMode: "local-docker", | ||
context: "my-cluster", | ||
defaultHostname: "my.domain.com", | ||
forceSsl: false, | ||
gardenSystemNamespace: defaultSystemNamespace, | ||
imagePullSecrets: [], | ||
ingressClass: "nginx", | ||
ingressHttpPort: 80, | ||
ingressHttpsPort: 443, | ||
resources: defaultResources, | ||
storage: defaultStorage, | ||
registryProxyTolerations: [], | ||
tlsCertificates: [], | ||
_systemServices: [], | ||
} | ||
|
||
let tmpDir: TempDirectory | ||
|
||
beforeEach(async () => { | ||
tmpDir = await makeTempDir({ git: true }) | ||
}) | ||
|
||
afterEach(async () => { | ||
await tmpDir.cleanup() | ||
}) | ||
|
||
context("cluster-docker mode", () => { | ||
it("should set a default deploymentRegistry with projectName as namespace", async () => { | ||
const garden = await makeDummyGarden(tmpDir.path) | ||
const config: KubernetesConfig = { | ||
...basicConfig, | ||
buildMode: "cluster-docker", | ||
} | ||
|
||
const result = await configureProvider({ | ||
projectName: garden.projectName, | ||
projectRoot: garden.projectRoot, | ||
config, | ||
log: garden.log, | ||
dependencies: [], | ||
configStore: garden.configStore, | ||
}) | ||
|
||
expect(result.config.deploymentRegistry).to.eql({ | ||
hostname: "127.0.0.1:5000", | ||
namespace: garden.projectName, | ||
}) | ||
}) | ||
|
||
it("should allow overriding the deploymentRegistry namespace for the in-cluster registry", async () => { | ||
const garden = await makeDummyGarden(tmpDir.path) | ||
const config: KubernetesConfig = { | ||
...basicConfig, | ||
buildMode: "cluster-docker", | ||
deploymentRegistry: { | ||
hostname: "127.0.0.1:5000", | ||
namespace: "my-namespace", | ||
}, | ||
} | ||
|
||
const result = await configureProvider({ | ||
projectName: garden.projectName, | ||
projectRoot: garden.projectRoot, | ||
config, | ||
log: garden.log, | ||
dependencies: [], | ||
configStore: garden.configStore, | ||
}) | ||
|
||
expect(result.config.deploymentRegistry).to.eql({ | ||
hostname: "127.0.0.1:5000", | ||
namespace: "my-namespace", | ||
}) | ||
}) | ||
}) | ||
}) |