1、编译问题

编译K8S报错,错误打印如下:

 # KUBE_BASE_IMAGE_REGISTRY="192.168.166.180:50500" KUBE_DOCKER_REGISTRY="192.168.166.180:50500"  KUBE_BUILD_CONFORMANCE=n KUBE_BUILD_HYPERKUBE=n make quick-release
+++ [0414 05:00:25] Verifying Prerequisites....
+++ [0414 05:00:26] Building Docker image kube-build:build-c1deb6c94b-5-v1.13.4-1
+++ [0414 05:00:50] Creating data container kube-build-data-c1deb6c94b-5-v1.13.4-1
+++ [0414 05:00:56] Syncing sources to container
+++ [0414 05:01:28] Running build command...
+++ [0414 05:01:40] Building go targets for linux/amd64:
    ./vendor/k8s.io/code-generator/cmd/deepcopy-gen
+++ [0414 05:01:47] Building go targets for linux/amd64:
    ./vendor/k8s.io/code-generator/cmd/defaulter-gen
+++ [0414 05:01:53] Building go targets for linux/amd64:
    ./vendor/k8s.io/code-generator/cmd/conversion-gen
+++ [0414 05:02:03] Building go targets for linux/amd64:
    ./vendor/k8s.io/kube-openapi/cmd/openapi-gen
+++ [0414 05:02:14] Building go targets for linux/amd64:
    ./vendor/github.com/go-bindata/go-bindata/go-bindata
+++ [0414 05:02:16] Building go targets for linux/amd64:
    cmd/kube-proxy
    cmd/kube-apiserver
    cmd/kube-controller-manager
    cmd/kubelet
    cmd/kubeadm
    cmd/kube-scheduler
    vendor/k8s.io/apiextensions-apiserver
    cluster/gce/gci/mounter
# k8s.io/kubernetes/vendor/k8s.io/apiextensions-apiserver/pkg/controller/openapi/builder
vendor/k8s.io/apiextensions-apiserver/pkg/controller/openapi/builder/builder.go:434:16: undefined: "k8s.io/kubernetes/vendor/k8s.io/apiextensions-apiserver/pkg/generated/openapi".GetOpenAPIDefinitions
vendor/k8s.io/apiextensions-apiserver/pkg/controller/openapi/builder/builder.go:489:11: undefined: "k8s.io/kubernetes/vendor/k8s.io/apiextensions-apiserver/pkg/generated/openapi".GetOpenAPIDefinitions
!!! [0414 05:03:00] Call tree:
!!! [0414 05:03:00]  1: /go/src/k8s.io/kubernetes/hack/lib/golang.sh:704 kube::golang::build_some_binaries(...)
!!! [0414 05:03:00]  2: /go/src/k8s.io/kubernetes/hack/lib/golang.sh:853 kube::golang::build_binaries_for_platform(...)
!!! [0414 05:03:00]  3: hack/make-rules/build.sh:27 kube::golang::build_binaries(...)
!!! [0414 05:03:00] Call tree:
!!! [0414 05:03:00]  1: hack/make-rules/build.sh:27 kube::golang::build_binaries(...)
!!! [0414 05:03:00] Call tree:
!!! [0414 05:03:00]  1: hack/make-rules/build.sh:27 kube::golang::build_binaries(...)
make[1]: *** [Makefile:93: all] Error 1
make: *** [Makefile:505: cross] Error 1
!!! [0414 05:03:04] Call tree:
!!! [0414 05:03:04]  1: build/../build/common.sh:523 kube::build::run_build_command_ex(...)
!!! [0414 05:03:04]  2: build/release.sh:36 kube::build::run_build_command(...)
make: *** [quick-release] Error 1

2、问题原因

查看代码可以发现GetOpenAPIDefinitions这个函数是有定义的

src/k8s.io/kubernetes/vendor/k8s.io/apiextensions-apiserver/pkg/generated/openapi/zz_generated.openapi.go
func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenAPIDefinition {
	return map[string]common.OpenAPIDefinition{
		"k8s.io/api/autoscaling/v1.CrossVersionObjectReference":          schema_k8sio_api_autoscaling_v1_CrossVersionObjectReference(ref),
		"k8s.io/api/autoscaling/v1.ExternalMetricSource":                 schema_k8sio_api_autoscaling_v1_ExternalMetricSource(ref),
		"k8s.io/api/autoscaling/v1.ExternalMetricStatus":                 schema_k8sio_api_autoscaling_v1_ExternalMetricStatus(ref),
		"k8s.io/api/autoscaling/v1.HorizontalPodAutoscaler":              schema_k8sio_api_autoscaling_v1_HorizontalPodAutoscaler(ref),
		"k8s.io/api/autoscaling/v1.HorizontalPodAutoscalerCondition":     schema_k8sio_api_autoscaling_v1_HorizontalPodAutoscalerCondition(ref),
		"k8s.io/api/autoscaling/v1.HorizontalPodAutoscalerList":          schema_k8sio_api_autoscaling_v1_HorizontalPodAutoscalerList(ref),
		"k8s.io/api/autoscaling/v1.HorizontalPodAutoscalerSpec":          schema_k8sio_api_autoscaling_v1_HorizontalPodAutoscalerSpec(ref),
		"k8s.io/api/autoscaling/v1.HorizontalPodAutoscalerStatus":        schema_k8sio_api_autoscaling_v1_HorizontalPodAutoscalerStatus(ref),
		"k8s.io/api/autoscaling/v1.MetricSpec":                           schema_k8sio_api_autoscaling_v1_MetricSpec(ref),
...

zz_generated.openapi.go这个源文件注释中有说明,该文件不能修改

// Code generated by openapi-gen. DO NOT EDIT.

// This file was autogenerated by openapi-gen. Do not edit it manually!

代码是从另外一台能够正常编译的机器上拷贝到本节点的,应该是和编译环境有关系,具体原因没有细究

3、问题解决

删除kubernetes代码,重新解压一份后,可以正常编译

# ls -l src/k8s.io/
total 12
drwxr-xr-x. 17 root root 4096 Apr 14 07:14 cloud-provider-openstack
drwxrwxr-x  18 root root 4096 Apr 15 04:46 kubernetes
Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐