Skip to content

Files

Latest commit

 

History

History

k8s

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

Bookus-Kube

Bookus Kubernetes build files

Kubernetes Basic

Basic Functions

kubectl get pods

NAME                                   READY   STATUS    RESTARTS   AGE
kubernetes-bootcamp-5b48cfdcbd-86b6d   1/1     Running   0          13s

kubectl get services

NAME         TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)   AGE
kubernetes   ClusterIP   10.96.0.1    <none>        443/TCP   34s

kubectl expose deployment/kubernetes-bootcamp --type="NodePort" --port 8080

kubernetes            ClusterIP   10.96.0.1      <none>        443/TCP          62s
kubernetes-bootcamp   NodePort    10.98.69.218   <none>        8080:31688/TCP   59s

์ด๋Ÿฐ์‹์œผ๋กœ NodePort๋ผ๋Š” Service Type์„ ์„ค์ •ํ•ด์„œ ํฌํŠธ ํ•˜๋‚˜๋ฅผ ์—ด ์ˆ˜ ์žˆ์Œ.

kubectl describe services/kubernetes-bootcamp

Name:                     kubernetes-bootcamp
Namespace:                default
Labels:                   run=kubernetes-bootcamp
Annotations:              <none>
Selector:                 run=kubernetes-bootcamp
Type:                     NodePort
IP:                       10.98.69.218
Port:                     <unset>  8080/TCP
TargetPort:               8080/TCP
NodePort:                 <unset>  31688/TCP
Endpoints:                172.18.0.5:8080
Session Affinity:         None
External Traffic Policy:  Cluster
Events:                   <none>

export NODE_PORT= $(kubectl get services/kubernetes-bootcamp -o go-template='{{(index .spec.ports 0).nodePort}}') echo NODE_PORT=$NODE_PORT NODE_PORT=31688

์œ„์™€ ๊ฐ™์ด ํ™˜๊ฒฝ ๋ณ€์ˆ˜๋ฅผ ํ†ตํ•ด Port๋ฅผ ์™ธ๋ถ€๋กœ ๋นผ๋‚ผ ์ˆ˜ ์žˆ์Œ.

describe ๋Š” get์˜ ์ƒ์„ธ ์ถœ๋ ฅ ๋ฒ„์ „์ด๋ผ๊ณ  ๋ด๋„ ๋จ.

kubectl delete service -l run=kubernetes-bootcamp

์œ„์˜ ๋ช…๋ น์–ด๋ฅผ ์‹คํ–‰ํ•˜๋ฉด ์„œ๋น„์Šค๊ฐ€ ์‚ญ์ œ๋จ.

kubectl exec -ti $POD_NAME curl localhost:8080

๋‚ด๋ถ€์—์„œ ์‹คํ–‰ํ•˜๋Š” ํ•จ์ˆ˜. POD_NAME์—๋Š” ์‹ค์ œ ํŒŒ๋“œ ์ด๋ฆ„์ด ๋“ค์–ด์žˆ์Œ. ์ด๊ฒƒ

Labeling

kubectl get services -l run=kubernetes-bootcamp

์„œ๋น„์Šค ์ค‘์—์„œ ๊ตฌ๋™๋˜๋Š” ๊ฒƒ ์ค‘์— kubernetes-bootcamp๋ฅผ ๊ฐ€์ง„ ๋†ˆ๋งŒ ๊ฐ€์ ธ์˜ฌ ์ˆ˜ ์žˆ์Œ.