반응형
kubectl api-resources 명령어를 통해 모든 리소스 조회 가능하다.
root@master:/# kubectl api-resources
NAME SHORTNAMES APIVERSION NAMESPACED KIND
bindings v1 true Binding
componentstatuses cs v1 false ComponentStatus
configmaps cm v1 true ConfigMap
endpoints ep v1 true Endpoints
events ev v1 true Event
limitranges limits v1 true LimitRange
namespaces ns v1 false Namespace
nodes no v1 false Node
persistentvolumeclaims pvc v1 true PersistentVolumeClaim
persistentvolumes pv v1 false PersistentVolume
pods po v1 true Pod
podtemplates v1 true PodTemplate
replicationcontrollers rc v1 true ReplicationController
resourcequotas quota v1 true ResourceQuota
secrets v1 true Secret
serviceaccounts sa v1 true ServiceAccount
services svc v1 true Service
mutatingwebhookconfigurations admissionregistration.k8s.io/v1 false MutatingWebhookConfiguration
validatingwebhookconfigurations admissionregistration.k8s.io/v1 false ValidatingWebhookConfiguration
customresourcedefinitions crd,crds apiextensions.k8s.io/v1 false CustomResourceDefinition
apiservices apiregistration.k8s.io/v1 false APIService
controllerrevisions apps/v1 true ControllerRevision
daemonsets ds apps/v1 true DaemonSet
deployments deploy apps/v1 true Deployment
replicasets rs apps/v1 true ReplicaSet
statefulsets sts apps/v1 true StatefulSet
applications app,apps argoproj.io/v1alpha1 true Application
applicationsets appset,appsets argoproj.io/v1alpha1 true ApplicationSet
appprojects appproj,appprojs argoproj.io/v1alpha1 true AppProject
selfsubjectreviews authentication.k8s.io/v1 false SelfSubjectReview
tokenreviews authentication.k8s.io/v1 false TokenReview
localsubjectaccessreviews authorization.k8s.io/v1 true LocalSubjectAccessReview
selfsubjectaccessreviews authorization.k8s.io/v1 false SelfSubjectAccessReview
selfsubjectrulesreviews authorization.k8s.io/v1 false SelfSubjectRulesReview
subjectaccessreviews authorization.k8s.io/v1 false SubjectAccessReview
horizontalpodautoscalers hpa autoscaling/v2 true HorizontalPodAutoscaler
cronjobs cj batch/v1 true CronJob
jobs batch/v1 true Job
certificatesigningrequests csr certificates.k8s.io/v1 false CertificateSigningRequest
leases coordination.k8s.io/v1 true Lease
endpointslices discovery.k8s.io/v1 true EndpointSlice
events ev events.k8s.io/v1 true Event
flowschemas flowcontrol.apiserver.k8s.io/v1beta3 false FlowSchema
prioritylevelconfigurations flowcontrol.apiserver.k8s.io/v1beta3 false PriorityLevelConfiguration
ingressclasses networking.k8s.io/v1 false IngressClass
ingresses ing networking.k8s.io/v1 true Ingress
networkpolicies netpol networking.k8s.io/v1 true NetworkPolicy
runtimeclasses node.k8s.io/v1 false RuntimeClass
poddisruptionbudgets pdb policy/v1 true PodDisruptionBudget
clusterrolebindings rbac.authorization.k8s.io/v1 false ClusterRoleBinding
clusterroles rbac.authorization.k8s.io/v1 false ClusterRole
rolebindings rbac.authorization.k8s.io/v1 true RoleBinding
roles rbac.authorization.k8s.io/v1 true Role
priorityclasses pc scheduling.k8s.io/v1 false PriorityClass
csidrivers storage.k8s.io/v1 false CSIDriver
csinodes storage.k8s.io/v1 false CSINode
csistoragecapacities storage.k8s.io/v1 true CSIStorageCapacity
storageclasses sc storage.k8s.io/v1 false StorageClass
volumeattachments storage.k8s.io/v1 false VolumeAttachment
이 명령어를 잘 이용하면 각 서비스에 대한 yaml파일들을 백업할 수 있다.
#!/bin/sh
DIR=/k8s-bak/resouruces # 경로 입력
mkdir -p
for NS in $(kubectl get ns --no-headers | awk '{ print $1 }') # 모든 Namespace 조회
do
mkdir -p ${DIR}/${NS} # 각 Namespace 별 폴더 생성
for RESOURCE in $(kubectl api-resources --no-headers | awk '{ print $1 }') # 리소스 조회
do
kubectl get ${RESOURCE} -n ${NS} -o yaml > ${DIR}/${NS}/${RESOURCE}.yaml # YAML 백업
done
done
실행결과
root@master:~# ./bak.yaml
root@master:/k8s-bak/resources# ls
argocd default ingress-nginx kube-node-lease kube-public kube-system
root@master:/k8s-bak/resources# cd argocd/
root@master:/k8s-bak/resources/argocd# ls
apiservices.yaml mutatingwebhookconfigurations.yaml
applicationsets.yaml namespaces.yaml
applications.yaml networkpolicies.yaml
appprojects.yaml nodes.yaml
bindings.yaml persistentvolumeclaims.yaml
certificatesigningrequests.yaml persistentvolumes.yaml
clusterrolebindings.yaml poddisruptionbudgets.yaml
clusterroles.yaml pods.yaml
componentstatuses.yaml podtemplates.yaml
configmaps.yaml priorityclasses.yaml
controllerrevisions.yaml prioritylevelconfigurations.yaml
cronjobs.yaml replicasets.yaml
csidrivers.yaml replicationcontrollers.yaml
csinodes.yaml resourcequotas.yaml
csistoragecapacities.yaml rolebindings.yaml
customresourcedefinitions.yaml roles.yaml
daemonsets.yaml runtimeclasses.yaml
deployments.yaml secrets.yaml
endpointslices.yaml selfsubjectaccessreviews.yaml
endpoints.yaml selfsubjectreviews.yaml
events.yaml selfsubjectrulesreviews.yaml
flowschemas.yaml serviceaccounts.yaml
horizontalpodautoscalers.yaml services.yaml
ingressclasses.yaml statefulsets.yaml
ingresses.yaml storageclasses.yaml
jobs.yaml subjectaccessreviews.yaml
leases.yaml tokenreviews.yaml
limitranges.yaml validatingwebhookconfigurations.yaml
localsubjectaccessreviews.yaml volumeattachments.yaml
반응형
'Develop > k8s' 카테고리의 다른 글
cri-o error validating runtime config: cannot enable checkpoint/restore support without the criu binary in (0) | 2024.04.09 |
---|---|
Ubuntu 22.04,cri-o Kubernetes(k8s) v1.29, cilium 설치 (0) | 2024.04.07 |
Windows kubectl 및 Multiple-Clusters 접근 (Windows에서 k8s Cluster 사용) (0) | 2023.11.29 |
ETCD Leader 및 List 조회 (0) | 2023.11.21 |
k8s pods 전체 삭제 및 특정 이름 전체 삭제 (0) | 2023.11.09 |