1

I am currently setting up an environment to deploy an application on google cloud platform using kubernetes.

I tried setting up an Ingress to connect to my NodePort services with the following yaml config:

apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: my-ingress
  annotations:
    ingress.gcp.kubernetes.io/pre-shared-cert: "my-certificate"
spec:
  rules:
  - host: example.com
    http:
      paths:
      - path: /*
        backend:
          serviceName: website
          servicePort: 80
      - path: /api/*
        backend:
          serviceName: api
          servicePort: 80

So example.com and all routes go to my website service, and all requests to example.com/api/ go to my API app.

Only thing is I want all requests to be rewritten to my app as /<endpoint> instead of /api/<endpoint>. Just a few days back gcp added the ability to specify additional redirect and rewrite rules for load balancers, but it isn't available to be configured in YAML yet (as seen here: https://github.com/kubernetes/ingress-gce/issues/109).

Now I went to go manually configure the host rewrite through the cloud console. Once I save, the settings appear to get reverted back within about 10 minutes and I can't figure out why.

I also want to set up a http to https redirect rule, but I can't create these either because they seem to get reverted as well.

Could anybody explain why this is?

I'm not sure if it matters but I used kubectl apply -f my-ingress.yaml to create the ingress

1
  • Maybe the k8s cloud-controller is wrestling back control of the config? Ultimately when you are declaring the ingress controller you are instructing the cloud controller to go and configure GCP LB. I could be wrong, but maybe periodically it looks for deviation from its config and reapplied it? – Alex Moore Apr 25 '20 at 9:08
0

What @Alex Moore said - because the GCP LB is a K8s object it controls its configuration.

If you want to use features that cannot be configured inside K8s you should create the LB outside of K8s, create a nodePort service and point the GCP LB to the nodes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.