云容器实例 CCI-使用client-go访问CCI的CRD资源Network:定义CRD资源Network
时间:2025-02-12 14:55:06
定义CRD资源Network
创建文件夹pkg/apis/networking.cci.io/v1beta1,其中networking.cci.io为CRD资源的group,v1beta1为CRD资源版本
mkdir -p pkg/apis/networking.cci.io/v1beta1
在新建文件夹中新建以下文件:
doc.go
// +k8s:deepcopy-gen=package// +groupName=networking.cci.io// +groupGoName=NetworkingCCIpackage v1beta1
types.go
package v1beta1import (metav1 "k8s.io/apimachinery/pkg/apis/meta/v1")// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object// NetworkList is a list of network resource in container.type NetworkList struct {metav1.TypeMeta `json:",inline"`// Standard list metadata.// More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata// +optionalmetav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`Items []Network `json:"items" protobuf:"bytes,2,rep,name=items"`}// +genclient// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object// Network is a network resource in container.type Network struct {metav1.TypeMeta `json:",inline"`// +optionalmetav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`// Spec defines the attributes on a network// +optionalSpec NetworkSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"`// Status describes the network status// +optionalStatus NetworkStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"`}// NetworkSpec describes the attributes on a network resource.type NetworkSpec struct {// network typeNetworkType string `json:"networkType,omitempty" protobuf:"bytes,5,opt,name=networkType"`// ID of the VPC to attachAttachedVPC string `json:"attachedVPC,omitempty" protobuf:"bytes,4,opt,name=attachedVPC"`// network IDNetworkID string `json:"networkID,omitempty" protobuf:"bytes,7,opt,name=networkID"`// Subnet IDSubnetID string `json:"subnetID,omitempty" protobuf:"bytes,8,opt,name=subnetID"`// available zoneAvailableZone string `json:"availableZone,omitempty" protobuf:"bytes,9,opt,name=availableZone"`// The CIDR of the networkCIDR string `json:"cidr,omitempty" protobuf:"bytes,3,opt,name=cidr"`}// NetworkStatus describes the status of a networktype NetworkStatus struct {// State describes the network state// +optionalState string `json:"state" protobuf:"bytes,1,opt,name=state"`// Message describes why network is in current state// +optionalMessage string `json:"message,omitempty" protobuf:"bytes,2,opt,name=message"`}const (// NetworkInitializing means the network is initializingNetworkInitializing = "Initializing"// NetworkPending means the network is processingNetworkPending = "Pending"// NetworkActive means the network is availableNetworkActive = "Active"// NetworkFailed means the network is not availableNetworkFailed = "Failed"// NetworkTerminating means the network is undergoing graceful terminationNetworkTerminating = "Terminating")
register.go
package v1beta1import (metav1 "k8s.io/apimachinery/pkg/apis/meta/v1""k8s.io/apimachinery/pkg/runtime""k8s.io/apimachinery/pkg/runtime/schema")// GroupName is the group name use in this packageconst GroupName = "networking.cci.io"// SchemeGroupVersion is group version used to register these objectsvar SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1beta1"}// Resource takes an unqualified resource and returns a Group qualified GroupResourcefunc Resource(resource string) schema.GroupResource {return SchemeGroupVersion.WithResource(resource).GroupResource()}var (// localSchemeBuilder and AddToScheme will stay in k8s.io/kubernetes.SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)localSchemeBuilder = &SchemeBuilderAddToScheme = localSchemeBuilder.AddToScheme)// Adds the list of known types to the given scheme.func addKnownTypes(scheme *runtime.Scheme) error {scheme.AddKnownTypes(SchemeGroupVersion,&Network{},&NetworkList{},)// Add the watch version that appliesmetav1.AddToGroupVersion(scheme, SchemeGroupVersion)return nil}
support.huaweicloud.com/sdkreference-cci/cci_09_0002.html
看了此文的人还看了
CDN加速
GaussDB
文字转换成语音
免费的服务器
如何创建网站
域名网站购买
私有云桌面
云主机哪个好
域名怎么备案
手机云电脑
SSL证书申请
云点播服务器
免费OCR是什么
电脑云桌面
域名备案怎么弄
语音转文字
文字图片识别
云桌面是什么
网址安全检测
网站建设搭建
国外CDN加速
SSL免费证书申请
短信批量发送
图片OCR识别
云数据库MySQL
个人域名购买
录音转文字
扫描图片识别文字
OCR图片识别
行驶证识别
虚拟电话号码
电话呼叫中心软件
怎么制作一个网站
Email注册网站
华为VNC
图像文字识别
企业网站制作
个人网站搭建
华为云计算
免费租用云托管
云桌面云服务器
ocr文字识别免费版
HTTPS证书申请
图片文字识别转换
国外域名注册商
使用免费虚拟主机
云电脑主机多少钱
鲲鹏云手机
短信验证码平台
OCR图片文字识别
SSL证书是什么
申请企业邮箱步骤
免费的企业用邮箱
云免流搭建教程
域名价格
推荐文章
ServerLess102