Skip to content

Commit

Permalink
fix(local-mode): fixed some bugs in local mode config (#3311)
Browse files Browse the repository at this point in the history
* fix(local-mode): fixed some bugs in local mode config

* Always erase the original container's command - it might not be recognized by a proxy container
* Always delete the startup probe to avoid potential timeout issues
* Always overwrite env variables and erase envFrom of a proxy container - credentials and another service-level env vars are not necessary to set up a reverse proxy
* Always erase all mounted devices and volumes in a proxy container
* Corrected port configuration in the example. Duplicate servicePorts are not allowed.
  • Loading branch information
vvagaytsev committed Oct 19, 2022
1 parent 4850aa9 commit ee97935
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
19 changes: 11 additions & 8 deletions core/src/plugins/kubernetes/local-mode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,17 +342,20 @@ function patchSyncableManifest(

// use reverse proxy container image
targetContainer.image = k8sReverseProxyImageName
// erase the original container command, the proxy container won't recognize it
targetContainer.command = []
// erase the original container arguments, the proxy container won't recognize them
targetContainer.args = []

const extraEnvVars = prepareEnvVars(localModeEnvVars)
if (!targetContainer.env) {
targetContainer.env = []
}
// prevent duplicate env vars
const extraEnvVarNames = new Set(extraEnvVars.map((v) => v.name))
remove(targetContainer.env, (v) => extraEnvVarNames.has(v.name))
targetContainer.env.push(...extraEnvVars)
// overwrite env vars of the proxy container,
// it needs only some specific variables to make reverse proxy work
targetContainer.env = prepareEnvVars(localModeEnvVars)
// ignore envFrom if any defined
targetContainer.envFrom = []

// remove all mounted volumes and devices from the proxy container
targetContainer.volumeMounts = []
targetContainer.volumeDevices = []

if (!targetContainer.ports) {
targetContainer.ports = []
Expand Down
3 changes: 0 additions & 3 deletions examples/local-mode/backend-1/garden.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ services:
containerPort: 8080
# Maps service:80 -> container:8080
servicePort: 80
- name: http2
containerPort: 8000
servicePort: 80
ingresses:
- path: ${var.ingressPath}
port: http # http2 can be used as an alternative port here
Expand Down

0 comments on commit ee97935

Please sign in to comment.