允许突变网钩使用启用TLS的ISTIO
我有以下mutatingwebhookconfiguration
apiVersion: admissionregistration.k8s.io/v1
kind: MutatingWebhookConfiguration
metadata:
name: example-webhook
webhooks:
- name: example-webhook.default.svc.cluster.local
admissionReviewVersions:
- "v1beta1"
sideEffects: "None"
timeoutSeconds: 30
objectSelector:
matchLabels:
example-webhook-enabled: "true"
clientConfig:
service:
name: example-webhook
namespace: default
path: "/mutate"
caBundle: "LS0tLS1CR..."
rules:
- operations: [ "CREATE" ]
apiGroups: [""]
apiVersions: ["v1"]
resources: ["pods"]
我想在webhook
pod中注入istio
inabled namepace istio
具有严格的TLS模式开启。
因此,(我认为)在我的示例中不需要tls,webhook
服务,因此将其制作如下:
apiVersion: v1
kind: Service
metadata:
name: example-webhook
namespace: default
spec:
selector:
app: example-webhook
ports:
- port: 80
targetPort: webhook
name: webhook
但是,当创建pod
时(确实确实触发了Webhook) )我会收到以下错误:
▶ k create -f demo-pod.yaml
Error from server (InternalError): error when creating "demo-pod.yaml": Internal error occurred: failed calling webhook "example-webhook.default.svc.cluster.local": Post "https://example-webhook.default.svc:443/mutate?timeout=30s": no service port 443 found for service "example-webhook"
我不能配置不在443
上的webhook而不是80
上调用?无论哪种方式,TLS终止都是由istio
sidecar完成的。
有没有办法使用virtualService
/destinationRule
?
edit :最重要的是,为什么它试图在示例>示例webhook.default.svc
endpoint中达到服务? (虽然应该在示例webhook.default.svc.cluster.local.local
中这样做)?
更新1
我尝试使用https
,如下所示:
我使用istio's CA创建了一个证书和私钥。
我可以验证证书中的DNS名称是否有效如下(来自另一个POD),
echo | openssl s_client -showcerts -servername example-webhook.default.svc -connect example-webhook.default.svc:443 2>/dev/null | openssl x509 -inform pem -noout -text
...
Subject: C = GR, ST = Attica, L = Athens, O = Engineering, OU = FOO, CN = *.cluster.local, emailAddress = [email protected]
...
X509v3 extensions:
X509v3 Subject Alternative Name:
DNS:*.default.svc.cluster.local, DNS:example-webhook, DNS:example-webhook.default.svc
...
但现在POD的创建失败如下:
▶ k create -f demo-pod.yaml
Error from server (InternalError): error when creating "demo-pod.yaml": Internal error occurred: failed calling webhook "example-webhook.default.svc.cluster.local": Post "https://example-webhook.default.svc:443/mutate?timeout=30s": x509: certificate is not valid for any names, but wanted to match example-webhook.default.svc
更新2
使用istio
istio <适当地创建了Webhook Pod的证书的事实。 /代码> CA证书,也已验证。
curl --cacert istio_cert https://example-webhook.default.svc
Test
istio_cert
包含ISTIO CA证书的文件
是在发生什么?
I have the following MutatingWebhookConfiguration
apiVersion: admissionregistration.k8s.io/v1
kind: MutatingWebhookConfiguration
metadata:
name: example-webhook
webhooks:
- name: example-webhook.default.svc.cluster.local
admissionReviewVersions:
- "v1beta1"
sideEffects: "None"
timeoutSeconds: 30
objectSelector:
matchLabels:
example-webhook-enabled: "true"
clientConfig:
service:
name: example-webhook
namespace: default
path: "/mutate"
caBundle: "LS0tLS1CR..."
rules:
- operations: [ "CREATE" ]
apiGroups: [""]
apiVersions: ["v1"]
resources: ["pods"]
I want to inject the webhook
pod in an istio
enabled namespace with istio
having strict TLS mode on.
Therefore, (I thought) TLS should not be needed in my example-webhook
service so it is crafted as follows:
apiVersion: v1
kind: Service
metadata:
name: example-webhook
namespace: default
spec:
selector:
app: example-webhook
ports:
- port: 80
targetPort: webhook
name: webhook
However when creating a Pod
(that does indeed trigger the webhook) I get the following error:
▶ k create -f demo-pod.yaml
Error from server (InternalError): error when creating "demo-pod.yaml": Internal error occurred: failed calling webhook "example-webhook.default.svc.cluster.local": Post "https://example-webhook.default.svc:443/mutate?timeout=30s": no service port 443 found for service "example-webhook"
Can't I configure the webhook not to be called on 443
but rather on 80
? Either way TLS termination is done by the istio
sidecar.
Is there a way around this using VirtualService
/ DestinationRule
?
edit: on top of that, why is it trying to reach the service in the example-webhook.default.svc
endpoint? (while it should be doing so in example-webhook.default.svc.cluster.local
) ?
Update 1
I have tried to use https
as follows:
I have created a certificate and private key, using istio's CA.
I can verify that my DNS names in the cert are valid as follows (from another pod)
echo | openssl s_client -showcerts -servername example-webhook.default.svc -connect example-webhook.default.svc:443 2>/dev/null | openssl x509 -inform pem -noout -text
...
Subject: C = GR, ST = Attica, L = Athens, O = Engineering, OU = FOO, CN = *.cluster.local, emailAddress = [email protected]
...
X509v3 extensions:
X509v3 Subject Alternative Name:
DNS:*.default.svc.cluster.local, DNS:example-webhook, DNS:example-webhook.default.svc
...
but now pod creation fails as follows:
▶ k create -f demo-pod.yaml
Error from server (InternalError): error when creating "demo-pod.yaml": Internal error occurred: failed calling webhook "example-webhook.default.svc.cluster.local": Post "https://example-webhook.default.svc:443/mutate?timeout=30s": x509: certificate is not valid for any names, but wanted to match example-webhook.default.svc
Update 2
The fact that the certs the webhook pod are running with were appropriately created using the istio
CA cert, is also validated.
curl --cacert istio_cert https://example-webhook.default.svc
Test
where istio_cert
is the file containing istio's CA certificate
What is going on?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
不确定您是否可以在端口80上使用Webhook ...
也许其中一些对您有用,我使用以下脚本来生成证书,您可以更改它以适合您的需求:
脚本创建了一个秘密,然后我然后安装到webhook,deployment.yaml:
service.yaml:
Not sure if you can use webhook on port 80...
Perhaps some of this will be useful to you, I used the following script to generate certificates, you can change it to suit your needs:
The script creates a secret, which I then mounted into the webhook, deployment.yaml:
service.yaml:
您是否尝试在突变webhookconfiguration中添加端口属性
Did you try adding the port attribute in your MutatingWebhookConfiguration
您可以尝试更改价值
You can try changing value