【发布时间】:2020-12-12 04:04:01
【问题描述】:
我有一个安装了 Istio 的 AKS 集群。我正在使用 Kubernetes Client for C# 在我的集群上执行一些操作(读取和创建机密)。 我为此配置了适当的集群角色和绑定:
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: secret-creator
rules:
- apiGroups: [""]
resources: ["secrets"]
verbs: ["create", "get", "list", "delete", "update"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: role-binding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: secret-creator
subjects:
- kind: ServiceAccount
name: default
namespace: default
目前该服务位于默认命名空间中,并在默认服务帐户下运行。我为我的整个集群设置了 PeerAuthentication 和 DestinationRules,如下所示:
apiVersion: security.istio.io/v1beta1
kind: PeerAuthentication
metadata:
name: default
namespace: default
spec:
mtls: {}
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
name: Mdestinationrule
namespace: default
spec:
host: "*"
trafficPolicy:
tls:
mode: ISTIO_MUTUAL
使用这些配置后,我的服务无法与 API 服务器通信以使用 KubeClient 的 client.ReadNamespacedSecret(name, secretNamespace) 。当我禁用我的destinationRule 时,事情就开始起作用了。
由于某些限制,我无法修改现有的destiationRules,也无法将我的服务部署在单独的命名空间中。我需要帮助以了解在与 API 服务器通信时是否可以放置某种过滤器或类似的东西,以便通信不是 mTls?
请指教。
【问题讨论】:
-
您遇到什么错误?是禁止错误吗?可以分享 envoy sidecar 的日志吗?
-
@Arghya,以前我被禁止了,我按照你之前的一个问题中的建议解决了这个问题。当时我没有在默认命名空间上启用此 DestinationRule,但启用后,我开始从 Kube 客户端代码中获取它:
Error in KubeClient :The SSL connection could not be established, see inner exception. StackTrace : System.IO.IOException: Unable to read data from the transport connection: Connection reset by peer. ---> System.Net.Sockets.SocketException (104): Connection reset by peer --- End of inner exception stack trace --- -
我会说您的 PeerAuthentication 不正确。据我检查documentation PeerAuthentication mtls 的值是未设置、许可、严格和禁用。您能否尝试将其从
spec: mtls: {}更改为spec: mtls: mode: DISABLE并检查是否有效?另一件事是目标规则中的通配符主机,我不确定这是否可行,它应该是服务注册表中的服务名称。 -
@Jakub mtls : {} 是另一种表示“严格”的方式,所以这可能不是问题。我找到了配置上述方法的方法,将发布解决方案。
标签: c# kubernetes istio azure-aks