简体   繁体   中英

setting the k8s cluster to use the hostname/IP address instead of localhost

I just installed k8s cluster but the URLs are all using localhost and would like to change it to use the hostname or even IP address. Due to this the cluster can be accessed only from the master node. I am unable to find the right place to make this change. Any help is really appreciated.

OS: Redhat 7.1
Kubernetes version: 1.2

[rakeshk@ kubernetes]$ kubectl cluster-info
Kubernetes master is running at http://localhost:8080
Elasticsearch is running at http://localhost:8080/api/v1/proxy/namespaces/kube-system/services/elasticsearch-logging
Heapster is running at http://localhost:8080/api/v1/proxy/namespaces/kube-system/services/heapster
Kibana is running at http://localhost:8080/api/v1/proxy/namespaces/kube-system/services/kibana-logging
KubeDNS is running at http://localhost:8080/api/v1/proxy/namespaces/kube-system/services/kube-dns
kubedash is running at http://localhost:8080/api/v1/proxy/namespaces/kube-system/services/kubedash
kubernetes-dashboard is running at http://localhost:8080/api/v1/proxy/namespaces/kube-system/services/kubernetes-dashboard
Grafana is running at http://localhost:8080/api/v1/proxy/namespaces/kube-system/services/monitoring-grafana
InfluxDB is running at http://localhost:8080/api/v1/proxy/namespaces/kube-system/services/monitoring-influxdb

Based on the port number ( 8080 , which is the default value of --insecure-port of kube-apiserver ), I am guessing that you are running the kubectl cluster-info command on the same machine where the kube-apiserver is running.

If the above assumption is correct, then copy the /etc/kubernetes/admin.conf file (from the machine thats running the kube-apiserver ) to your local machine ~/.kube/config . Run kubectl cluster-info on your local machine (install kubectl program on your local machine, if you haven't already). This should give you cluster address as either a hostname or IP address. Whether it shows it as an IP address or a hostname depends on whether a reverse lookup of the IP address resolves a DNS record.

If you are initialising using program. kubeadm init will autodetect the network interface to advertise the master on as the interface with the default gateway. If default gateway IP address is not routable IP address, ensure that you set --api-advertise-addresses to a routable IP address.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM