HAProxy 라우터는 와일드카드 경로를 지원하며, 이 경로는 ROUTER_ALLOW_WILDCARD_ROUTES 환경 변수를 true 로 설정하여 활성화됩니다. 라우터 승인 검사를 통과하는 와일드카드 정책이 Subdomain 인 모든 경로는 HAProxy 라우터에서 서비스를 제공합니다. 그런 다음 HAProxy 라우터는 경로의 와일드카드 정책에 따라 연결된 서비스(경로용)를 노출합니다.
중요
경로의 와일드카드 정책을 변경하려면 경로를 제거하고 업데이트된 와일드카드 정책으로 다시 생성해야 합니다. 경로의 .yaml 파일에서 경로의 와일드카드 정책만 편집하는 것은 작동하지 않습니다.
Copy to ClipboardCopied!Toggle word wrapToggle overflow
*.example.test 에 대한 DNS 항목이 라우터 인스턴스를 가리키는지 확인하고 도메인의 경로를 사용할 수 있는지 확인합니다.
이 예제에서는 로컬 확인자와 함께 curl 을 사용하여 DNS 조회를 시뮬레이션합니다.
routerip="4.1.1.1" # replace with IP address of one of your router instances.
curl -k --resolve www.example.test:443:$routerip https://www.example.test/
curl -k --resolve abc.example.test:443:$routerip https://abc.example.test/
curl -k --resolve anyname.example.test:443:$routerip https://anyname.example.test/
# routerip="4.1.1.1" # replace with IP address of one of your router instances.
# curl -k --resolve www.example.test:443:$routerip https://www.example.test/
# curl -k --resolve abc.example.test:443:$routerip https://abc.example.test/
# curl -k --resolve anyname.example.test:443:$routerip https://anyname.example.test/
Copy to ClipboardCopied!Toggle word wrapToggle overflow
와일드카드 경로(ROUTER_ALLOW_WILDCARD_ROUTES 가 true로 설정됨)를 허용하는 라우터의 경우 와일드카드 경로와 연결된 하위 도메인의 소유권에 대한 몇 가지 주의 사항이 있습니다.
와일드카드 경로 이전에는 다른 클레임에 대해 경로가 가장 오래된 네임스페이스를 사용하는 호스트 이름에 대한 소유권을 기반으로 했습니다. 예를 들어, 1. example.test 에 대한 클레임이 있는 네임스페이스 ns1 의 경로 r1은 경로 r2 가 경로 r 2보다 오래된 경우 네임스페이스 ns2 의 다른 경로 r2 에 대해 상이합니다.
또한 다른 네임스페이스의 경로는 오버레이되지 않은 호스트 이름을 요청할 수 있었습니다. 예를 들어 네임스페이스 ns1의 routerone은 www.example.test 를 클레임하고 네임스페이스 d2 의 다른 경로 rtwo 는 c3po.example.test 를 클레임할 수 있습니다.
동일한 하위 도메인을 클레임하는 와일드카드 경로(위예제에서 example.test )가 없는 경우에도 마찬가지입니다.
그러나 와일드카드 경로는 하위 도메인(\ *.example.test 형식의 호스트 이름) 내의 모든 호스트 이름을 요청해야 합니다. 와일드카드 경로의 클레임은 해당 하위 도메인의 가장 오래된 경로(예.test)가 와일드카드 경로와 동일한 네임스페이스에 있는지 여부에 따라 허용 또는 거부됩니다. 가장 오래된 경로는 일반 경로 또는 와일드카드 경로일 수 있습니다.
예를 들어, owner.example.test 라는 호스트를 요청한 ns1 네임스페이스에 경로 eldest 가 이미 있고 나중에 해당 하위 도메인의 경로(예.test)에 요청하는 새 와일드카드 경로 와일드카드 경로가 추가된 경우 와일드카드 경로의 클레임은소유경로와 동일한 네임스페이스(ns1)인 경우에만 허용됩니다.
다음 예제에서는 와일드카드 경로 클레임이 성공 또는 실패하는 다양한 시나리오를 보여줍니다.
아래 예제에서 와일드카드 경로를 허용하는 라우터는 와일드카드 경로가 하위 도메인을 요청하지 않은 한 하위 도메인 example.test 에 있는 호스트에 대한 비 오버레이 클레임을 허용합니다.
oc adm router ...
oc set env dc/router ROUTER_ALLOW_WILDCARD_ROUTES=true
oc project ns1
oc expose service myservice --hostname=owner.example.test
oc expose service myservice --hostname=aname.example.test
oc expose service myservice --hostname=bname.example.test
oc project ns2
oc expose service anotherservice --hostname=second.example.test
oc expose service anotherservice --hostname=cname.example.test
oc project otherns
oc expose service thirdservice --hostname=emmy.example.test
oc expose service thirdservice --hostname=webby.example.test
$ oc adm router ...
$ oc set env dc/router ROUTER_ALLOW_WILDCARD_ROUTES=true
$ oc project ns1
$ oc expose service myservice --hostname=owner.example.test
$ oc expose service myservice --hostname=aname.example.test
$ oc expose service myservice --hostname=bname.example.test
$ oc project ns2
$ oc expose service anotherservice --hostname=second.example.test
$ oc expose service anotherservice --hostname=cname.example.test
$ oc project otherns
$ oc expose service thirdservice --hostname=emmy.example.test
$ oc expose service thirdservice --hostname=webby.example.test
Copy to ClipboardCopied!Toggle word wrapToggle overflow
아래 예제에서 와일드카드 경로를 허용하는 라우터에서는 소유자.example.test 또는 aname.example.example.test 에 대한 클레임을 성공적으로 허용하지 않습니다. 소유 네임스페이스는 ns1 입니다.
oc adm router ...
oc set env dc/router ROUTER_ALLOW_WILDCARD_ROUTES=true
oc project ns1
oc expose service myservice --hostname=owner.example.test
oc expose service myservice --hostname=aname.example.test
oc project ns2
oc expose service secondservice --hostname=bname.example.test
oc expose service secondservice --hostname=cname.example.test
# Router will not allow this claim with a different path name `/p1` as
# namespace `ns1` has an older route claiming host `aname.example.test`.
oc expose service secondservice --hostname=aname.example.test --path="/p1"
# Router will not allow this claim as namespace `ns1` has an older route
# claiming host name `owner.example.test`.
oc expose service secondservice --hostname=owner.example.test
oc project otherns
# Router will not allow this claim as namespace `ns1` has an older route
# claiming host name `aname.example.test`.
oc expose service thirdservice --hostname=aname.example.test
$ oc adm router ...
$ oc set env dc/router ROUTER_ALLOW_WILDCARD_ROUTES=true
$ oc project ns1
$ oc expose service myservice --hostname=owner.example.test
$ oc expose service myservice --hostname=aname.example.test
$ oc project ns2
$ oc expose service secondservice --hostname=bname.example.test
$ oc expose service secondservice --hostname=cname.example.test
$ # Router will not allow this claim with a different path name `/p1` as
$ # namespace `ns1` has an older route claiming host `aname.example.test`.
$ oc expose service secondservice --hostname=aname.example.test --path="/p1"
$ # Router will not allow this claim as namespace `ns1` has an older route
$ # claiming host name `owner.example.test`.
$ oc expose service secondservice --hostname=owner.example.test
$ oc project otherns
$ # Router will not allow this claim as namespace `ns1` has an older route
$ # claiming host name `aname.example.test`.
$ oc expose service thirdservice --hostname=aname.example.test
Copy to ClipboardCopied!Toggle word wrapToggle overflow
아래 예제에서 와일드카드 경로를 허용하는 라우터를 사용하면 소유 네임스페이스가 ns1 이고 와일드카드 경로는 동일한 네임스페이스에 속하므로 '\*.example.test.test 클레임이 성공합니다.
oc adm router ...
oc set env dc/router ROUTER_ALLOW_WILDCARD_ROUTES=true
oc project ns1
oc expose service myservice --hostname=owner.example.test
# Reusing the route.yaml from the previous example.
# spec:
# host: www.example.test
# wildcardPolicy: Subdomain
oc create -f route.yaml # router will allow this claim.
$ oc adm router ...
$ oc set env dc/router ROUTER_ALLOW_WILDCARD_ROUTES=true
$ oc project ns1
$ oc expose service myservice --hostname=owner.example.test
$ # Reusing the route.yaml from the previous example.
$ # spec:
$ # host: www.example.test
$ # wildcardPolicy: Subdomain
$ oc create -f route.yaml # router will allow this claim.
Copy to ClipboardCopied!Toggle word wrapToggle overflow
아래 예에서 와일드카드 경로를 허용하는 라우터에서는 소유 네임스페이스가 ns1 이고 와일드카드 경로는 다른 네임 스페이스에 속하므로 '\*.example.test.test에 대한 클레임이 성공하지 못합니다 .
oc adm router ...
oc set env dc/router ROUTER_ALLOW_WILDCARD_ROUTES=true
oc project ns1
oc expose service myservice --hostname=owner.example.test
# Switch to a different namespace/project.
oc project cyclone
# Reusing the route.yaml from a prior example.
# spec:
# host: www.example.test
# wildcardPolicy: Subdomain
oc create -f route.yaml # router will deny (_NOT_ allow) this claim.
$ oc adm router ...
$ oc set env dc/router ROUTER_ALLOW_WILDCARD_ROUTES=true
$ oc project ns1
$ oc expose service myservice --hostname=owner.example.test
$ # Switch to a different namespace/project.
$ oc project cyclone
$ # Reusing the route.yaml from a prior example.
$ # spec:
$ # host: www.example.test
$ # wildcardPolicy: Subdomain
$ oc create -f route.yaml # router will deny (_NOT_ allow) this claim.
Copy to ClipboardCopied!Toggle word wrapToggle overflow
마찬가지로 와일드카드 경로가 있는 네임스페이스에서 하위 도메인을 요청하면 해당 네임스페이스 내 경로만 동일한 하위 도메인의 호스트를 요청할 수 있습니다.
아래 예제에서 와일드카드 경로가 subdomain example.test 인 네임스페이스 ns1 의 경로가 있으면 네임스페이스 ns1 의 경로만 동일한 하위 도메인의 호스트를 요청할 수 있습니다.
oc adm router ...
oc set env dc/router ROUTER_ALLOW_WILDCARD_ROUTES=true
oc project ns1
oc expose service myservice --hostname=owner.example.test
oc project otherns
# namespace `otherns` is allowed to claim for other.example.test
oc expose service otherservice --hostname=other.example.test
oc project ns1
# Reusing the route.yaml from the previous example.
# spec:
# host: www.example.test
# wildcardPolicy: Subdomain
oc create -f route.yaml # Router will allow this claim.
# In addition, route in namespace otherns will lose its claim to host
# `other.example.test` due to the wildcard route claiming the subdomain.
# namespace `ns1` is allowed to claim for deux.example.test
oc expose service mysecondservice --hostname=deux.example.test
# namespace `ns1` is allowed to claim for deux.example.test with path /p1
oc expose service mythirdservice --hostname=deux.example.test --path="/p1"
oc project otherns
# namespace `otherns` is not allowed to claim for deux.example.test
# with a different path '/otherpath'
oc expose service otherservice --hostname=deux.example.test --path="/otherpath"
# namespace `otherns` is not allowed to claim for owner.example.test
oc expose service yetanotherservice --hostname=owner.example.test
# namespace `otherns` is not allowed to claim for unclaimed.example.test
oc expose service yetanotherservice --hostname=unclaimed.example.test
$ oc adm router ...
$ oc set env dc/router ROUTER_ALLOW_WILDCARD_ROUTES=true
$ oc project ns1
$ oc expose service myservice --hostname=owner.example.test
$ oc project otherns
$ # namespace `otherns` is allowed to claim for other.example.test
$ oc expose service otherservice --hostname=other.example.test
$ oc project ns1
$ # Reusing the route.yaml from the previous example.
$ # spec:
$ # host: www.example.test
$ # wildcardPolicy: Subdomain
$ oc create -f route.yaml # Router will allow this claim.
$ # In addition, route in namespace otherns will lose its claim to host
$ # `other.example.test` due to the wildcard route claiming the subdomain.
$ # namespace `ns1` is allowed to claim for deux.example.test
$ oc expose service mysecondservice --hostname=deux.example.test
$ # namespace `ns1` is allowed to claim for deux.example.test with path /p1
$ oc expose service mythirdservice --hostname=deux.example.test --path="/p1"
$ oc project otherns
$ # namespace `otherns` is not allowed to claim for deux.example.test
$ # with a different path '/otherpath'
$ oc expose service otherservice --hostname=deux.example.test --path="/otherpath"
$ # namespace `otherns` is not allowed to claim for owner.example.test
$ oc expose service yetanotherservice --hostname=owner.example.test
$ # namespace `otherns` is not allowed to claim for unclaimed.example.test
$ oc expose service yetanotherservice --hostname=unclaimed.example.test
Copy to ClipboardCopied!Toggle word wrapToggle overflow
아래 예제에서는 소유자 경로가 삭제되고 소유권이 네임스페이스 내에서 전달되는 다양한 시나리오가 표시되어 있습니다. 네임스페이스 ns1 에 호스트를 클레임하는 경로에는 eldest .example.test 가 있지만 해당 네임스페이스의 와일드카드 경로는 하위 도메인 example.test 를 요청할 수 있습니다. 호스트 eldest .example.test 의 경로가 삭제되면 다음 가장 오래된 경로 senior.example.test 가 가장 오래된 경로가 되며 다른 경로에는 영향을 주지 않습니다. 호스트 senior.example.test 의 경로가 삭제되면 가장 오래된 다음 경로 junior.example.test 가 가장 오래된 경로가 되고 와일드카드 경로 클레임자를 차단합니다.
oc adm router ...
oc set env dc/router ROUTER_ALLOW_WILDCARD_ROUTES=true
oc project ns1
oc expose service myservice --hostname=eldest.example.test
oc expose service seniorservice --hostname=senior.example.test
oc project otherns
# namespace `otherns` is allowed to claim for other.example.test
oc expose service juniorservice --hostname=junior.example.test
oc project ns1
# Reusing the route.yaml from the previous example.
# spec:
# host: www.example.test
# wildcardPolicy: Subdomain
oc create -f route.yaml # Router will allow this claim.
# In addition, route in namespace otherns will lose its claim to host
# `junior.example.test` due to the wildcard route claiming the subdomain.
# namespace `ns1` is allowed to claim for dos.example.test
oc expose service mysecondservice --hostname=dos.example.test
# Delete route for host `eldest.example.test`, the next oldest route is
# the one claiming `senior.example.test`, so route claims are unaffacted.
oc delete route myservice
# Delete route for host `senior.example.test`, the next oldest route is
# the one claiming `junior.example.test` in another namespace, so claims
# for a wildcard route would be affected. The route for the host
# `dos.example.test` would be unaffected as there are no other wildcard
# claimants blocking it.
oc delete route seniorservice
$ oc adm router ...
$ oc set env dc/router ROUTER_ALLOW_WILDCARD_ROUTES=true
$ oc project ns1
$ oc expose service myservice --hostname=eldest.example.test
$ oc expose service seniorservice --hostname=senior.example.test
$ oc project otherns
$ # namespace `otherns` is allowed to claim for other.example.test
$ oc expose service juniorservice --hostname=junior.example.test
$ oc project ns1
$ # Reusing the route.yaml from the previous example.
$ # spec:
$ # host: www.example.test
$ # wildcardPolicy: Subdomain
$ oc create -f route.yaml # Router will allow this claim.
$ # In addition, route in namespace otherns will lose its claim to host
$ # `junior.example.test` due to the wildcard route claiming the subdomain.
$ # namespace `ns1` is allowed to claim for dos.example.test
$ oc expose service mysecondservice --hostname=dos.example.test
$ # Delete route for host `eldest.example.test`, the next oldest route is
$ # the one claiming `senior.example.test`, so route claims are unaffacted.
$ oc delete route myservice
$ # Delete route for host `senior.example.test`, the next oldest route is
$ # the one claiming `junior.example.test` in another namespace, so claims
$ # for a wildcard route would be affected. The route for the host
$ # `dos.example.test` would be unaffected as there are no other wildcard
$ # claimants blocking it.
$ oc delete route seniorservice
Copy to ClipboardCopied!Toggle word wrapToggle overflow