daniel-hutao / Advanced-Kubernetes-Operator

纸质书,2023年1月初出版
45 stars 16 forks source link

7.6.2节 多版本部署,v2版本创建yaml报错, v1创建正常 #6

Open tanlay opened 1 year ago

tanlay commented 1 year ago

报错如下:

$ kubectl apply -f config/samples/apps_v2_application.yaml 
Error from server: error when retrieving current configuration of:
Resource: "apps.tanlay.com/v2, Resource=applications", GroupVersionKind: "apps.tanlay.com/v2, Kind=Application"
Name: "nginx-sample", Namespace: "default"
from server for: "config/samples/apps_v2_application.yaml": conversion webhook for apps.tanlay.com/v1, Kind=Application failed: the server could not find the requested resource

api/v2/application_types.go文件

// 只修改了ApplicationSpec结构体的Deployment字段为Workflow,其他和v1版本一致,
// 只在v1版本增加了持久化 //+kubebuilder:storageversion
type ApplicationSpec struct {
    // INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
    // Important: Run "make" to regenerate code after modifying this file

    Workflow v1.DeploymentTemplate `json:"workflow,omitempty"`
    Service  v1.ServiceTemplate    `json:"service,omitempty"`
}
asjfoajs commented 1 month ago

我也遇到了这个问题,解决了嘛