Skip to main content

Publish a service from a Managed Kubernetes cluster to the Internet

  1. Check quotas.
  2. Connect to the cluster.
  3. Create a GatewayClass.
  4. Create a Gateway.
  5. Create an HTTPRoute.

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

  1. Create a YAML file with a manifest for the GatewayClass object.

    Example of a GatewayClass manifest:

    ---
    apiVersion: gateway.networking.k8s.io/v1
    kind: GatewayClass
    metadata:
    name: envoy-gateway
    spec:
    controllerName: gateway.envoyproxy.io/gatewayclass-controller
  2. 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

  1. Create a YAML file with a manifest for the Gateway object.

    Example of a Gateway manifest:

    ---
    apiVersion: gateway.networking.k8s.io/v1
    kind: Gateway
    metadata:
    name: external-gateway
    spec:
    gatewayClassName: envoy-gateway
    listeners:
    - name: http
    protocol: HTTP
    port: 80
  2. 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

  1. Create a YAML file with a manifest for the HTTPRoute object.

    Example of an HTTPRoute manifest:

    ---
    apiVersion: gateway.networking.k8s.io/v1
    kind: HTTPRoute
    metadata:
    name: test-route
    spec:
    parentRefs:
    - name: external-gateway
    hostnames:
    - "test.com"
    rules:
    - matches:
    - path:
    type: Exact
    value: /testpath
    backendRefs:
    - name: my-app-service
    port: 80

    Where:

    • external-gateway — the name of the Gateway object;
    • my-app-service — the name of the service you are publishing to the Internet.
  2. 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>.