1. 탬플릿 작성

  • externalname.yaml
apiVersion: v1
kind: Service
metadata:
  name: externalname-service
spec:
  type: ExternalName
  externalName: google.com

2. 서비스 구조

  • 파드에서 Extername 타입 서비스에 도메인 요청을 하여 접속하는 구조

KUB54001

3. 서비스 생성

root@instance-1:/sorc001/kubernetes-book-sample/service# kubectl apply -f externalname.yaml 
service/externalname-service created
root@instance-1:/sorc001/kubernetes-book-sample/service# kubectl get vc
error: the server doesn't have a resource type "vc"
root@instance-1:/sorc001/kubernetes-book-sample/service# kubectl get svc
NAME                   TYPE           CLUSTER-IP      EXTERNAL-IP   PORT(S)        AGE
externalname-service   ExternalName   <none>          google.com    <none>         10s

4. 접근 테스트

root@instance-1:/sorc001/kubernetes-book-sample/service# kubectl run -it --image nicolaka/netshoot testnet bash
kubectl run --generator=deployment/apps.v1 is DEPRECATED and will be removed in a future version. Use kubectl run --generator=run-pod/v1 or kubectl create instead.
If you don't see a command prompt, try pressing enter.
bash-5.0# curl externalname-service.default.svc.cluster.local
<!DOCTYPE html>
<html lang=en>
  <meta charset=utf-8>

5. 전체 프로세스

댓글남기기