首页 > 其他分享 >k8s yaml 文件中的api版本如何选择?

k8s yaml 文件中的api版本如何选择?

时间:2022-12-22 13:32:44浏览次数:39  
标签:v1 watch create get list patch yaml api k8s


在创建不同的资源时,发现yaml文件用到的api版本不一样。 本文主要讲如何api版本的选择。

在你的k8s集群执行命令,查看你的k8s 提供的api 和版本信息,输出列格式:

  • NAME 资源名称
  • SHORTNAMES 资源名称简写
  • NAMESPACED 是否需要指定命名空间
  • APIGROUP => apiVersion
  • KIND 资源类型
  • VERBS 可用的方法
[root@k8s-master ~]# kubectl api-resources -o wide
NAME SHORTNAMES APIVERSION NAMESPACED KIND VERBS
bindings v1 true Binding [create]
componentstatuses cs v1 false ComponentStatus [get list]
configmaps cm v1 true ConfigMap [create delete deletecollection get list patch update watch]
endpoints ep v1 true Endpoints [create delete deletecollection get list patch update watch]
events ev v1 true Event [create delete deletecollection get list patch update watch]
limitranges limits v1 true LimitRange [create delete deletecollection get list patch update watch]
namespaces ns v1 false Namespace [create delete get list patch update watch]
nodes no v1 false Node [create delete deletecollection get list patch update watch]
persistentvolumeclaims pvc v1 true PersistentVolumeClaim [create delete deletecollection get list patch update watch]
persistentvolumes pv v1 false PersistentVolume [create delete deletecollection get list patch update watch]
pods po v1 true Pod [create delete deletecollection get list patch update watch]
podtemplates v1 true PodTemplate [create delete deletecollection get list patch update watch]
replicationcontrollers rc v1 true ReplicationController [create delete deletecollection get list patch update watch]
resourcequotas quota v1 true ResourceQuota [create delete deletecollection get list patch update watch]
secrets v1 true Secret [create delete deletecollection get list patch update watch]
serviceaccounts sa v1 true ServiceAccount [create delete deletecollection get list patch update watch]
services svc v1 true Service [create delete deletecollection get list patch update watch]
mutatingwebhookconfigurations admissionregistration.k8s.io/v1 false MutatingWebhookConfiguration [create delete deletecollection get list patch update watch]
validatingwebhookconfigurations admissionregistration.k8s.io/v1 false ValidatingWebhookConfiguration [create delete deletecollection get list patch update watch]
customresourcedefinitions crd,crds apiextensions.k8s.io/v1 false CustomResourceDefinition [create delete deletecollection get list patch update watch]
apiservices apiregistration.k8s.io/v1 false APIService [create delete deletecollection get list patch update watch]
controllerrevisions apps/v1 true ControllerRevision [create delete deletecollection get list patch update watch]
daemonsets ds apps/v1 true DaemonSet [create delete deletecollection get list patch update watch]
deployments deploy apps/v1 true Deployment [create delete deletecollection get list patch update watch]
replicasets rs apps/v1 true ReplicaSet [create delete deletecollection get list patch update watch]
statefulsets sts apps/v1 true StatefulSet [create delete deletecollection get list patch update watch]
tokenreviews authentication.k8s.io/v1 false TokenReview [create]
localsubjectaccessreviews authorization.k8s.io/v1 true LocalSubjectAccessReview [create]
selfsubjectaccessreviews authorization.k8s.io/v1 false SelfSubjectAccessReview [create]
selfsubjectrulesreviews authorization.k8s.io/v1 false SelfSubjectRulesReview [create]
subjectaccessreviews authorization.k8s.io/v1 false SubjectAccessReview [create]
horizontalpodautoscalers hpa autoscaling/v2 true HorizontalPodAutoscaler [create delete deletecollection get list patch update watch]
cronjobs cj batch/v1 true CronJob [create delete deletecollection get list patch update watch]
jobs batch/v1 true Job [create delete deletecollection get list patch update watch]
certificatesigningrequests csr certificates.k8s.io/v1 false CertificateSigningRequest [create delete deletecollection get list patch update watch]
leases coordination.k8s.io/v1 true Lease [create delete deletecollection get list patch update watch]
bgpconfigurations crd.projectcalico.org/v1 false BGPConfiguration [delete deletecollection get list patch create update watch]
bgppeers crd.projectcalico.org/v1 false BGPPeer [delete deletecollection get list patch create update watch]
blockaffinities crd.projectcalico.org/v1 false BlockAffinity [delete deletecollection get list patch create update watch]
caliconodestatuses crd.projectcalico.org/v1 false CalicoNodeStatus [delete deletecollection get list patch create update watch]
clusterinformations crd.projectcalico.org/v1 false ClusterInformation [delete deletecollection get list patch create update watch]
felixconfigurations crd.projectcalico.org/v1 false FelixConfiguration [delete deletecollection get list patch create update watch]
globalnetworkpolicies crd.projectcalico.org/v1 false GlobalNetworkPolicy [delete deletecollection get list patch create update watch]
globalnetworksets crd.projectcalico.org/v1 false GlobalNetworkSet [delete deletecollection get list patch create update watch]
hostendpoints crd.projectcalico.org/v1 false HostEndpoint [delete deletecollection get list patch create update watch]
ipamblocks crd.projectcalico.org/v1 false IPAMBlock [delete deletecollection get list patch create update watch]
ipamconfigs crd.projectcalico.org/v1 false IPAMConfig [delete deletecollection get list patch create update watch]
ipamhandles crd.projectcalico.org/v1 false IPAMHandle [delete deletecollection get list patch create update watch]
ippools crd.projectcalico.org/v1 false IPPool [delete deletecollection get list patch create update watch]
ipreservations crd.projectcalico.org/v1 false IPReservation [delete deletecollection get list patch create update watch]
kubecontrollersconfigurations crd.projectcalico.org/v1 false KubeControllersConfiguration [delete deletecollection get list patch create update watch]
networkpolicies crd.projectcalico.org/v1 true NetworkPolicy [delete deletecollection get list patch create update watch]
networksets crd.projectcalico.org/v1 true NetworkSet [delete deletecollection get list patch create update watch]
endpointslices discovery.k8s.io/v1 true EndpointSlice [create delete deletecollection get list patch update watch]
events ev events.k8s.io/v1 true Event [create delete deletecollection get list patch update watch]
flowschemas flowcontrol.apiserver.k8s.io/v1beta2 false FlowSchema [create delete deletecollection get list patch update watch]
prioritylevelconfigurations flowcontrol.apiserver.k8s.io/v1beta2 false PriorityLevelConfiguration [create delete deletecollection get list patch update watch]
ingressclasses networking.k8s.io/v1 false IngressClass [create delete deletecollection get list patch update watch]
ingresses ing networking.k8s.io/v1 true Ingress [create delete deletecollection get list patch update watch]
networkpolicies netpol networking.k8s.io/v1 true NetworkPolicy [create delete deletecollection get list patch update watch]
runtimeclasses node.k8s.io/v1 false RuntimeClass [create delete deletecollection get list patch update watch]
poddisruptionbudgets pdb policy/v1 true PodDisruptionBudget [create delete deletecollection get list patch update watch]
podsecuritypolicies psp policy/v1beta1 false PodSecurityPolicy [create delete deletecollection get list patch update watch]
clusterrolebindings rbac.authorization.k8s.io/v1 false ClusterRoleBinding [create delete deletecollection get list patch update watch]
clusterroles rbac.authorization.k8s.io/v1 false ClusterRole [create delete deletecollection get list patch update watch]
rolebindings rbac.authorization.k8s.io/v1 true RoleBinding [create delete deletecollection get list patch update watch]
roles rbac.authorization.k8s.io/v1 true Role [create delete deletecollection get list patch update watch]
priorityclasses pc scheduling.k8s.io/v1 false PriorityClass [create delete deletecollection get list patch update watch]
csidrivers storage.k8s.io/v1 false CSIDriver [create delete deletecollection get list patch update watch]
csinodes storage.k8s.io/v1 false CSINode [create delete deletecollection get list patch update watch]
csistoragecapacities storage.k8s.io/v1beta1 true CSIStorageCapacity [create delete deletecollection get list patch update watch]
storageclasses sc storage.k8s.io/v1 false StorageClass [create delete deletecollection get list patch update watch]
volumeattachments storage.k8s.io/v1 false VolumeAttachment [create delete deletecollection get list patch update watch]
[root@k8s-master ~]#

获取特定 API 组的 API 资源:

[root@k8s-master ~]# kubectl api-resources --api-group apps -o wide
NAME SHORTNAMES APIVERSION NAMESPACED KIND VERBS
controllerrevisions apps/v1 true ControllerRevision [create delete deletecollection get list patch update watch]
daemonsets ds apps/v1 true DaemonSet [create delete deletecollection get list patch update watch]
deployments deploy apps/v1 true Deployment [create delete deletecollection get list patch update watch]
replicasets rs apps/v1 true ReplicaSet [create delete deletecollection get list patch update watch]
statefulsets sts apps/v1 true StatefulSet [create delete deletecollection get list patch update watch]
[root@k8s-master ~]#
[root@k8s-master ~]#
[root@k8s-master ~]#
[root@k8s-master ~]# kubectl explain deploy
KIND: Deployment
VERSION: apps/v1

DESCRIPTION:
Deployment enables declarative updates for Pods and ReplicaSets.

FIELDS:
apiVersion <string>
APIVersion defines the versioned schema of this representation of an
object. Servers should convert recognized schemas to the latest internal
value, and may reject unrecognized values. More info:
https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources

kind <string>
Kind is a string value representing the REST resource this object
represents. Servers may infer this from the endpoint the client submits
requests to. Cannot be updated. In CamelCase. More info:
https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds

metadata <Object>
Standard object's metadata. More info:
https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata

spec <Object>
Specification of the desired behavior of the Deployment.

status <Object>
Most recently observed status of the Deployment.

[root@k8s-master ~]#

打印当前k8s集群支持的所有api:

[root@k8s-master ~]# kubectl api-versions
admissionregistration.k8s.io/v1
apiextensions.k8s.io/v1
apiregistration.k8s.io/v1
apps/v1
authentication.k8s.io/v1
authorization.k8s.io/v1
autoscaling/v1
autoscaling/v2
autoscaling/v2beta1
autoscaling/v2beta2
batch/v1
batch/v1beta1
certificates.k8s.io/v1
coordination.k8s.io/v1
crd.projectcalico.org/v1
discovery.k8s.io/v1
discovery.k8s.io/v1beta1
events.k8s.io/v1
events.k8s.io/v1beta1
flowcontrol.apiserver.k8s.io/v1beta1
flowcontrol.apiserver.k8s.io/v1beta2
networking.k8s.io/v1
node.k8s.io/v1
node.k8s.io/v1beta1
policy/v1
policy/v1beta1
rbac.authorization.k8s.io/v1
scheduling.k8s.io/v1
storage.k8s.io/v1
storage.k8s.io/v1beta1
v1
[root@k8s-master ~]#


标签:v1,watch,create,get,list,patch,yaml,api,k8s
From: https://blog.51cto.com/u_9152644/5962681

相关文章

  • react中的api获取数组排序
    [javascript-SortanarrayofobjectsinReactandrenderthem-StackOverflow](https://stackoverflow.com/questions/43572436/sort-an-array-of-objects-in-reac......
  • k8s yaml资源清单格式
    k8s由于资源比较多,组合起来参数众多,不适合用cli传参的形式。因此用yaml文件的形式传参给k8s。yaml文件相当于剧本,运维人员相当于制片人,k8s相当于导演,docker相当于剧务、po......
  • python之调用高德、百度api解析经纬度地址
    调用高德#高德地图根据经纬度反查地址,每天只能调用5000次defgaode_excute_single_query(coordStrings,currentkey='你自己的api-key'):#1-将coordList中的经纬......
  • MyBatis的相应API与传统和代理开发的Dao层实现
    MyBatis的相应API1、SqlSession工厂构建器SqlSessionFactoryBuilder常用API:SqlSessionFactorybuild(InputStreaminputStream)通过加载mybatis的核心文件的输入流的形式构......
  • .net core web api 路由约束
    路由约束在传入URL发生匹配时执行,URL路径标记为路由值。路径约束通常检查通过路径模板关联的路径值,并对该值是否为可接受做出对/错决定。某些路由约束使用路由值以外......
  • ptrade 量化交易接口 API接口文档
    http://ptradeapi.com  更新了多个可转债数据接口比如:ptradeapi #可转债溢价率规模数据 ......
  • 使用kubeadm安装k8s集群(v1.18.0)
    一、安装环境系统[root@master1~]#cat/etc/redhat-releaseCentOSLinuxrelease7.9.2009(Core)[root@master1~]#uname-aLinuxmaster13.10.0-1160.el7.x86_64#1......
  • Kubernetes(k8s) kubectl top常用命令
    kubectl在$HOME/.kube目录中查找一个名为config的配置文件。可以通过设置KUBECONFIG环境变量或设置--kubeconfig参数来指定其它kubeconfig文件。本文主要介绍K......
  • Flink:DataStreamAPI
    执行环境获取的执行环境是StreamExecutionEnvironment类的对象。在代码中创建执行环境的方法,就是调用这个类的静态方法。getExecutionEnvironment根据上下文直接得到......
  • echarts api的介绍
    参考的地址:https://echarts.apache.org/zh/api.htmlecharts.initecharts.init(dom?:HTMLDivElement|HTMLCanvasElement,theme?:Object|string,opts?:{devicePi......