Advanced-Kubernetes-Operator icon indicating copy to clipboard operation
Advanced-Kubernetes-Operator copied to clipboard

【勘误-P38】PodTemplateSpec字段添加报错

Open Shuimo03 opened this issue 2 years ago • 8 comments

我的代码:

// CoffeeSpec defines the desired state of Coffee
type CoffeeSpec struct {
	// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
	// Important: Run "make" to regenerate code after modifying this file
	Replicas int32                  `json:"replicas,omitempty"`
	Template corev1.PodTemplateSpec `json:"template,omitempty"`
}

我的环境

  • Intel macos
  • golang 1.19
  • kubebuilder 3.9.0

错误

* spec.validation.openAPIV3Schema.properties[spec].properties[template].properties[spec].properties[volumes].items.properties[ephemeral].properties[volumeClaimTemplate].properties[spec].properties[resources].properties[claims].items.x-kubernetes-map-type: Invalid value: "null": must be atomic as item of a list with x-kubernetes-list-type=set
* spec.validation.openAPIV3Schema.properties[spec].properties[template].properties[spec].properties[ephemeralContainers].items.properties[resources].properties[claims].items.x-kubernetes-map-type: Invalid value: "null": must be atomic as item of a list with x-kubernetes-list-type=set
* spec.validation.openAPIV3Schema.properties[spec].properties[template].properties[spec].properties[containers].items.properties[resources].properties[claims].items.x-kubernetes-map-type: Invalid value: "null": must be atomic as item of a list with x-kubernetes-list-type=set
* spec.validation.openAPIV3Schema.properties[spec].properties[template].properties[spec].properties[initContainers].items.properties[resources].properties[claims].items.x-kubernetes-map-type: Invalid value: "null": must be atomic as item of a list with x-kubernetes-list-type=set
make: *** [install] Error 1
```

Shuimo03 avatar Feb 14 '23 13:02 Shuimo03

同样遇到这个问题

Sucran avatar Feb 19 '23 07:02 Sucran

我是这样解决的 go.mod文件 k8s.io/api v0.26.0 改成 k8s.io/api v0.26.1 然后修改Makefile 里的ENVTEST_K8S_VERSION = 1.26.0 改成 ENVTEST_K8S_VERSION = 1.25.0 就能正常make install 了 机器是MacBookpro14'(2021) M1 chip,使用插件--plugins=go/v4-alpha

kubectl version --short :

Client Version: v1.25.0 Kustomize Version: v4.5.7 Server Version: v1.25.0

Sucran avatar Mar 03 '23 08:03 Sucran

@Shuimo03 可以参考一下我的解决方案

Sucran avatar Mar 03 '23 08:03 Sucran

@Sucran 好咧,多谢大佬,最近没看了,到时候试试看

Shuimo03 avatar Mar 03 '23 13:03 Shuimo03

kubebuilder 版本用的3.8 可以,现在v3.9.0版本和kubernetes 1.25.0版本结合有报错

kcxg avatar Apr 04 '23 06:04 kcxg

解决方法2,修改go.mod,加入replace k8s.io/api v0.26.0 => k8s.io/api v0.25.0定义,然后执行go mod tidy

kcxg avatar Apr 04 '23 06:04 kcxg

参考https://github.com/kubernetes-sigs/kubebuilder/issues/3303.升级k8s.io/api即可 。 目前发现升级太高会引起其他问题,暂时升级为go get k8s.io/[email protected] ,go mod tidy.

vavikast avatar Apr 13 '23 06:04 vavikast

https://github.com/kubernetes-sigs/kubebuilder/issues/3303#issuecomment-1510520496

升级版本

MajLuu avatar May 14 '23 10:05 MajLuu