docker - task.Container moving from docker to kubernetes
问题描述
I'm trying to bring docker container to kubernetes. In docker you can ask the dns for :
host tasks.containername
The result are all internal IPs from running containers with this name.
I do the same on kubernetes, by using the headless-services. I can do
host pod-name
The result are also all internal IPs from the pods.
So far so good but there are a lot of "run.sh" scripts that uses the "task.XXX" query. Have someone a idea how to fix this without editing all run.sh scripts ?
Maybe something in the coredns, with mapping.
best and thank you
解决方案
我同意编辑脚本是最明智的解决方案,但这里是在 kubernetes 中编辑 coredns 的方法。
kubectl edit configmap coredns -n kube-system
然后添加如下重写配置。
rewrite name tasks.containername.default.svc.cluster.local containername.default.svc.cluster.local
例如
.:53 {
errors
log
health
rewrite name tasks.containername.default.svc.cluster.local containername.default.svc.cluster.local
kubernetes cluster.local 10.0.0.0/24
proxy . /etc/resolv.conf
cache 30
}
然后重新加载 coredns 如下
kubectl exec -n kube-system coredns-xxxxxxx -- kill -SIGUSR1 1
推荐阅读
- google-chrome - Chrome v91,AADSTS50196:服务器终止操作,因为它遇到客户端请求循环。请联系您的应用供应商
- javascript - 传单在显示位置重复时提供无效的 Lng/Lat 坐标
- python - 使用 selenium python 循环遍历元素时遇到问题
- typescript - 空传播函数类型注释
- c++ - 尝试在 opencv 4.5.1 中使用 SIFT 提取特征时出现问题
- myhdl - MyHDL 0.11 在一个简单的解复用器实现上出错
- ios - 如何使用预定功能更改 Firestore 文档中的布尔值?
- python - 如何在显示 QMenu 时将鼠标焦点转移回来?
- javascript - 数组javascript中具有相同id值的超大数据
- c++ - C++:用于创建聚合类的结构设计模式,其成分表达了他们想要公开的内容