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

Make sure that the pool has an allocated quota for at least one public IP address. To do this, view Cloud Platform quota consumption.

2. Connect to the cluster

To connect to the cluster, use the Connect to a Managed Kubernetes cluster instructions.

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 for creating a 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 for creating a 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 → Load Balancers section → 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 — name of the Gateway object;
    • my-app-service — name of the service that you are exposing to the internet.
  2. Apply the manifest:

    kubectl apply -f <file_name>

    Specify <file_name> — the name of the YAML file with the manifest for creating an HTTPRoute object. For example, <httproute.yaml>.