You are viewing documentation for a release that is no longer maintainedSee documentation for the latest supported version 3 or the latest supported version 4.
1.11.5.2.6. 상호 TLS 변경
워크로드별 PeerAuthentication 정책과 함께 mTLS를 사용할 때 워크로드 정책이 네임스페이스/글로벌 정책과 다를 경우 트래픽을 허용하려면 상응하는 DestinationRule이 필요합니다.
자동 mTLS는 기본적으로 활성화되어 있지만 ServiceMeshControlPlane 리소스에서 spec.security.dataPlane.automtls를 false로 설정하여 비활성화할 수 있습니다. 자동 mTLS를 비활성화할 때 서비스 간 적절한 통신을 위해 DestinationRules가 필요할 수 있습니다. 예를 들어, 하나의 네임스페이스에 대해 PeerAuthentication을 STRICT으로 설정하면 DestinationRule이 네임스페이스의 서비스에 TLS 모드를 구성하지 않는 한 다른 네임스페이스의 서비스에 액세스하지 못할 수 있습니다.
Copy to ClipboardCopied!Toggle word wrapToggle overflow
mTLS 비활성화: bookinfo 샘플 애플리케이션의 productpage 서비스의 경우, 다음 예제를 사용하여 Red Hat OpenShift Service Mesh v2.0에 PeerAuthentication 리소스를 구성합니다.
PeerAuthentication 리소스 예
apiVersion: security.istio.io/v1beta1
kind: PeerAuthentication
metadata:
name: productpage-mTLS-disable
namespace: <namespace>
spec:
mtls:
mode: DISABLE
selector:
matchLabels:
# this should match the selector for the "productpage" service
app: productpage
apiVersion: security.istio.io/v1beta1
kind: PeerAuthentication
metadata:name: productpage-mTLS-disable
namespace: <namespace>spec:mtls:mode: DISABLE
selector:matchLabels:# this should match the selector for the "productpage" serviceapp: productpage
Copy to ClipboardCopied!Toggle word wrapToggle overflow
mTLS 활성화: bookinfo 샘플 애플리케이션에서 productpage 서비스에 대한 JWT 인증의 경우, Red Hat OpenShift Service Mesh v1.1에 대해 다음과 같은 방식으로 정책 리소스를 구성했습니다.
Copy to ClipboardCopied!Toggle word wrapToggle overflow
mTLS 활성화: bookinfo 샘플 애플리케이션에서 productpage 서비스에 대한 JWT 인증의 경우, 다음 예제를 사용하여 Red Hat OpenShift Service Mesh v2.0에 PeerAuthentication 리소스를 구성합니다.
PeerAuthentication 리소스 예
#require mtls for productpage:9000
apiVersion: security.istio.io/v1beta1
kind: PeerAuthentication
metadata:
name: productpage-mTLS-with-JWT
namespace: <namespace>
spec:
selector:
matchLabels:
# this should match the selector for the "productpage" service
app: productpage
portLevelMtls:
9000:
mode: STRICT
---
#JWT authentication for productpage
apiVersion: security.istio.io/v1beta1
kind: RequestAuthentication
metadata:
name: productpage-mTLS-with-JWT
namespace: <namespace>
spec:
selector:
matchLabels:
# this should match the selector for the "productpage" service
app: productpage
jwtRules:
- issuer: "https://securetoken.google.com"
audiences:
- "productpage"
jwksUri: "https://www.googleapis.com/oauth2/v1/certs"
fromHeaders:
- name: "x-goog-iap-jwt-assertion"
---
#Require JWT token to access product page service from
#any client to all paths except /health_check
apiVersion: security.istio.io/v1beta1
kind: AuthorizationPolicy
metadata:
name: productpage-mTLS-with-JWT
namespace: <namespace>
spec:
action: ALLOW
selector:
matchLabels:
# this should match the selector for the "productpage" service
app: productpage
rules:
- to: # require JWT token to access all other paths
- operation:
notPaths:
- /health_check
from:
- source:
# if using principalBinding: USE_PEER in the Policy,
# then use principals, e.g.
# principals:
# - “*”
requestPrincipals:
- “*”
- to: # no JWT token required to access health_check
- operation:
paths:
- /health_check
#require mtls for productpage:9000apiVersion: security.istio.io/v1beta1
kind: PeerAuthentication
metadata:name: productpage-mTLS-with-JWT
namespace: <namespace>spec:selector:matchLabels:# this should match the selector for the "productpage" serviceapp: productpage
portLevelMtls:9000:mode: STRICT
---#JWT authentication for productpageapiVersion: security.istio.io/v1beta1
kind: RequestAuthentication
metadata:name: productpage-mTLS-with-JWT
namespace: <namespace>spec:selector:matchLabels:# this should match the selector for the "productpage" serviceapp: productpage
jwtRules:-issuer:"https://securetoken.google.com"audiences:-"productpage"jwksUri:"https://www.googleapis.com/oauth2/v1/certs"fromHeaders:-name:"x-goog-iap-jwt-assertion"---#Require JWT token to access product page service from#any client to all paths except /health_checkapiVersion: security.istio.io/v1beta1
kind: AuthorizationPolicy
metadata:name: productpage-mTLS-with-JWT
namespace: <namespace>spec:action: ALLOW
selector:matchLabels:# this should match the selector for the "productpage" serviceapp: productpage
rules:-to:# require JWT token to access all other paths-operation:notPaths:- /health_check
from:-source:# if using principalBinding: USE_PEER in the Policy,# then use principals, e.g.# principals:# - “*”requestPrincipals:- “*”-to:# no JWT token required to access health_check-operation:paths:- /health_check
Copy to ClipboardCopied!Toggle word wrapToggle overflow