k8s操作

k8s查看可用资源

查看集群所有资源,包括crd资源
kubectl api-resources -o wide --kubeconfig=/home/gws/.kube/haconf

kubernetes.io

gws@gws-TP450:~$ kubectl api-resources -o wide --kubeconfig=/home/gws/.kube/haconf 
NAME                                       SHORTNAMES   APIGROUP                       NAMESPACED   KIND                                      VERBS
bindings                                                                               true         Binding                                   [create]
componentstatuses                          cs                                          false        ComponentStatus                           [get list]
configmaps                                 cm                                          true         ConfigMap                                 [create delete deletecollection get list patch update watch]
endpoints                                  ep                                          true         Endpoints                                 [create delete deletecollection get list patch update watch]
events                                     ev                                          true         Event                                     [create delete deletecollection get list patch update watch]

查看APIService

作为Kubernetes中的一种资源对象,可以使用kubectl get apiservice来查看

gws@gws-TP450:~$ kubectl get apiservice -o wide --kubeconfig=/home/gws/.kube/haconf  
NAME                                   SERVICE                      AVAILABLE   AGE
v1.                                    Local                        True        12d
v1.apps                                Local                        True        12d
v1.authentication.k8s.io               Local                        True        12d
v1.authorization.k8s.io                Local                        True        12d
v1.autoscaling                         Local                        True        12d
v1.batch                               Local                        True        12d
v1.crd.projectcalico.org               Local                        True        5d
v1.monitoring.coreos.com               Local                        True        5d
v1.networking.k8s.io                   Local                        True        12d
v1.rbac.authorization.k8s.io           Local                        True        12d
v1.some.api.group                      Local                        True        16h
v1.storage.k8s.io                      Local                        True        12d
v1beta1.admissionregistration.k8s.io   Local                        True        12d
v1beta1.apiextensions.k8s.io           Local                        True        12d
v1beta1.apps                           Local                        True        12d
v1beta1.authentication.k8s.io          Local                        True        12d
v1beta1.authorization.k8s.io           Local                        True        12d
v1beta1.batch                          Local                        True        12d
v1beta1.certificates.k8s.io            Local                        True        12d
v1beta1.coordination.k8s.io            Local                        True        12d
v1beta1.events.k8s.io                  Local                        True        12d
v1beta1.extensions                     Local                        True        12d
v1beta1.metrics.k8s.io                 kube-system/metrics-server   True        12d
v1beta1.policy                         Local                        True        12d
v1beta1.rbac.authorization.k8s.io      Local                        True        12d
v1beta1.scheduling.k8s.io              Local                        True        12d
v1beta1.storage.k8s.io                 Local                        True        12d
v1beta2.apps                           Local                        True        12d
v2beta1.autoscaling                    Local                        True        12d
v2beta2.autoscaling                    Local                        True        12d
v3.management.cattle.io                Local                        True        5d
v3.project.cattle.io                   Local                        True        5d

crd操作

查看

gws@gws-TP450:~$ kubectl get crd  --kubeconfig=$HOME/.kube/haconf  -o wide | grep foo
foos.some.api.group                                             2019-05-28T06:18:46Z
gws@gws-TP450:~$ 
gws@gws-TP450:~$ kubectl get crd foos.some.api.group  --kubeconfig=$HOME/.kube/haconf  -o yaml
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
  creationTimestamp: "2019-05-28T06:18:46Z"
  generation: 1
  name: foos.some.api.group
  resourceVersion: "2168757"
  selfLink: /apis/apiextensions.k8s.io/v1beta1/customresourcedefinitions/foos.some.api.group
  uid: 736001d4-8110-11e9-9a82-00505637a23a
spec:
  conversion:
    strategy: None
  group: some.api.group
  names:
    kind: Foo
    listKind: FooList
    plural: foos
    singular: foo
  scope: Namespaced
  version: v1
  versions:
  - name: v1
    served: true
    storage: true
status:
  acceptedNames:
    kind: Foo
    listKind: FooList
    plural: foos
    singular: foo
  conditions:
  - lastTransitionTime: "2019-05-28T06:18:46Z"
    message: no conflicts found
    reason: NoConflicts
    status: "True"
    type: NamesAccepted
  - lastTransitionTime: null
    message: the initial names have been accepted
    reason: InitialNamesAccepted
    status: "True"
    type: Established
  storedVersions:
  - v1

删除

kubectl delete crd foos.some.api.group

gws@gws-TP450:~/test/crd$ kubectl delete crd foos.some.api.group --kubeconfig=$HOME/.kube/haconf 
customresourcedefinition.apiextensions.k8s.io "foos.some.api.group" deleted

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值