Ingress controller

Set up the Ingress controller #

Features of the Ingress controller #

VNETWORK provides an out-of-the-box ingress controller. Once you apply an ingress manifest, the controller creates a Load Balancer automatically. A load balancer is created for every single ingress object. A load balancer will serve as an entry point for all incoming traffic and then deliver it to pods based on rules specified in services and ingress objects.

So, if you have an application running in a Kubernetes cluster, you first need to provide access to its pods by creating a service and then provide access from the Internet by creating an ingress object.

Create a service #

1. Create a YAML file in any text or code editor:

apiVersion: v1
kind: Service
metadata:
  name: service-grafana
spec:
  ports:
  - port: 80
    protocol: TCP
    targetPort: 3000
  selector:
    app: grafana

Enter your custom values instead:

  • service-grafana—service name
  • 80—service port
  • TCP—protocol which pods listen on
  • 3000—pod port
  • grafana—application name

2. Run the kubectl command from the file directory:

kubectl apply -f <name of the created YAML-file>

You’ll get the output:

service/<service name> created

Congratulations! You’ve created a service of the default ClusterIP type. For more information about other types of Kubernetes services, refer to the official Kubernetes documentation.

Use the VNETWORK ingress controller #

A VNETWORK ingress controller is pre-installed by default, so you only need to create an ingress object.

1. Create a YAML file in any text or code editor:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: hello-world
spec:
rules:
  - http:
    paths:
    - path: /about
      backend:
        serviceName: hello-world-about
        servicePort: 80
    - path: /login
      backend:
        serviceName: hello-world-login
        servicePort: 80

Enter your custom values instead:

  • hello-world—the name of the ingress object
  • /about—URL path
  • hello-world-about—the name of the service that will manage “/about” requests
  • 80—the port of the service that will manage “/login” requests
  • /login—URL path
  • hello-world-login—the name of the service that will manage “/login” requests
  • 80—the port of the service that will manage “/login” requests

2. Run the kubectl command from the file directory:

kubectl apply -f <name of the created YAML-file>

You’ll get the output:

Ingress/<name of the created ingress object> created

Congratulations! You’ve created and applied an ingress object for the VNETWORK ingress controller. Now it will automatically create a VNETWORK load balancer on your behalf. It will be shown in your Control panel in the Load Balancers section.

View an ingress IP address #

If you want to see an IP address of the load balancer through which the traffic comes, view it in the Control panel or run the command:

kubectl get ingress <ingress name>

You’ll get the output:

output

The IP address is written in the ADDRESS column.