1.11.5.2.6. 상호 TLS 변경
워크로드별 PeerAuthentication 정책과 함께 mTLS를 사용할 때 워크로드 정책이 네임스페이스/글로벌 정책과 다를 경우 트래픽을 허용하려면 상응하는 DestinationRule이 필요합니다.
자동 mTLS는 기본적으로 활성화되어 있지만 ServiceMeshControlPlane 리소스에서 spec.security.dataPlane.automtls를 false로 설정하여 비활성화할 수 있습니다. 자동 mTLS를 비활성화할 때 서비스 간 적절한 통신을 위해 DestinationRules가 필요할 수 있습니다. 예를 들어, 하나의 네임스페이스에 대해 PeerAuthentication을 STRICT으로 설정하면 DestinationRule이 네임스페이스의 서비스에 TLS 모드를 구성하지 않는 한 다른 네임스페이스의 서비스에 액세스하지 못할 수 있습니다.
mTLS에 대한 자세한 내용은 mTLS(mutual Transport Layer Security) 활성화를 참조하십시오.
1.11.5.2.6.1. 기타 mTLS 예 링크 복사링크가 클립보드에 복사되었습니다!
mTLS 비활성화: bookinfo 샘플 애플리케이션의 productpage 서비스의 경우, Red Hat OpenShift Service Mesh v1.1에 대해 다음과 같은 방식으로 정책 리소스를 구성했습니다.
정책 리소스 예
apiVersion: authentication.istio.io/v1alpha1
kind: Policy
metadata:
name: productpage-mTLS-disable
namespace: <namespace>
spec:
targets:
- name: productpage
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
mTLS 활성화: bookinfo 샘플 애플리케이션에서 productpage 서비스에 대한 JWT 인증의 경우, Red Hat OpenShift Service Mesh v1.1에 대해 다음과 같은 방식으로 정책 리소스를 구성했습니다.
정책 리소스 예
apiVersion: authentication.istio.io/v1alpha1
kind: Policy
metadata:
name: productpage-mTLS-with-JWT
namespace: <namespace>
spec:
targets:
- name: productpage
ports:
- number: 9000
peers:
- mtls:
origins:
- jwt:
issuer: "https://securetoken.google.com"
audiences:
- "productpage"
jwksUri: "https://www.googleapis.com/oauth2/v1/certs"
jwtHeaders:
- "x-goog-iap-jwt-assertion"
triggerRules:
- excludedPaths:
- exact: /health_check
principalBinding: USE_ORIGIN
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