Publish a service from a Managed Kubernetes cluster to the Internet
1. Check quotas
Ensure that the pool has a quota for at least one public IP address. To do this, view your cloud platform quota consumption.
2. Connect to the cluster
To connect to the cluster, follow the instructions in Connect to a Managed Kubernetes cluster.
3. Create a GatewayClass
-
Create a YAML file with a manifest for the GatewayClass object.
Example of a GatewayClass manifest:
---apiVersion: gateway.networking.k8s.io/v1kind: GatewayClassmetadata:name: envoy-gatewayspec:controllerName: gateway.envoyproxy.io/gatewayclass-controller -
Apply the manifest:
kubectl apply -f <file_name>Specify
<file_name>— the name of the YAML file with the manifest to create the GatewayClass object. For example,<gatewayclass.yaml>.
4. Create a Gateway
-
Create a YAML file with a manifest for the Gateway object.
Example of a Gateway manifest:
---apiVersion: gateway.networking.k8s.io/v1kind: Gatewaymetadata:name: external-gatewayspec:gatewayClassName: envoy-gatewaylisteners:- name: httpprotocol: HTTPport: 80 -
Apply the manifest:
kubectl apply -f <file_name>Specify
<file_name>— the name of the YAML file with the manifest to create the Gateway object. For example,<gateway.yaml>.
The created load balancer will appear in the Control Panel: in the top menu, click Products and select Cloud Servers → section Load Balancers → tab Load Balancers.
5. Create an HTTPRoute
-
Create a YAML file with a manifest for the HTTPRoute object.
Example of an HTTPRoute manifest:
---apiVersion: gateway.networking.k8s.io/v1kind: HTTPRoutemetadata:name: test-routespec:parentRefs:- name: external-gatewayhostnames:- "test.com"rules:- matches:- path:type: Exactvalue: /testpathbackendRefs:- name: my-app-serviceport: 80Where:
external-gateway— the name of the Gateway object;my-app-service— the name of the service you are publishing to the Internet.
-
Apply the manifest:
kubectl apply -f <file_name>Specify
<file_name>— the name of the YAML file with the manifest to create the HTTPRoute object. For example,<httproute.yaml>.