I am trying to start Kubernetes with 'kubectl apply -f redis.yaml' and I am getting
Unable to connect to the server: dial tcp: lookup MasterIP on 127.0.0.53:53: server misbehavingBefore, I was receiving
The connection to the server localhost:8080 was refused - did you specify the right host or port?This error. I was searching for the solution and someone said trying to use this command
export KUBERNETES_MASTER=http://MasterIP:8080After that, I am receiving the error above? How can I fix this?
kubectl cluster-info
Kubernetes master is running at 192.168.219.107:6443
KubeDNS is running at 192.168.219.107:6443/api/v1/namespaces/kube-system/services/my ./kube/config
apiVersion: v1
clusters:
- cluster:
certificate-authority-data:
server: https://****:6443
name: kubernetes
contexts:
- context:
cluster: kubernetes
user: kubernetes-admin
name: kubernetes-admin@kubernetes
current-context: kubernetes-admin@kubernetes
kind: Config
preferences: {}
users:
- name: kubernetes-admin
user:
client-certificate-data:
client-key-data: export KUBERNETES_MASTER=http://MasterIP:8080 is not correct because the port should be 6443 and protocol should be https for external connection coming to Kubernetes API Server.
export KUBERNETES_MASTER=https://MasterIP:6443`You seem to have a valid kubeconfig file and so you really don't need to export KUBERNETES_MASTER environment variable.
Make sure that the file is located at .kube/config path in your home directory. otherwise point KUBECONFIG environment variable to the path where the kubeconfig file is located.