如何从Kubernetes pod访问外部世界

时间:2017-08-03 13:37:29

标签: kubernetes

我遇到的问题是我无法使用smtp.gmail.com587端口从K8s pod发送电子邮件。我尝试使用dnsPolicy: ClusterFirstWithHostNet但没有任何改变。使用dnsPolicy: Default一切似乎都可以,但我无法使用此方法,因为pod应该能够解析群集中的其他pod。顺便说一句,ConfigMap与谷歌的dns也没有帮助:

apiVersion: v1
kind: ConfigMap
metadata:
  name: kube-dns
  namespace: kube-system
data:
  upstreamNameservers: |
    [“8.8.8.8”, “8.8.4.4”]

有什么想法吗?
提前致谢。
PS,我的Kubernetes版本是v1.7.2

2 个答案:

答案 0 :(得分:2)

也许只是你的configmap中带语法错误(“vs”) 如果你跑 #!/bin/bash source_string="8=FIX|35=c|79=1|80=5|31=2|80=9|31=3|44=TEST|33=1.0|9=sample|10=Test" json_string="{8:FIX, 35:c, 79:[{80:5,31:2},{80:9}], 33:1.0, 44:TEST, 10:Test, 9:sample}" # get the count of uniq keys on source_string in file "source_key_count" grep -oP '[^\W]+(?==)' <<<"$source_string" | sort | uniq -c > source_key_count # get the count of uniq keys on json_string in file "json_key_count" grep -oP '(?<=[ ,{])[^\W]+(?=:)' <<<"$json_string" | sort | uniq -c > json_key_count echo "== join ==" # show tabular comparation of counts: key source json join -1 2 -2 2 source_key_count json_key_count | column -t echo "== diff ==" # show differences between both files diff source_key_count json_key_count 你会得到一个语法错误,而不是 kubectl -n kube-system logs kube-dns-xxxx -c dnsmasq

答案 1 :(得分:0)

还有另一种解决此问题的方法 - 您可以在启动时在容器的resolve.conf中编写Google DNS(8.8.8.8)。

相关问题