Cilium BGP Lab

Sure, here is the blog post based on the information provided:

Reaching Kubernetes Apps with Cilium and BGP Peering

In our previous article, we set up a KinD cluster with Cilium and created a BGP peering with our routers. Now, we want to let the outside world reach our Kubernetes apps. We will add more features to our lab environment so it can be close to a real deployment.

Cilium provides two options to reach applications: using the Pod IP address or using a LoadBalance IP assigned to a Service. In this article, we will focus on the latter option and advertise the LoadBalancer IP to our BGP neighbors.

New Features in This Lab

————————-

We have added new features to our lab environment to make it closer to a real deployment. These include:

### CiliumBGPPeeringPolicy

This policy allows us to advertise the LoadBalancer IP to our BGP neighbors. We will apply this policy to our KinD cluster so that the outside world can reach our Kubernetes apps using the LoadBalancer IP.

### CiliumLoadBalancerIPPool

This feature allows us to assign a unique IP address to each LoadBalancer service. We will use this feature to assign an IP address to our BookInfo application, which we will deploy later in this article.

Building the Environment

————————-

To build the environment, run the following command:

“`make

make

“`

This will create a KinD cluster with 4 nodes (1 control-plane and 3 workers), a containerlab topology with 3 routers (FRR), and 1 client (Alpine). You can decide to let Cilium install manually or with `make cilium`. In this case, we will use the manual installation method.

Applying the CiliumBGPPeeringPolicy and CiliumLoadBalancerIPPool

————————————————————–

To apply the CiliumBGPPeeringPolicy and CiliumLoadBalancerIPPool, you can do it with `make` or the official way with `kubectl`. Here is an example of how to do it with `make`:

“`

make cilium-bgp-peering-policy

make cilium-loadbalancer-ip-pool

“`

You can validate the configurations with the following commands:

“`

kubectl get bgp-peering-policy

kubectl get loadbalancer-ip-pool

“`

Deploying the BookInfo Application

———————————-

Now that our environment is ready, we can deploy the BookInfo application. We will use the `kustomize` command to create a Service and assign an IP address from our IP Pool. Here is an example of how to do it:

“`

kustomize build bookinfo | kubectl apply -f –

“`

This will create a Service named `bookinfo` with an IP address assigned from our IP Pool. We can validate that the Service has been created by running the following command:

“`

kubectl get svc

“`

Assigning IP Addresses to LoadBalancer Services

———————————————

To assign IP addresses to LoadBalancer services, we will use the `kubectl` command with the following command:

“`

kubectl create service –type=LoadBalancer –ip-address=

“`

For example, to assign an IP address to the `bookinfo` Service, we can run the following command:

“`

kubectl create service bookinfo –type=LoadBalancer –ip-address=10.0.10.1

“`

This will assign the IP address `10.0.10.1` to the `bookinfo` Service. We can validate that the Service has been updated by running the following command:

“`

kubectl get svc

“`

Reaching Our App with Lynx

——————————

Now that we have assigned an IP address to our LoadBalancer Service, we can reach our app using a console browser like Lynx. To install Lynx on our Alpine client, run the following command:

“`

apk add lynx

“`

Once installed, we can start Lynx and navigate to the IP address of our LoadBalancer Service:

“`

lynx http://10.0.10.1

“`

This will open the BookInfo application in our console browser. We can interact with the application using the Lynx commands.

Conclusion

———-

In this article, we have added more features to our lab environment so that it can be close to a real deployment. We have applied the CiliumBGPPeeringPolicy and CiliumLoadBalancerIPPool to our KinD cluster and deployed the BookInfo application using a LoadBalancer Service. We have also assigned an IP address to our LoadBalancer Service and reached our app using Lynx. These features will help us build a more complete lab environment for testing Cilium features.

We hope this article has provided you with useful information on building a more complete lab environment for testing Cilium features. Please feel free to reach out if you have any questions or need further assistance.