How to apply a Static IP for Spring SCDF Stream that has a LoadBalancer (in Kubernetes)

11/20/2019

I am deploying a stream with Spring SCDF. This stream also has a LoadBalancer. I activated that with the

spring.cloud.deployer.kubernetes.createLoadBalancer true

stream Deployer property. So this LoadBalancer does work now and gives me an external IP that I can access. However this IP is changing each time I am redeploying the stream.

I am using GCP and there am able to provide a static IP. In Kubernetes I can give an ingress a static IP like so:

annotations:
    kubernetes.io/ingress.global-static-ip-name: "web-static-ip"

I wonder how I can do the same for a deployed stream with Spring SCDF now?

-- xetra11
kubernetes
spring-cloud-dataflow

1 Answer

11/20/2019

In a production deployment setting, you'd want to have an explicit load-balancer (LB) attached to the desired application, so its service can be invoked by other services because there will be a static URL/IP to interact with it. Even if the app is rolling-upgraded or redeployed, you will get a predictable URL/IP.

Here's an example of the LB deployment:

kind: Service
apiVersion: v1
metadata:
  name: FOO-lb
  namespace: kafkazone
spec:
  ports:
  - port: 80
    name: http
    targetPort: 8080
  selector:
    FOOZ: BAR-APP
  type: LoadBalancer

This deployment would produce a URL/IP. Let's say, for example, the IP address of FOO-lb is: 10.20.30.40.

And, when you deploy the stream, you can attach a label selector to the desired application [e.g.: deployer.<yourapp>.kubernetes.deploymentLabels=FOOZ: BAR-APP], so all the incoming traffic to 10.20.30.40 will automatically be received by the source. You will be, of course, relying on the specific IP to post data or interact with it, and it will not change.

-- Sabby Anandan
Source: StackOverflow