0

I've a shipped app where a URL is hardcoded "upload.mydomain.io:123123/myRoute".

This DNS points to an VM where an NGINX distributes the traffic to services. Now I need to put a highly scalable service in front of the VM, WITHOUT having the possibility to change the hardcoded URL. I've tried so far:

  • Cloud Functions
  • App Engine
  • Cloud Run
  • My own Kubernetes Cluster.

As an DNS Distributer I use Cloudflare, where I also tried to do something with Page Rules.

Functions -> No Domain in EU

Cloud Run -> Only Port 80

App Engine -> Only Port 8080

Kubernetes Ingress -> I can put my Domain on, also with the port as Service port, but then in the URL the port is gone

This is my Kubernetes Manifest:

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  creationTimestamp: null
  labels:
    app: myApp-api
  name: myApp-api
spec:
  replicas: 3
  strategy:
    type: Recreate
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: myApp-api
    spec:
      containers:
      - name: myApp-api
        env:
        - name: NODE_ENV
          value: production
        image: eu.gcr.io/myApp-123/myApp-api:latest
        imagePullPolicy: Always
        ports:
        - containerPort: 21337
      restartPolicy: Always
status: {}


---

apiVersion: v1
kind: Service
metadata:
  labels:
    app: myApp-api-service
  name: myApp-api-service
spec:
  ports:
  - name: myApp-api-port
    port: 21337
    targetPort: 21337
  selector:
    app: myApp-api
  type: LoadBalancer
status:
  loadBalancer: {}

---

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: myApp-api-ingress
spec:
  tls:
  - hosts:
    - upload.myDomain.io
    secretName: tls-secret
  rules:
  - host: upload.myDomain.io
    http:
      paths:
      - path: /*
        backend:
          serviceName: myApp-api-service
          servicePort: myApp-api-port

Is it possible somehow to create this route with some service?

DonKanallie
  • 123
  • 5
  • Can you give some details on how are you putting a Kubernetes cluster in front of your VM? – yyyyahir Sep 02 '19 at 10:21
  • I have a kubernetes Cluster which receives the request (Express.JS backend Pod) and if conditions are true, it pipes the request to the VM. I also edited my Answer to show the cluster configs – DonKanallie Sep 02 '19 at 12:27

1 Answers1

0

You can use ClusterIP services to map external services within the cluster, this way, you'd see your service as a cluster-local address (represented by a Service), which will be relaying requests to your external service.

Alternatively, you can user an specific type of service called ExternalName, that also does the same relaying only using DNS names instead of addresses.

yyyyahir
  • 255
  • 1
  • 6