<p>I have the following <code>MutatingWebhookConfiguration</code></p>
<pre><code>apiVersion: admissionregistration.k8s.io/v1
kind: MutatingWebhookConfiguration
metadata:
  name: example-webhook
webhooks:
  - name: example-webhook.default.svc.cluster.local
    admissionReviewVersions:
      - &quot;v1beta1&quot;
    sideEffects: &quot;None&quot;
    timeoutSeconds: 30
    objectSelector:
      matchLabels:
        example-webhook-enabled: &quot;true&quot;
    clientConfig:
      service:
        name: example-webhook
        namespace: default
        path: &quot;/mutate&quot;
      caBundle: &quot;LS0tLS1CR...&quot;
    rules:
      - operations: [ &quot;CREATE&quot; ]
        apiGroups: [&quot;&quot;]
        apiVersions: [&quot;v1&quot;]
        resources: [&quot;pods&quot;]
</code></pre>
<p>I want to inject the <code>webhook</code> pod in an <code>istio</code> enabled namespace with <code>istio</code> having strict TLS mode on.</p>
<p>Therefore, (I thought) TLS should not be needed in my <code>example-webhook</code> service so it is crafted as follows:</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: example-webhook
  namespace: default
spec:
  selector:
    app: example-webhook
  ports:
    - port: 80
      targetPort: webhook
      name: webhook
</code></pre>
<p>However when creating a <code>Pod</code> (that does indeed trigger the webhook) I get the following error:</p>
<pre><code>▶ k create -f demo-pod.yaml
Error from server (InternalError): error when creating &quot;demo-pod.yaml&quot;: Internal error occurred: failed calling webhook &quot;example-webhook.default.svc.cluster.local&quot;: Post &quot;https://example-webhook.default.svc:443/mutate?timeout=30s&quot;: no service port 443 found for service &quot;example-webhook&quot;
</code></pre>
<p>Can't I configure the webhook not to be called on <code>443</code> but rather on <code>80</code>? Either way TLS termination is done by the <code>istio</code> sidecar.</p>
<p>Is there a way around this using <code>VirtualService</code> / <code>DestinationRule</code>?</p>
<p><strong>edit</strong>: on top of that, why is it trying to reach the service in the <code>example-webhook.default.svc</code> endpoint? (while it should be doing so in <code>example-webhook.default.svc.cluster.local</code>) ?</p>
<h3>Update 1</h3>
<p>I have tried to use <code>https</code> as follows:</p>
<p>I have created a certificate and private key, using istio's CA.</p>
<p>I can verify that my DNS names in the cert are valid as follows (from another pod)</p>
<pre><code>echo | openssl s_client -showcerts -servername example-webhook.default.svc -connect example-webhook.default.svc:443 2&gt;/dev/null | openssl x509 -inform pem -noout -text
</code></pre>
<pre><code>...
 Subject: C = GR, ST = Attica, L = Athens, O = Engineering, OU = FOO, CN = *.cluster.local, emailAddress = me@myemail.com
...
        X509v3 extensions:
            X509v3 Subject Alternative Name:
                DNS:*.default.svc.cluster.local, DNS:example-webhook, DNS:example-webhook.default.svc
...
</code></pre>
<p>but now pod creation fails as follows:</p>
<pre><code>▶ k create -f demo-pod.yaml
Error from server (InternalError): error when creating &quot;demo-pod.yaml&quot;: Internal error occurred: failed calling webhook &quot;example-webhook.default.svc.cluster.local&quot;: Post &quot;https://example-webhook.default.svc:443/mutate?timeout=30s&quot;: x509: certificate is not valid for any names, but wanted to match example-webhook.default.svc
</code></pre>
<h3>Update 2</h3>
<p>The fact that the certs the webhook pod are running with were appropriately created using the <code>istio</code> CA cert, is also validated.</p>
<pre><code>curl --cacert istio_cert https://example-webhook.default.svc
Test
</code></pre>
<p>where <code>istio_cert</code> is the file containing istio's CA certificate</p>
<p>What is going on?</p>

pkaramol
<p>Did you try adding the <strong>port</strong> attribute in your MutatingWebhookConfiguration</p>
<pre class="lang-yaml prettyprint-override"><code>clientConfig:
      service:
        name: example-webhook
        namespace: default
        path: &quot;/mutate&quot;
        port: 80
</code></pre>
