<p>I want to expose k8s api's using a service. My issue is that the api only respond on port 6443 on https. Any attempt on http return status 400 bad request. How can I &quot;force&quot; the service to user https ?</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: k8s-api
  namespace: kube-system
  labels:
    label: k8s-api
spec:
  ports:
  - port: 80 #Port on which your service is running
    targetPort: 6443
    protocol: TCP
    name: http
  selector:
    name: kube-apiserver-master-node 
</code></pre>
<p>May be this ?</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: k8s-api
  namespace: kube-system
  labels:
    label: k8s-api
spec:
  ports:
  - port: 443 #Port on which your service is running
    targetPort: 6443
    protocol: TCP
    name: http
  selector:
    name: kube-apiserver-master-node 
</code></pre>

<p>If you are using the Nginx ingress by default it does <strong>SSL</strong> <strong>off load</strong> and sends plain <strong>HTTP</strong> in the background.</p>
<p>Changing port <strong>6443</strong> might be helpful if you request direct connecting to the <strong>service</strong>.</p>
<p>If you are using the Nginx ingress make sure it doesn't terminate SSL.</p>
<pre><code>nginx.ingress.kubernetes.io/backend-protocol: &quot;HTTPS&quot;
nginx.ingress.kubernetes.io/ssl-passthrough: &quot;true&quot;
</code></pre>
