Using Existing ULB
UK8S supports specifying an existing ULB instance when creating a Service of type LoadBalancer, instead of creating a new ULB instance.
It also supports multiple Services reusing a single ULB instance, but the following rule restrictions exist:
-
The existing ULB instance must be the ULB instance you created yourself, not the one created by the UK8S plugin, otherwise it will lead to accidental deletion of the ULB (when the Service inside UK8S is deleted, the ULB will also be deleted synchronously).
-
When multiple Services reuse a ULB instance, the Service ports cannot conflict, otherwise the new service cannot be created successfully.
-
When an existing ULB instance is used to create a LoadBalancer Service, the ULB instance will not be deleted after the Service is deleted, only the corresponding Vserver will be deleted.
-
The naming convention for the Vserver created through UK8S is
Protocol-ServicePort-ServiceUUID
. Do not modify it arbitrarily, otherwise it may lead to dirty data.
Let’s see how to use existing ULB instances.
Using Existing ALB
⚠️ Using ALB requires CloudProvider version >= 24.03.13.
apiVersion: v1
kind: Service
metadata:
name: https
labels:
app: https
annotations:
"service.beta.kubernetes.io/ucloud-load-balancer-id": "alb-rpfirtgx4l4" # Replace with your own alb id
# Declare the use of alb
"service.beta.kubernetes.io/ucloud-load-balancer-listentype": "application"
# Declare the use of http protocol
"service.beta.kubernetes.io/ucloud-load-balancer-vserver-protocol": "http"
spec:
type: LoadBalancer
ports:
- protocol: TCP
port: 443
targetPort: 8080
name: https
- protocol: TCP
name: http
port: 80
targetPort: 8080
selector:
app: https
Using Existing Internal ULB
To declare the use of an existing internal ULB, at least two annotations need to be declared.
apiVersion: v1
kind: Service
metadata:
name: https
labels:
app: https
annotations:
service.beta.kubernetes.io/ucloud-load-balancer-id: "ulb-ofvmd1o4" #Replace with your own ULB Id
service.beta.kubernetes.io/ucloud-load-balancer-type: "inner"
spec:
type: LoadBalancer
ports:
- protocol: TCP
port: 443
targetPort: 8080
selector:
app: https
Using Existing External ULB (7 Layer)
apiVersion: v1
kind: Service
metadata:
name: https
labels:
app: https
annotations:
service.beta.kubernetes.io/ucloud-load-balancer-id: "ulb-ofvmd1o4"
service.beta.kubernetes.io/ucloud-load-balancer-vserver-protocol: "https"
# http and https are equivalent, both indicate that 7 layer load balancing is being used.
service.beta.kubernetes.io/ucloud-load-balancer-vserver-ssl-cert: "ssl-b103etqy"
service.beta.kubernetes.io/ucloud-load-balancer-vserver-ssl-port: "443"
# SSL is enabled for port 443, while port 80 remains HTTP
spec:
type: LoadBalancer
ports:
- protocol: TCP
port: 443
targetPort: 8080
- protocol: TCP
port: 80
targetPort: 8080
selector:
app: https
Using Existing External ULB (4 Layer)
apiVersion: v1
kind: Service
metadata:
name: https
labels:
app: https
annotations:
service.beta.kubernetes.io/ucloud-load-balancer-id: "ulb-ofvmd1o4"
service.beta.kubernetes.io/ucloud-load-balancer-vserver-protocol: "tcp"
# Indicates the use of 4-layer load balancing
spec:
type: LoadBalancer
ports:
- protocol: TCP
port: 443
targetPort: 8080
- protocol: TCP
port: 80
targetPort: 8080
selector:
app: tcp