kubectl: when EXTERNAL-IP too long

Kubernetes version (use kubectl version):

Client Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.11", GitCommit:"637c7e288581ee40ab4ca210618a89a555b6e7e9", GitTreeState:"clean", BuildDate:"2018-11-26T14:38:32Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"12+", GitVersion:"v1.12.6-eks-d69f1b", GitCommit:"d69f1bf3669bf00b7f4a758e978e0e7a1e3a68f7", GitTreeState:"clean", BuildDate:"2019-02-28T20:26:10Z", GoVersion:"go1.10.8", Compiler:"gc", Platform:"linux/amd64"}

Environment:

Darwin PauldeMacBook-Pro.local 18.5.0 Darwin Kernel Version 18.5.0: Mon Mar 11 20:40:32 PDT 2019; root:xnu-4903.251.3~3/RELEASE_X86_64 x86_64
  • Install tools: zsh

What happened: when use AKS in AWS, the ip too long ,so can not be found the ip EX:

NAME           TYPE           CLUSTER-IP       EXTERNAL-IP        PORT(S)          AGE
redis-master     LoadBalancer   10.100.6.182     a98068ce56515...   3000:31686/TCP   36m

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 15 (6 by maintainers)

Most upvoted comments

Without being able to reproduce it, I just happened to find where it truncates the external IP to 13 bytes + “…” when it is longer than 16 bytes.

https://github.com/kubernetes/kubernetes/blob/ea5cef1c65b5890011bdd258f5c61dcf197ee5e3/pkg/printers/internalversion/printers.go#L1018

const (
	loadBalancerWidth = 16
	...
}
func loadBalancerStatusStringer(s api.LoadBalancerStatus, wide bool) string {
	...
	if !wide && len(r) > loadBalancerWidth {
		r = r[0:(loadBalancerWidth-3)] + "..."
	}
	return r
}
func getServiceExternalIP(svc *api.Service, wide bool) string {
	switch svc.Spec.Type {
	...
	case api.ServiceTypeLoadBalancer:
		lbIps := loadBalancerStatusStringer(svc.Status.LoadBalancer, wide)
	...
}

It looks like that in order to support full display of IPv6 in table format, loadBalancerWidth would need to be changed from 16 to 48

EDIT: After taking another quick look, I notice that it looks like the code only truncates the external IP if wide output is not specified, so whoever works on this should check. If wide format displays the full IP, then maybe it is OK as-is.