# k8s 로그인
su k8s
# 노드 상태, 정보 등 확인
[k8s@m-k8s root]$ kubectl get nodes
NAME STATUS ROLES AGE VERSION
k8s-w1 Ready <none> 3d15h v1.18.4
k8s-w2 Ready <none> 3d15h v1.18.4
m-k8s Ready master 3d17h v1.18.4
# Kubernetes 클러스터 내에서 사용 가능한 API 리소스의 목록을 표시
[k8s@m-k8s root]$ kubectl api-resources
NAME SHORTNAMES APIGROUP NAMESPACED KIND
bindings true Binding
componentstatuses cs false ComponentStatus
configmaps cm true ConfigMap
endpoints ep true Endpoints
events ev true Event
limitranges limits true LimitRange
namespaces ns false Namespace
nodes no false Node
persistentvolumeclaims pvc true PersistentVolumeClaim
persistentvolumes pv false PersistentVolume
pods po true Pod
podtemplates true PodTemplate
replicationcontrollers rc true ReplicationController
resourcequotas quota true ResourceQuota
secrets true Secret
serviceaccounts sa true ServiceAccount
services svc true Service
mutatingwebhookconfigurations admissionregistration.k8s.io false MutatingWebhookConfiguration
validatingwebhookconfigurations admissionregistration.k8s.io false ValidatingWebhookConfiguration
customresourcedefinitions crd,crds apiextensions.k8s.io false CustomResourceDefinition
apiservices apiregistration.k8s.io false APIService
controllerrevisions apps true ControllerRevision
daemonsets ds apps true DaemonSet
deployments deploy apps true Deployment
replicasets rs apps true ReplicaSet
statefulsets sts apps true StatefulSet
tokenreviews authentication.k8s.io false TokenReview
localsubjectaccessreviews authorization.k8s.io true LocalSubjectAccessReview
selfsubjectaccessreviews authorization.k8s.io false SelfSubjectAccessReview
selfsubjectrulesreviews authorization.k8s.io false SelfSubjectRulesReview
subjectaccessreviews authorization.k8s.io false SubjectAccessReview
horizontalpodautoscalers hpa autoscaling true HorizontalPodAutoscaler
cronjobs cj batch true CronJob
jobs batch true Job
certificatesigningrequests csr certificates.k8s.io false CertificateSigningRequest
leases coordination.k8s.io true Lease
bgpconfigurations crd.projectcalico.org false BGPConfiguration
bgppeers crd.projectcalico.org false BGPPeer
blockaffinities crd.projectcalico.org false BlockAffinity
clusterinformations crd.projectcalico.org false ClusterInformation
felixconfigurations crd.projectcalico.org false FelixConfiguration
globalnetworkpolicies crd.projectcalico.org false GlobalNetworkPolicy
globalnetworksets crd.projectcalico.org false GlobalNetworkSet
hostendpoints crd.projectcalico.org false HostEndpoint
ipamblocks crd.projectcalico.org false IPAMBlock
ipamconfigs crd.projectcalico.org false IPAMConfig
ipamhandles crd.projectcalico.org false IPAMHandle
ippools crd.projectcalico.org false IPPool
networkpolicies crd.projectcalico.org true NetworkPolicy
networksets crd.projectcalico.org true NetworkSet
endpointslices discovery.k8s.io true EndpointSlice
events ev events.k8s.io true Event
ingresses ing extensions true Ingress
ingressclasses networking.k8s.io false IngressClass
ingresses ing networking.k8s.io true Ingress
networkpolicies netpol networking.k8s.io true NetworkPolicy
runtimeclasses node.k8s.io false RuntimeClass
poddisruptionbudgets pdb policy true PodDisruptionBudget
podsecuritypolicies psp policy false PodSecurityPolicy
clusterrolebindings rbac.authorization.k8s.io false ClusterRoleBinding
clusterroles rbac.authorization.k8s.io false ClusterRole
rolebindings rbac.authorization.k8s.io true RoleBinding
roles rbac.authorization.k8s.io true Role
priorityclasses pc scheduling.k8s.io false PriorityClass
csidrivers storage.k8s.io false CSIDriver
csinodes storage.k8s.io false CSINode
storageclasses sc storage.k8s.io false StorageClass
volumeattachments storage.k8s.io false VolumeAttachment
# Kubernetes 클러스터에서 실행 중인 모든 Pod들의 목록을 가져옴
[k8s@m-k8s root]$ kubectl get pods --all-namespaces
NAMESPACE NAME READY STATUS RESTARTS AGE
default nginx-pod 1/1 Running 1 17h
kube-system calico-kube-controllers-99c9b6f64-xx6n8 1/1 Running 2 3d17h
kube-system calico-node-gtgk7 1/1 Running 2 3d15h
kube-system calico-node-hnl7t 1/1 Running 2 3d15h
kube-system calico-node-r7jtg 1/1 Running 3 3d17h
kube-system coredns-66bff467f8-86h42 1/1 Running 2 3d17h
kube-system coredns-66bff467f8-crh6n 1/1 Running 2 3d17h
kube-system etcd-m-k8s 1/1 Running 3 3d17h
kube-system kube-apiserver-m-k8s 1/1 Running 3 3d17h
kube-system kube-controller-manager-m-k8s 1/1 Running 4 3d17h
kube-system kube-proxy-4tbnp 1/1 Running 2 3d15h
kube-system kube-proxy-hg68b 1/1 Running 2 3d15h
kube-system kube-proxy-zws4h 1/1 Running 3 3d17h
kube-system kube-scheduler-m-k8s 1/1 Running 5 3d17h
# kubectl apply -f nginx-pod.yaml
[k8s@m-k8s ~]$ kubectl apply -f nginx-pod.yaml
pod/my-nginx-pod created
# kubectl get pods
[k8s@m-k8s ~]$ kubectl get pods
NAME READY STATUS RESTARTS AGE
my-nginx-pod 0/1 ContainerCreating 0 14s
nginx-pod 1/1 Running 1 17h
[k8s@m-k8s ~]$ kubectl get pods
NAME READY STATUS RESTARTS AGE
my-nginx-pod 0/1 ContainerCreating 0 24s
nginx-pod 1/1 Running 1 17h
[k8s@m-k8s ~]$ kubectl get pods
NAME READY STATUS RESTARTS AGE
my-nginx-pod 1/1 Running 0 38s
nginx-pod 1/1 Running 1 17h
# kubectl get pods -o wide
[k8s@m-k8s ~]$ kubectl get pods -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
my-nginx-pod 1/1 Running 0 99s 172.16.46.1 k8s-w2 <none> <none>
nginx-pod 1/1 Running 1 17h 172.16.228.66 k8s-w1 <none> <none>
# curl 172.16.46.1
[k8s@m-k8s ~]$ curl 172.16.46.1
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
html { color-scheme: light dark; }
body { width: 35em; margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif; }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>
<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>
<p><em>Thank you for using nginx.</em></p>
</body>
</html>
# linux 종료하기
shutdown -h now
# root계정에서 원격 끄기
ssh w1-k8s shutdown -h now
ssh w2-k8s shutdown -h now
'MSA' 카테고리의 다른 글
AWS II (0) | 2023.10.26 |
---|---|
쿠버네티스 II (0) | 2023.10.25 |
도커 VI - Dockerfile 명령어 (0) | 2023.10.13 |
도커 V (0) | 2023.10.11 |
도커 III - git 리포지토리 생성 (0) | 2023.10.10 |