Skip to content

Commit

Permalink
fix(remote-building): use "Replace" strategy garden-util (kaniko) and…
Browse files Browse the repository at this point in the history
… garden-buildkit deployments

We need to use the "Replace" strategy for garden-util and garden-buildkit deployments, because
otherwise we can run into issues where multiple Pods are running at the same time

Also with the latest main I often get an error "Could not find a running Pod in Deployment garden-buildkit in namespace xxx" – this change fixes that too.
  • Loading branch information
stefreak committed Sep 21, 2023
1 parent c5d8fe5 commit 3bd6771
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions core/src/plugins/kubernetes/container/build/buildkit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,11 @@ export function getBuildkitDeployment(
app: buildkitDeploymentName,
},
},
strategy: {
// Note: When updating the deployment, we make sure to kill off old buildkit pods before new pods are started.
// This is important because with multiple running Pods we might end up syncing or building to the wrong Pod.
type: "Recreate",
},
template: {
metadata: {
labels: {
Expand Down
5 changes: 5 additions & 0 deletions core/src/plugins/kubernetes/container/build/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,11 @@ export function getUtilManifests(
app: utilDeploymentName,
},
},
strategy: {
// Note: When updating the deployment, we make sure to kill off old buildkit pods before new pods are started.
// This is important because with multiple running Pods we might end up syncing or building to the wrong Pod.
type: "Recreate",
},
template: {
metadata: {
labels: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ describe("buildkit build", () => {
},
})

expect(result.spec.strategy).eql({
type: "Recreate",
})

expect(result.spec.template.spec?.containers.length === 2)

expect(result.spec.template.spec?.containers[0]).eql({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ describe("common build", () => {
spec: {
replicas: 1,
selector: { matchLabels: { app: "garden-util" } },
strategy: {
type: "Recreate",
},
template: {
metadata: { labels: { app: "garden-util" }, annotations: undefined },
spec: {
Expand Down

0 comments on commit 3bd6771

Please sign in to comment.