Kubernetes

쿠버네티스 (서비스 리소스 생성- nodeport 방식, LoadBalancer 타입 생성)

law and security 2024. 10. 1. 10:50

FQDN (파드 속에서만 사용) : 파드가 서비스주소와 포트번호를 모를 때 (환경변수에 없음)  --> 의미 : 파드생성 --> 서비스 생성


서비스주소와 포트를 알기 위해서 파드는 자신의 서비스명을 가지고 resolv.conf에 있는 dns서버 주소에 FQDN값으로 요청 --> 해당 DNS(kubedns  ---> coredns 들에게 분기 --> ip+포트 --.> 파드에게 전달 --> 받은 주소로 접속(: 서비스 주소) --> 적정한 파드로 트래픽전달 --> 그 파드가 사이트화면을 열어줌

metalLB : 쿠버네티스 전용 로드밸런서 
                bare-metal 기반의 로드밸런서 

* bare-metal?  하드웨서 속에 직접 운영체제를 설치하는 방식 -> 하이퍼바이저 등이나 로컬호스트 os의 제약사항을 받지 않을 수 있다. (= 가상화 없이 물리 서버에서 직접 클러스터를 구성하여 자원을 관리)

metalLB를 설치하려는 이유? nodeport 방식의 서비스 -> 192.168.56.100:30123 또는 192.168.56.101:30123로 접속을 했다. : 접속시 서버가 죽은 ip로 접속할 경우 서비가 중단되므로 이를 방지하기 위하여 metalLB를 설치하는 것 

ippool생성 이유?  해당 아이피 대역에 광고하기 위해서 




 
 
< POD가 서비스의 IP(CLUSTER-IP)와 PORT를 어떻게 알 수 있을까?> 

 

 

더보기
[root@k8smaster ~]# k describe node k8smaster | grep Taint
Taints:             node-role.kubernetes.io/control-plane:NoSchedule

[root@k8smaster ~]# k taint nodes k8smaster node-role.kubernetes.io/control-plane:NoSchedule-
node/k8smaster untainted

[root@k8smaster ~]# k get pods
NAME              READY   STATUS    RESTARTS      AGE
guestbook-bb58v   1/1     Running   1 (41m ago)   17h
guestbook-fbm7z   1/1     Running   1 (41m ago)   17h
guestbook-qnm2c   1/1     Running   1 (41m ago)   17h

[root@k8smaster ~]# k describe node k8smaster | grep Taint
Taints:             <none>
[root@k8smaster ~]# k get pods
No resources found in default namespace

 
-> 노드의 현재 taint 상태를 확인
-> 특정 taint를 제거
 
* k8smaster 노드는 더 이상 NoSchedule taint가 적용되지 않아, 스케줄링이 가능
 
 
 
<POD 내부에서FQDN을 이용한 서비스검색>
 

[root@k8smaster ~]# k get pods
NAME              READY   STATUS    RESTARTS      AGE
guestbook-bb58v   1/1     Running   1 (56m ago)   17h
guestbook-fbm7z   1/1     Running   1 (56m ago)   17h
guestbook-qnm2c   1/1     Running   1 (56m ago)   17h

# POD안의 컨테이너에서 FQDN을 이용한 서비스접속

[root@k8smaster ~]# kubectl exec -it guestbook-bb58v -- bash
root@guestbook-bb58v:/app# curl http://guestbook.default.svc.cluster.local
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link href="/common.css" rel="stylesheet">
<link href="/guestbook.css" rel="stylesheet">

<title>방명록 (K8S)</title>
</head>
<body>
        <div class="guestbook list displaynone" style="display: block;">
                <ul class="cont">
                        <li>
                                <p class="memo">
HealthCheck : This is v1 running in pod guestbook-fbm7z (10.102.249.24)
                                </p>
                        </li>
                </ul>
        </div>

        <h4 class="g-top">방명록 v1(정환열)</h4>
        <div class="top-img">
                <img src="/bg-guestbook.jpg">
        </div>
        <form action="/" method="post" id="frm" enctype="multipart/form-data">
                <div class="g-cont">
                        <ul>
                                <li class="name"><input name="name" type="text" maxlength="20" placeholder="이름" class="form-control"></li>
                                <li class="msg"><textarea name="content" maxlength="200" placeholder="내용을 입력해주세요" class="form-control" rows="3"></textarea></li>
                                <li>파일첨부<input type="file" name="uploadingFile"></li>
                        </ul>
                        <p class="btn btn-lg" onclick="document.getElementById('frm').submit();">방명록 남기기</p>
                </div>
        </form>

        <div class="guestbook list displaynone" style="display: block;">
                <ul class="cont">
                        <li>
                                <p class="name">최유진</p>
                                <p class="date">2024-09-25 03:43:41</p>
                                <p class="memo">방명록</p>
                                첨부파일&nbsp;:&nbsp;<a href="/downloadFile/null"></a>
                        </li>
                </ul>
        </div>
</body>

</html>root@guestbook-bb58vcurl http://guestbook.defaultdefault
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link href="/common.css" rel="stylesheet">
<link href="/guestbook.css" rel="stylesheet">

<title>방명록 (K8S)</title>
</head>
<body>
        <div class="guestbook list displaynone" style="display: block;">
                <ul class="cont">
                        <li>
                                <p class="memo">
HealthCheck : This is v1 running in pod guestbook-bb58v (10.102.249.27)
                                </p>
                        </li>
                </ul>
        </div>

        <h4 class="g-top">방명록 v1(정환열)</h4>
        <div class="top-img">
                <img src="/bg-guestbook.jpg">
        </div>
        <form action="/" method="post" id="frm" enctype="multipart/form-data">
                <div class="g-cont">
                        <ul>
                                <li class="name"><input name="name" type="text" maxlength="20" placeholder="이름" class="form-control"></li>
                                <li class="msg"><textarea name="content" maxlength="200" placeholder="내용을 입력해주세요" class="form-control" rows="3"></textarea></li>
                                <li>파일첨부<input type="file" name="uploadingFile"></li>
                        </ul>
                        <p class="btn btn-lg" onclick="document.getElementById('frm').submit();">방명록 남기기</p>
                </div>
        </form>

        <div class="guestbook list displaynone" style="display: block;">
                <ul class="cont">
                        <li>
                                <p class="name">최유진</p>
                                <p class="date">2024-09-25 03:43:41</p>
                                <p class="memo">방명록</p>
                                첨부파일&nbsp;:&nbsp;<a href="/downloadFile/null"></a>
                        </li>
                </ul>
        </div>
</body>

</html>root@guestbook-bb58v:/app#  curl http://guestbook
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link href="/common.css" rel="stylesheet">
<link href="/guestbook.css" rel="stylesheet">

<title>방명록 (K8S)</title>
</head>
<body>
        <div class="guestbook list displaynone" style="display: block;">
                <ul class="cont">
                        <li>
                                <p class="memo">
HealthCheck : This is v1 running in pod guestbook-fbm7z (10.102.249.24)
                                </p>
                        </li>
                </ul>
        </div>

        <h4 class="g-top">방명록 v1(정환열)</h4>
        <div class="top-img">
                <img src="/bg-guestbook.jpg">
        </div>
        <form action="/" method="post" id="frm" enctype="multipart/form-data">
                <div class="g-cont">
                        <ul>
                                <li class="name"><input name="name" type="text" maxlength="20" placeholder="이름" class="form-control"></li>
                                <li class="msg"><textarea name="content" maxlength="200" placeholder="내용을 입력해주세요" class="form-control" rows="3"></textarea></li>
                                <li>파일첨부<input type="file" name="uploadingFile"></li>
                        </ul>
                        <p class="btn btn-lg" onclick="document.getElementById('frm').submit();">방명록 남기기</p>
                </div>
        </form>

        <div class="guestbook list displaynone" style="display: block;">
                <ul class="cont">
                        <li>
                                <p class="name">최유진</p>
                                <p class="date">2024-09-25 03:43:41</p>
                                <p class="memo">방명록</p>
                                첨부파일&nbsp;:&nbsp;<a href="/downloadFile/null"></a>
                        </li>
                </ul>
        </div>
</body>

</html>root@guestbook-bb58v:/app#  cat /etc/resolv.conf
search default.svc.cluster.local svc.cluster.local cluster.local
nameserver 10.96.0.10
options ndots:5
root@guestbook-bb58v:/app# exit
exit

[root@k8smaster ~]# k get ns
NAME                   STATUS   AGE
default                Active   279d
kube-node-lease        Active   279d
kube-public            Active   279d
kube-system            Active   279d
kubernetes-dashboard   Active   4d22h
shopping-mall          Active   3d17h

# kube-dns ip주소 확인 

[root@k8smaster ~]# k get svc -n kube-system
NAME             TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)                  AGE
kube-dns         ClusterIP   10.96.0.10      <none>        53/UDP,53/TCP,9153/TCP   279d
metrics-server   ClusterIP   10.111.112.94   <none>        443/TCP                  4d22h

[root@k8smaster ~]# k describe svc kube-dns -n kube-system
Name:              kube-dns
Namespace:         kube-system
Labels:            k8s-app=kube-dns
                   kubernetes.io/cluster-service=true
                   kubernetes.io/name=CoreDNS
Annotations:       prometheus.io/port: 9153
                   prometheus.io/scrape: true
Selector:          k8s-app=kube-dns
Type:              ClusterIP
IP Family Policy:  SingleStack
IP Families:       IPv4
IP:                10.96.0.10
IPs:               10.96.0.10
Port:              dns  53/UDP
TargetPort:        53/UDP
Endpoints:         10.98.16.151:53,10.98.16.152:53
Port:              dns-tcp  53/TCP
TargetPort:        53/TCP
Endpoints:         10.98.16.151:53,10.98.16.152:53
Port:              metrics  9153/TCP
TargetPort:        9153/TCP
Endpoints:         10.98.16.151:9153,10.98.16.152:9153
Session Affinity:  None
Events:            <none>

[root@k8smaster ~]#  k get pods -o wide -n kube-system
NAME                                       READY   STATUS    RESTARTS       AGE    IP               NODE        NOMINATED NODE   READINESS GATES
calico-kube-controllers-7c968b5878-8w2m5   1/1     Running   7 (63m ago)    279d   10.98.16.150     k8smaster   <none>           <none>
calico-node-2q72n                          1/1     Running   7 (63m ago)    279d   192.168.56.100   k8smaster   <none>           <none>
calico-node-dhs52                          1/1     Running   13 (63m ago)   279d   192.168.56.101   k8snode1    <none>           <none>
coredns-5dd5756b68-lxcrj                   1/1     Running   7 (63m ago)    279d   10.98.16.152     k8smaster   <none>           <none>
coredns-5dd5756b68-wbs6p                   1/1     Running   7 (63m ago)    279d   10.98.16.151     k8smaster   <none>           <none>
etcd-k8smaster                             1/1     Running   7 (63m ago)    279d   192.168.56.100   k8smaster   <none>           <none>
kube-apiserver-k8smaster                   1/1     Running   7 (63m ago)    279d   192.168.56.100   k8smaster   <none>           <none>
kube-controller-manager-k8smaster          1/1     Running   7 (63m ago)    279d   192.168.56.100   k8smaster   <none>           <none>
kube-proxy-j4dsf                           1/1     Running   7 (63m ago)    279d   192.168.56.100   k8smaster   <none>           <none>
kube-proxy-s59th                           1/1     Running   13 (63m ago)   279d   192.168.56.101   k8snode1    <none>           <none>
kube-scheduler-k8smaster                   1/1     Running   7 (63m ago)    279d   192.168.56.100   k8smaster   <none>           <none>
metrics-server-6d857ffdc9-zdk82            1/1     Running   1 (63m ago)    23h    10.102.249.62    k8snode1    <none>           <none>
metrics-server-75bf97fcc9-snsmv            0/1     Running   1 (63m ago)    23h    10.102.249.5     k8snode1    <none>           <none>

 
 
->  현재의 pod가 자기를 열지 않았다. service guestbook에 요청을 해서 다른 파드 또는 자기 파드가 열릴 수 있다. 
 
ip를 pod에 전달  -> guestbook service에 전달 
 
 

[root@k8smaster ~]# k get svc
NAME         TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)   AGE
guestbook    ClusterIP   10.101.209.250   <none>        80/TCP    18h
kubernetes   ClusterIP   10.96.0.1        <none>        443/TCP   19h

[root@k8smaster ~]# curl 10.101.209.250
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link href="/common.css" rel="stylesheet">
<link href="/guestbook.css" rel="stylesheet">

<title>방명록 (K8S)</title>
</head>
<body>
        <div class="guestbook list displaynone" style="display: block;">
                <ul class="cont">
                        <li>
                                <p class="memo">
HealthCheck : This is v1 running in pod guestbook-bb58v (10.102.249.27)
                                </p>
                        </li>
                </ul>
        </div>

        <h4 class="g-top">방명록 v1(정환열)</h4>
        <div class="top-img">
                <img src="/bg-guestbook.jpg">
        </div>
        <form action="/" method="post" id="frm" enctype="multipart/form-data">
                <div class="g-cont">
                        <ul>
                                <li class="name"><input name="name" type="text" maxlength="20" placeholder="이름" class="form-control"></li>
                                <li class="msg"><textarea name="content" maxlength="200" placeholder="내용을 입력해주세요" class="form-control" rows="3"></textarea></li>
                                <li>파일첨부<input type="file" name="uploadingFile"></li>
                        </ul>
                        <p class="btn btn-lg" onclick="document.getElementById('frm').submit();">방명록 남기기</p>
                </div>
        </form>

        <div class="guestbook list displaynone" style="display: block;">
                <ul class="cont">
                        <li>
                                <p class="name">최유진</p>
                                <p class="date">2024-09-25 03:43:41</p>
                                <p class="memo">방명록</p>
                                첨부파일&nbsp;:&nbsp;<a href="/downloadFile/null"></a>
                        </li>
                </ul>
        </div>
</body>

 
-> gestbook clusterIP (=가상의 내부 IP) 주소는 외부에서(localhost) 열 수 없다.  ( 내부에서는 열 수 있다 -  node와 pod간의 연결을 가능하다.  )
 
 
< NodePort 서비스사용>

</html>[root@k8smaster ~]# cd ~/lab/05
[root@k8smaster 05]# ls
guestbook-rc-readinessprobe.yaml               guestbook-svc-loadbalancer.yaml  guestbook-svc.yaml  named-port
guestbook-replicaset.yaml                      guestbook-svc-named-ports.yaml   ingress
guestbook-svc-client-ip-session-affinity.yaml  guestbook-svc-nodeport.yaml      metalLB

[root@k8smaster 05]# k create -f guestbook-svc-nodeport.yaml
service/guestbook-nodeport created

[root@k8smaster 05]# k get svc
NAME                 TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE
guestbook            ClusterIP   10.101.209.250   <none>        80/TCP         18h
guestbook-nodeport   NodePort    10.105.204.19    <none>        80:30123/TCP   8s
kubernetes           ClusterIP   10.96.0.1        <none>        443/TCP        19h

[root@k8smaster 05]# k describe svc guestbook-nodeport
Name:                     guestbook-nodeport
Namespace:                default
Labels:                   <none>
Annotations:              <none>
Selector:                 app=guestbook
Type:                     NodePort
IP Family Policy:         SingleStack
IP Families:              IPv4
IP:                       10.105.204.19
IPs:                      10.105.204.19
Port:                     <unset>  80/TCP
TargetPort:               8080/TCP
NodePort:                 <unset>  30123/TCP
Endpoints:                10.102.249.24:8080,10.102.249.27:8080,10.102.249.33:8080
Session Affinity:         None
External Traffic Policy:  Cluster
Events:                   <none>
[root@k8smaster 05]# curl 10.105.204.19
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link href="/common.css" rel="stylesheet">
<link href="/guestbook.css" rel="stylesheet">

<title>방명록 (K8S)</title>
</head>
<body>
        <div class="guestbook list displaynone" style="display: block;">
                <ul class="cont">
                        <li>
                                <p class="memo">
HealthCheck : This is v1 running in pod guestbook-qnm2c (10.102.249.33)
                                </p>
                        </li>
                </ul>
        </div>

        <h4 class="g-top">방명록 v1(정환열)</h4>
        <div class="top-img">
                <img src="/bg-guestbook.jpg">
        </div>
        <form action="/" method="post" id="frm" enctype="multipart/form-data">
                <div class="g-cont">
                        <ul>
                                <li class="name"><input name="name" type="text" maxlength="20" placeholder="이름" class="form-control"></li>
                                <li class="msg"><textarea name="content" maxlength="200" placeholder="내용을 입력해주세요" class="form-control" rows="3"></textarea></li>
                                <li>파일첨부<input type="file" name="uploadingFile"></li>
                        </ul>
                        <p class="btn btn-lg" onclick="document.getElementById('frm').submit();">방명록 남기기</p>
                </div>
        </form>

        <div class="guestbook list displaynone" style="display: block;">
                <ul class="cont">
                        <li>
                                <p class="name">최유진</p>
                                <p class="date">2024-09-25 03:43:41</p>
                                <p class="memo">방명록</p>
                                첨부파일&nbsp;:&nbsp;<a href="/downloadFile/null"></a>
                        </li>
                </ul>
        </div>
</body>
</html>[root@k8smaster 05]# curl 10.102.249.24:8080
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link href="/common.css" rel="stylesheet">
<link href="/guestbook.css" rel="stylesheet">

<title>방명록 (K8S)</title>
</head>
<body>
        <div class="guestbook list displaynone" style="display: block;">
                <ul class="cont">
                        <li>
                                <p class="memo">
HealthCheck : This is v1 running in pod guestbook-fbm7z (10.102.249.24)
                                </p>
                        </li>
                </ul>
        </div>

        <h4 class="g-top">방명록 v1(정환열)</h4>
        <div class="top-img">
                <img src="/bg-guestbook.jpg">
        </div>
        <form action="/" method="post" id="frm" enctype="multipart/form-data">
                <div class="g-cont">
                        <ul>
                                <li class="name"><input name="name" type="text" maxlength="20" placeholder="이름" class="form-control"></li>
                                <li class="msg"><textarea name="content" maxlength="200" placeholder="내용을 입력해주세요" class="form-control" rows="3"></textarea></li>
                                <li>파일첨부<input type="file" name="uploadingFile"></li>
                        </ul>
                        <p class="btn btn-lg" onclick="document.getElementById('frm').submit();">방명록 남기기</p>
                </div>
        </form>

        <div class="guestbook list displaynone" style="display: block;">
                <ul class="cont">
                        <li>
                                <p class="name">최유진</p>
                                <p class="date">2024-09-25 03:43:41</p>
                                <p class="memo">방명록</p>
                                첨부파일&nbsp;:&nbsp;<a href="/downloadFile/null"></a>
                        </li>
                </ul>
        </div>
</body>

    
-> node 포트로도 접속 가능하다. 
 
<k8snode1접속>

 
<localhost 접속>

 
 
<yaml 파일을 사용해MetalLB 설치>   - Kubernetes에서 MetalLB는 클러스터 외부에서 접근할 수 있는 LoadBalancer 서비스를 제공하기 위해 설치
 

</html>[root@k8smaster 05]# cd metalLB

[root@k8smaster metalLB]# kubectl create -f metallb-native.yaml
namespace/metallb-system created
customresourcedefinition.apiextensions.k8s.io/addresspools.metallb.io created
customresourcedefinition.apiextensions.k8s.io/bfdprofiles.metallb.io created
customresourcedefinition.apiextensions.k8s.io/bgpadvertisements.metallb.io created
customresourcedefinition.apiextensions.k8s.io/bgppeers.metallb.io created
customresourcedefinition.apiextensions.k8s.io/communities.metallb.io created
customresourcedefinition.apiextensions.k8s.io/ipaddresspools.metallb.io created
customresourcedefinition.apiextensions.k8s.io/l2advertisements.metallb.io created
serviceaccount/controller created
serviceaccount/speaker created
role.rbac.authorization.k8s.io/controller created
role.rbac.authorization.k8s.io/pod-lister created
clusterrole.rbac.authorization.k8s.io/metallb-system:controller created
clusterrole.rbac.authorization.k8s.io/metallb-system:speaker created
rolebinding.rbac.authorization.k8s.io/controller created
rolebinding.rbac.authorization.k8s.io/pod-lister created
clusterrolebinding.rbac.authorization.k8s.io/metallb-system:controller created
clusterrolebinding.rbac.authorization.k8s.io/metallb-system:speaker created
secret/webhook-server-cert created
service/webhook-service created
deployment.apps/controller created
daemonset.apps/speaker created
validatingwebhookconfiguration.admissionregistration.k8s.io/metallb-webhook-configuration created

[root@k8smaster metalLB]# ls
metallb-ippool.yaml  metallb-l2advertisement.yaml  metallb-native.yaml

[root@k8smaster metalLB]# k get ns
NAME                   STATUS   AGE
default                Active   280d
kube-node-lease        Active   280d
kube-public            Active   280d
kube-system            Active   280d
kubernetes-dashboard   Active   5d20h
metallb-system         Active   2m43s
shopping-mall          Active   3d22h

# 외부공개용IP Address Pool 생성

[root@k8smaster metalLB]# k create -f metallb-ippool.yaml
ipaddresspool.metallb.io/ip-pool created

# Layer 2에서 사용한 NIC 인터페이스설정
[root@k8smaster metalLB]#  kubectl create -f metallb-l2advertisement.yaml


# “metallb-system” 네임스페이스에 생성된 쿠버네티스 리소스 조회

[root@k8smaster metalLB]# k -n metallb-system get all
NAME                              READY   STATUS    RESTARTS   AGE
pod/controller-67d9f4b5bc-7pgdk   1/1     Running   0          115s
pod/speaker-6rn9g                 1/1     Running   0          115s
pod/speaker-tzdrl                 1/1     Running   0          115s

NAME                      TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)   AGE
service/webhook-service   ClusterIP   10.98.171.102   <none>        443/TCP   115s

NAME                     DESIRED   CURRENT   READY   UP-TO-DATE   AVAILABLE   NODE SELECTOR            AGE
daemonset.apps/speaker   2         2         2       2            2           kubernetes.io/os=linux   115s

NAME                         READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/controller   1/1     1            1           115s

NAME                                    DESIRED   CURRENT   READY   AGE
replicaset.apps/controller-67d9f4b5bc   1         1         1       115s

 
 
< 외부 로드 밸런서>

[root@k8smaster 05]# k create -f guestbook-svc-loadbalancer.yaml
service/guestbook-loadbalancer created
[root@k8smaster 05]# k get svc guestbook-loadbalancer
NAME                     TYPE           CLUSTER-IP      EXTERNAL-IP      PORT(S)        AGE
guestbook-loadbalancer   LoadBalancer   10.101.124.39   192.168.56.201   80:31116/TCP   17s
[root@k8smaster 05]# k describe svc guestbook-loadbalancer
Name:                     guestbook-loadbalancer
Namespace:                default
Labels:                   <none>
Annotations:              <none>
Selector:                 app=guestbook
Type:                     LoadBalancer
IP Family Policy:         SingleStack
IP Families:              IPv4
IP:                       10.101.124.39
IPs:                      10.101.124.39
LoadBalancer Ingress:     192.168.56.201
Port:                     <unset>  80/TCP
TargetPort:               8080/TCP
NodePort:                 <unset>  31116/TCP
Endpoints:                10.98.16.177:8080,10.98.16.178:8080,10.98.16.181:8080
Session Affinity:         None
External Traffic Policy:  Cluster
Events:
  Type    Reason       Age   From                Message
  ----    ------       ----  ----                -------
  Normal  IPAllocated  44s   metallb-controller  Assigned IP ["192.168.56.201"]
  
  [root@k8smaster 05]# k get svc
NAME                     TYPE           CLUSTER-IP       EXTERNAL-IP      PORT(S)        AGE
guestbook                ClusterIP      10.101.209.250   <none>           80/TCP         23h
guestbook-loadbalancer   LoadBalancer   10.101.124.39    192.168.56.201   80:31116/TCP   2m41s
guestbook-nodeport       NodePort       10.105.204.19    <none>           80:30123/TCP   4h54m
kubernetes               ClusterIP      10.96.0.1        <none>           443/TCP        24h
[root@k8smaster 05]# curl http://10.101.124.39
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link href="/common.css" rel="stylesheet">
<link href="/guestbook.css" rel="stylesheet">

<title>방명록 (K8S)</title>
</head>
<body>
        <div class="guestbook list displaynone" style="display: block;">
                <ul class="cont">
                        <li>
                                <p class="memo">
HealthCheck : This is v1 running in pod guestbook-7nbrc (10.98.16.178)
                                </p>
                        </li>
                </ul>
        </div>

        <h4 class="g-top">방명록 v1(정환열)</h4>
        <div class="top-img">
                <img src="/bg-guestbook.jpg">
        </div>
        <form action="/" method="post" id="frm" enctype="multipart/form-data">
                <div class="g-cont">
                        <ul>
                                <li class="name"><input name="name" type="text" maxlength="20" placeholder="이름" class="form-control"></li>
                                <li class="msg"><textarea name="content" maxlength="200" placeholder="내용을 입력해주세요" class="form-control" rows="3"></textarea></li>
                                <li>파일첨부<input type="file" name="uploadingFile"></li>
                        </ul>
                        <p class="btn btn-lg" onclick="document.getElementById('frm').submit();">방명록 남기기</p>
                </div>
        </form>

        <div class="guestbook list displaynone" style="display: block;">
                <ul class="cont">
                        <li>
                                <p class="name">최유진</p>
                                <p class="date">2024-09-25 03:43:41</p>
                                <p class="memo">방명록</p>
                                첨부파일&nbsp;:&nbsp;<a href="/downloadFile/null"></a>
                        </li>
                </ul>
        </div>
</body>

[root@k8smaster 05]# curl http://10.101.124.39
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link href="/common.css" rel="stylesheet">
<link href="/guestbook.css" rel="stylesheet">

<title>방명록 (K8S)</title>
</head>
<body>
        <div class="guestbook list displaynone" style="display: block;">
                <ul class="cont">
                        <li>
                                <p class="memo">
HealthCheck : This is v1 running in pod guestbook-6dxw7 (10.98.16.146)
                                </p>
                        </li>
                </ul>
        </div>

        <h4 class="g-top">방명록 v1(정환열)</h4>
        <div class="top-img">
                <img src="/bg-guestbook.jpg">
        </div>
        <form action="/" method="post" id="frm" enctype="multipart/form-data">
                <div class="g-cont">
                        <ul>
                                <li class="name"><input name="name" type="text" maxlength="20" placeholder="이름" class="form-control"></li>
                                <li class="msg"><textarea name="content" maxlength="200" placeholder="내용을 입력해주세요" class="form-control" rows="3"></textarea></li>
                                <li>파일첨부<input type="file" name="uploadingFile"></li>
                        </ul>
                        <p class="btn btn-lg" onclick="document.getElementById('frm').submit();">방명록 남기기</p>
                </div>
        </form>

        <div class="guestbook list displaynone" style="display: block;">
                <ul class="cont">
                        <li>
                                <p class="name">최유진</p>
                                <p class="date">2024-09-25 03:43:41</p>
                                <p class="memo">방명록</p>
                                첨부파일&nbsp;:&nbsp;<a href="/downloadFile/null"></a>
                        </li>
                </ul>
        </div>
</body>

 
 

 
-> 로컬에서 연결되는 것을 확인 
 
 
 


 

<미션> 서비스 리소스 생성
1. 디폴트로 생성 --> curl명령 또는 k8snode1에서 확인 
2. nodeport 방식으로 서비스 생성 -->  curl 명령을 통해 cluster IP 접속 / 로컬호스트 IP로 접속 (100/101:30123)
3. LoadBalancer 타입 생성  -->  external IP 로 로컬  호스트에서 접속 테스트, nodeport 방식으로 접속 테스트, cluster IP로 접속 테스트