Hello there,
I’m trying to share one loadbalancer (client-service) between two deployments(client-api and client-web). After apply the configuration, the two services works perfectly. However, after some minutes, the loadbalancer stop working, causing the service unavailabilty.
In order to restart the loadbalancer, I have to press F5 for while and the service start working.
Could someone help me?f you guys need more information, please, let me know.
kind: Service
apiVersion: v1
metadata:
name: client-service
spec:
type: LoadBalancer
selector:
app: client-app
ports:
- name: client-api
protocol: TCP
port: 3101
targetPort: 3101
- name: client-web
protocol: TCP
port: 8888
targetPort: 80
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: client-api
spec:
replicas: 1
selector:
matchLabels:
app: client-app
revisionHistoryLimit: 2
template:
metadata:
labels:
app: client-app
spec:
containers:
- name: client-api
image: <DOCKER_IMAGE>
imagePullPolicy: Always
ports:
- containerPort: 3101
protocol: TCP
imagePullSecrets:
- name: <DOCKER_SECRETS>
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: client-web
spec:
replicas: 1
selector:
matchLabels:
app: client-app
template:
metadata:
labels:
app: client-app
spec:
containers:
- name: client-web
image: <DOCKER_IMAGE>
imagePullPolicy: Always
ports:
- containerPort: 8888
protocol: TCP
imagePullSecrets:
- name: <DOCKER_SECRETS>
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
The proper way to share an LB between two services is to use an ingress controller along with ingress objects to specify routing rules.
You can find an example in our community tutorials for how to accomplish this (you may not need to cert-manager part):
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.