我正在尝试更新我们拥有的kubernetes模板,以便在容器启动时可以传递诸如--db-config <value>
之类的参数。
这显然是不对的,因为没有被捡起
...
containers:
- name: {{ .Chart.Name }}
...
args: ["--db-config", "/etc/app/cfg/db.yaml", "--tkn-config", "/etc/app/cfg/tkn.yaml"] <-- WHY IS THIS NOT WORKING
答案 0 :(得分:1)
以下是显示您的方法有效的示例:
main.go:
package main
import "flag"
import "fmt"
func main() {
db := flag.String("db-config", "default", "some flag")
tk := flag.String("tk-config", "default", "some flag")
flag.Parse()
fmt.Println("db-config:", *db)
fmt.Println("tk-config:", *tk)
}
Dockerfile [简体]:
FROM scratch
ADD kube-flags /
ENTRYPOINT ["/kube-flags"]
测试:
docker run kube-flags:180906
db-config: default
tk-config: default
docker run kube-flags:180906 --db-config=henry
db-config: henry
tk-config: default
pod.yaml:
apiVersion: v1
kind: Pod
metadata:
name: test
spec:
containers:
- image: gcr.io/.../kube-flags:180906
imagePullPolicy: Always
name: test
args:
- --db-config
- henry
- --tk-config
- turnip
测试:
kubectl logs test
db-config: henry
tk-config: turnip