云容器实例 CCI-使用client-go访问CCI的CRD资源Network:定义CRD资源Network
时间:2024-04-28 17:22:55
定义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=NetworkingCCI package v1beta1
types.go
package v1beta1 import ( 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 // +optional metav1.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"` // +optional metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` // Spec defines the attributes on a network // +optional Spec NetworkSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"` // Status describes the network status // +optional Status NetworkStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"` } // NetworkSpec describes the attributes on a network resource. type NetworkSpec struct { // network type NetworkType string `json:"networkType,omitempty" protobuf:"bytes,5,opt,name=networkType"` // ID of the VPC to attach AttachedVPC string `json:"attachedVPC,omitempty" protobuf:"bytes,4,opt,name=attachedVPC"` // network ID NetworkID string `json:"networkID,omitempty" protobuf:"bytes,7,opt,name=networkID"` // Subnet ID SubnetID string `json:"subnetID,omitempty" protobuf:"bytes,8,opt,name=subnetID"` // available zone AvailableZone string `json:"availableZone,omitempty" protobuf:"bytes,9,opt,name=availableZone"` // The CIDR of the network CIDR string `json:"cidr,omitempty" protobuf:"bytes,3,opt,name=cidr"` } // NetworkStatus describes the status of a network type NetworkStatus struct { // State describes the network state // +optional State string `json:"state" protobuf:"bytes,1,opt,name=state"` // Message describes why network is in current state // +optional Message string `json:"message,omitempty" protobuf:"bytes,2,opt,name=message"` } const ( // NetworkInitializing means the network is initializing NetworkInitializing = "Initializing" // NetworkPending means the network is processing NetworkPending = "Pending" // NetworkActive means the network is available NetworkActive = "Active" // NetworkFailed means the network is not available NetworkFailed = "Failed" // NetworkTerminating means the network is undergoing graceful termination NetworkTerminating = "Terminating" )
register.go
package v1beta1 import ( 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 package const GroupName = "networking.cci.io" // SchemeGroupVersion is group version used to register these objects var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1beta1"} // Resource takes an unqualified resource and returns a Group qualified GroupResource func 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 = &SchemeBuilder AddToScheme = 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 applies metav1.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证书是什么
申请企业邮箱步骤
免费的企业用邮箱
云免流搭建教程
域名价格
推荐文章