Skip to content

Instantly share code, notes, and snippets.

@phstudy
Created March 7, 2019 14:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phstudy/5512dec6e1b652c6df4b272eec22749c to your computer and use it in GitHub Desktop.
Save phstudy/5512dec6e1b652c6df4b272eec22749c to your computer and use it in GitHub Desktop.
k8s_tips

Pod log 寫到不同檔案

傳遞 Pod 資訊僅能透過 環境變數 與 檔案

使用環境變數搭配 envsubst 設定 nginx configuration file 方法

共用 Deployment 設定檔

看起來只能用參數化的方式

在 osx 使用 envsubst 的方法

brew install gettext
brew link --force gettext 

sample:

curl -O https://gist.githubusercontent.com/phstudy/dfe627d955d3a8bfec18a258fd679c62/raw/a666faf4252a809ec689d75b0e5539849f166d75/nginx-deployment.yaml.tmpl

DEPLOYMENT_NAME=nginx-deployment-1 envsubst < nginx-deployment.yaml.tmpl | kubectl create -f -

DEPLOYMENT_NAME=nginx-deployment-2 envsubst < nginx-deployment.yaml.tmpl | kubectl create -f -

DEPLOYMENT_NAME=nginx-deployment-3 envsubst < nginx-deployment.yaml.tmpl | kubectl create -f -

Memory 使用超過時,pod 被 kill 的行為

  • If a Container exceeds its memory limit, it might be terminated. If it is restartable, the kubelet will restart it, as with any other type of runtime failure.

  • If a Container exceeds its memory request, it is likely that its Pod will be evicted whenever the node runs out of memory.

  • A Container might or might not be allowed to exceed its CPU limit for extended periods of time. However, it will not be killed for excessive CPU usage.

  • To determine whether a Container cannot be scheduled or is being killed due to resource limits, see the Troubleshooting section.

References:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment