Sat*_*nde 6 kubernetes kubernetes-helm
因此,我正在 kubernetes sing helm 图表上部署我的应用程序堆栈,现在我需要在我的 pods /etc/hosts 文件中添加一些依赖的服务器 IP 和主机名,因此在这种情况下需要帮助
Chr*_*ian 12
原始问题的舵模板解决方案。我用 helm 3 测试了这个。
apiVersion: apps/v1
kind: Deployment
spec:
template:
spec:
{{- with .Values.hostAliases }}
hostAliases:
{{ toYaml . | indent 8 }}
{{- end }}
Run Code Online (Sandbox Code Playgroud)
对于诸如以下的值:
hostAliases:
- ip: "10.0.0.1"
hostnames:
- "host.domain.com"
Run Code Online (Sandbox Code Playgroud)
如果值中省略或注释掉了 hostAliases,则在呈现模板时将省略 hostAliases 部分。
正如文档中所述,您可以使用主机别名功能向 POD 添加额外的主机
文档中的示例:
apiVersion: v1
kind: Pod
metadata:
name: hostaliases-pod
spec:
restartPolicy: Never
hostAliases:
- ip: "127.0.0.1"
hostnames:
- "foo.local"
- "bar.local"
- ip: "10.1.2.3"
hostnames:
- "foo.remote"
- "bar.remote"
containers:
- name: cat-hosts
image: busybox
command:
- cat
args:
- "/etc/hosts"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
13829 次 |
| 最近记录: |