Skip to content

Commit

Permalink
fix(remote-building): use "Recreate" strategy garden-util (kaniko) an…
Browse files Browse the repository at this point in the history
…d garden-buildkit deployments (#5125)

We need to use the "Recreate" 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 authored Sep 21, 2023
1 parent 2df5c54 commit 541851b
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 541851b

Please sign in to comment.