diff --git a/deployment/clusterObjectModel/mainParser/kubernetes.py b/deployment/clusterObjectModel/mainParser/kubernetes.py index 436b99bad..0929ce265 100644 --- a/deployment/clusterObjectModel/mainParser/kubernetes.py +++ b/deployment/clusterObjectModel/mainParser/kubernetes.py @@ -79,8 +79,9 @@ class Kubernetes: com_kubernetes["cluster-dns"] = k8s_cfg["cluster-dns"] com_kubernetes["api-servers-ip"] = k8s_cfg["load-balance-ip"] - com_kubernetes["api-servers-port"] = "8080" - com_kubernetes["api-servers-url"] = "http://{0}:8080".format(k8s_cfg["load-balance-ip"]) + com_kubernetes["api-servers-port"] = k8s_cfg["api-servers-port"] if ("api-servers-port" in k8s_cfg) else "8080" + com_kubernetes["api-servers-http-schema"] = k8s_cfg["api-servers-http-schema"] if ("api-servers-http-schema" in k8s_cfg) else "http" + com_kubernetes["api-servers-url"] = "{0}://{1}:{2}".format(com_kubernetes["api-servers-http-schema"], k8s_cfg["load-balance-ip"], com_kubernetes["api-servers-port"]) com_kubernetes["docker-registry"] = k8s_cfg["docker-registry"] com_kubernetes["hyperkube-version"] = k8s_cfg["hyperkube-version"] com_kubernetes["etcd-version"] = k8s_cfg["etcd-version"] diff --git a/deployment/k8sPaiLibrary/maintainlib/kubectl_conf_check.py b/deployment/k8sPaiLibrary/maintainlib/kubectl_conf_check.py index c38c604ea..8ba67eff8 100644 --- a/deployment/k8sPaiLibrary/maintainlib/kubectl_conf_check.py +++ b/deployment/k8sPaiLibrary/maintainlib/kubectl_conf_check.py @@ -61,7 +61,7 @@ class kubectl_conf_check: local_kubectl_conf = common.load_yaml_file("{0}/config".format(self.kube_conf_path)) api_server_address = local_kubectl_conf['clusters'][0]['cluster']['server'] - api_server_address_pai_conf = "http://{0}:8080".format(self.cluster_object_model['kubernetes']['api-servers-ip']) + api_server_address_pai_conf = self.cluster_object_model['kubernetes']['api-servers-url'] if api_server_address != api_server_address_pai_conf: self.logger.warning("CHECKING FAILED: The api_server_address in local configuration is different from the one in pai's configuration.".format(self.kube_conf_path)) diff --git a/deployment/k8sPaiLibrary/template/controller-manager.yaml.template b/deployment/k8sPaiLibrary/template/controller-manager.yaml.template index a5b8e2a7b..bee32a0fc 100644 --- a/deployment/k8sPaiLibrary/template/controller-manager.yaml.template +++ b/deployment/k8sPaiLibrary/template/controller-manager.yaml.template @@ -28,7 +28,7 @@ spec: command: - /usr/local/bin/kube-controller-manager - --master - - {{ cluster_cfg['kubernetes']['api-servers-ip'] }}:8080 + - {{ cluster_cfg['kubernetes']['api-servers-ip'] }}:{{ cluster_cfg['kubernetes']['api-servers-port'] }} - --service-cluster-ip-range - {{ cluster_cfg['kubernetes']['service-cluster-ip-range'] }} - --leader-elect=true diff --git a/deployment/k8sPaiLibrary/template/dashboard-deployment.yaml.template b/deployment/k8sPaiLibrary/template/dashboard-deployment.yaml.template index 00a2943d8..5b53a56ec 100644 --- a/deployment/k8sPaiLibrary/template/dashboard-deployment.yaml.template +++ b/deployment/k8sPaiLibrary/template/dashboard-deployment.yaml.template @@ -42,7 +42,7 @@ spec: - name: kubernetes-dashboard image: {{ cluster_cfg['kubernetes']['docker-registry'] }}/kubernetes-dashboard-amd64:{{ cluster_cfg['kubernetes']['dashboard-version'] }} args: - - --apiserver-host=http://{{ cluster_cfg['kubernetes']['api-servers-ip'] }}:8080 + - --apiserver-host={{ cluster_cfg['kubernetes']['api-servers-url'] }} resources: # the ideal cpu setting will be 3.5, according to our experiment. If the server hosting k8s dashboard has enough resource, user can change this setting to a larger value. requests: diff --git a/deployment/k8sPaiLibrary/template/kube-proxy.yaml.template b/deployment/k8sPaiLibrary/template/kube-proxy.yaml.template index c4f3a5074..d83700559 100644 --- a/deployment/k8sPaiLibrary/template/kube-proxy.yaml.template +++ b/deployment/k8sPaiLibrary/template/kube-proxy.yaml.template @@ -39,7 +39,7 @@ spec: - /hyperkube - proxy - --master - - {{ cluster_cfg['kubernetes']['api-servers-ip'] }}:8080 + - {{ cluster_cfg['kubernetes']['api-servers-ip'] }}:{{ cluster_cfg['kubernetes']['api-servers-port'] }} - --cluster-cidr - {{ cluster_cfg['kubernetes']['service-cluster-ip-range'] }} securityContext: diff --git a/deployment/k8sPaiLibrary/template/scheduler.yaml.template b/deployment/k8sPaiLibrary/template/scheduler.yaml.template index 804651e7d..a65106947 100644 --- a/deployment/k8sPaiLibrary/template/scheduler.yaml.template +++ b/deployment/k8sPaiLibrary/template/scheduler.yaml.template @@ -28,7 +28,7 @@ spec: command: - /usr/local/bin/kube-scheduler - --master - - {{ cluster_cfg['kubernetes']['api-servers-ip'] }}:8080 + - {{ cluster_cfg['kubernetes']['api-servers-ip'] }}:{{ cluster_cfg['kubernetes']['api-servers-port'] }} - --leader-elect=true livenessProbe: httpGet: diff --git a/examples/cluster-configuration/kubernetes-configuration.yaml b/examples/cluster-configuration/kubernetes-configuration.yaml index 3290981c5..a663614c5 100644 --- a/examples/cluster-configuration/kubernetes-configuration.yaml +++ b/examples/cluster-configuration/kubernetes-configuration.yaml @@ -21,6 +21,8 @@ kubernetes: # To support k8s ha, you should set an lb address here. # If deploy k8s with single master node, please set master IP address here load-balance-ip: IP + #api-servers-port: 8080 + #api-servers-http-schema: http # specify an IP range not in the same network segment with the host machine. service-cluster-ip-range: 169.254.0.0/16