<p>I need some help from the community, I'm pretty new to kubernetes.</p>
<p>I need the URL of my host defined in the &quot;deployment.yaml&quot; file to redirect from http to https using whatever technique. Next I am going to leave the infrastructure as the code I have.</p>
<p><strong>Deployment.yaml:</strong></p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: web
  namespace: default
spec:
  selector:
    matchLabels:
      run: web
  template:
    metadata:
      labels:
        run: web
    spec:
      containers:
      - image: gcr.io/google-samples/hello-app:1.0
        imagePullPolicy: Always
        name: web
        ports:
        - containerPort: 8080
          protocol: TCP
</code></pre>
<p><strong>service.yaml:</strong></p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: web
  namespace: default
spec:
  ports:
  - port: 8080
    protocol: TCP
    targetPort: 8080
    name: web
  selector:
    run: web
  type: NodePort
</code></pre>
<p>I have also created an ssl certificate for https obviously. For this I have created a certificate managed by google with the file &quot;<strong>managedcertificate.yaml</strong>&quot;:</p>
<pre><code>apiVersion: networking.gke.io/v1beta2
kind: ManagedCertificate
metadata:
  name: certificate-test   
spec:
  domains:
    - test.host.com       
</code></pre>
<p>Finally, I have created a static ip to assign it later in the ingress.
Command: &quot;gcloud compute addresses create ip-test --global&quot;</p>
<p><strong>ingress.yaml:</strong></p>
<pre><code>apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: basic-ingress
  annotations:
    kubernetes.io/ingress.global-static-ip-name: ip-test        
    networking.gke.io/managed-certificates: certificate-test   
spec:
  rules:
  - host: test.host.com       
    http:
      paths:
      - backend:
          serviceName: web
          servicePort: 8080
</code></pre>
<p>That's it. The service works for the url &quot;http://test.host.com&quot; and &quot;https://test.host.com&quot;, but what I want is that when I go to port 80 (that is to &quot;http: //test.host.com &quot;) automatically redirects me to 443 (with https).</p>
<p>I have tried to put the following configuration in the ingress: 'ingress.kubernetes.io/force-ssl-redirect:&quot; true &quot;', but it still doesn't work.</p>
<p>I hope someone who understands something more than me can help me please.
Thanks in advance to the community, greetings.</p>

mduque
<p>Unfortunately GKE Ingress implementation does not support HTTP to HTTPS redirection yet, although the feature is being implemented and should be available soon. See <a href="https://github.com/kubernetes/ingress-gce/issues/1075" rel="nofollow noreferrer">ingress-gce #1075</a>.</p>
<p>For now you have the following options:</p>
<ul>
<li>replacing GKE native Ingress with the <a href="https://kubernetes.github.io/ingress-nginx/deploy/#gce-gke" rel="nofollow noreferrer">ingress-nginx</a></li>
<li>implementing redirection yourself. See an example <a href="https://github.com/kubernetes/ingress-gce/issues/51#issuecomment-544544210" rel="nofollow noreferrer">here</a>.</li>
</ul>
