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

你可能感兴趣的:(k8s)