如何获得 Kubernetes 内服务的完整 FQDN?
? k get svc -o wide
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR
airflow-flower-service ClusterIP 172.20.119.107 <none> 5555/TCP 20d app=edna-airflow
airflow-service ClusterIP 172.20.76.63 <none> 80/TCP 20d app=edna-airflow
backend-service ClusterIP 172.20.39.154 <none> 80/TCP 20d app=edna-backend
Run Code Online (Sandbox Code Playgroud)
那么如何查询内部 Kubernetes DNS 以获取后端服务的 FQDN?
\xe2\x9e\x9c k get pods -n edna \nNAME READY STATUS RESTARTS AGE\nairflow-79d5f59644-dd4k7 1/1 Running 0 16h\nairflow-worker-67bcf7844b-rq7r8 1/1 Running 0 22h\nbackend-65bcb6546-wvvqj 1/1 Running 0 2d16h\n\n
Run Code Online (Sandbox Code Playgroud)\n因此,在airflow-79d5f59644-dd4k7 pod中运行的气流正在尝试从气流工作人员(celery/python,运行一个基于烧瓶的简单Web服务器处理日志)中提取日志,但它不能,因为域名airflow-worker-67bcf7844b- rq7r8未在airflow-79d5f59644-dd4k7内解析
\n*** Log file does not exist: /usr/local/airflow/logs/hello_world/hello_task/2020-07-14T22:05:12.123747+00:00/1.log\n*** Fetching from: http://airflow-worker-67bcf7844b-rq7r8:8793/log/hello_world/hello_task/2020-07-14T22:05:12.123747+00:00/1.log\n*** Failed to fetch log file from worker. HTTPConnectionPool(host=\'airflow-worker-67bcf7844b-rq7r8\', port=8793): Max retries exceeded with url: /log/hello_world/hello_task/2020-07-14T22:05:12.123747+00:00/1.log (Caused by NewConnectionError(\'<urllib3.connection.HTTPConnection object at 0x7fd37d6a9790>: Failed to establish a new connection: [Errno -2] Name or service not known\'))\n\n
Run Code Online (Sandbox Code Playgroud)\n我怎样才能做到这一点?
\n我知道 Airflow …
但如果我可以使用任何 kubernetes 命令获取资源类型的 dns,我的工作就会容易得多。还尝试了这个命令链接
例如,我想获取db-service
在dev
命名空间内运行的服务的 dns 名称svc.cluster.local
db-service.dev.svc.cluster.local
Run Code Online (Sandbox Code Playgroud)
有什么指点吗?