You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

执行kubectl apply部署Redis遇DNS解析错误,求解决方案

Fixing Kubectl Connection Issues with Your Kubernetes Cluster

Let’s work through resolving your connection problems step by step:

1. Remove the conflicting environment variable

The KUBERNETES_MASTER environment variable you set is overriding your kubeconfig settings, and it’s pointing to the wrong port (your cluster uses 6443, not 8080). First, unset this variable to let kubectl use your valid config:

unset KUBERNETES_MASTER

2. Fix your kubeconfig server address

Your ./kube/config shows the server as https://****:6443, but kubectl cluster-info confirms the master runs at 192.168.219.107:6443. Update the config to match the actual IP:

  • Open your config file (either ~/.kube/config or ./kube/config if using a custom path)
  • Find the server line under the clusters section and replace **** with 192.168.219.107, so it reads:
    server: https://192.168.219.107:6443
    
  • Save the file, and set secure permissions to avoid warnings:
    chmod 600 ~/.kube/config
    

3. Resolve the DNS lookup failure

The error dial tcp: lookup MasterIP on 127.0.0.53:53: server misbehaving means your system can’t resolve the MasterIP hostname to an IP.

  • If MasterIP is just a placeholder, replace it with 192.168.219.107 wherever you’re referencing the master node.
  • If MasterIP is supposed to be a valid hostname, add an entry to your local hosts file to bypass DNS issues:
    echo "192.168.219.107 MasterIP" | sudo tee -a /etc/hosts
    

4. Test the connection and reapply your deployment

After making these changes, verify kubectl can connect to the cluster:

kubectl cluster-info

You should see the master running at 192.168.219.107:6443 without errors. Then try applying your Redis deployment again:

kubectl apply -f redis.yaml

5. Additional checks if issues persist

  • Confirm your master node is reachable: ping 192.168.219.107 to test network connectivity.
  • If connecting to a remote cluster, ensure port 6443 is open in any firewalls between your machine and the master node.

内容的提问来源于stack exchange,提问作者chichi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.08 18:32:33