Contour Ingress on Minikube Kubernetes Cluster

BalaSubramani K
KUBELANCER PRIVATE LIMITED
4 min readFeb 24, 2024

​​Contour is an modern ingress controller for Kubernetes.Contour works by deploying the Envoy proxy as a reverse proxy and load balancer.

Good feature on Contour is , it supports multiple configuration APIs as meet our business need.

  • Ingress — A stable upstream API that enables basic ingress use cases.
  • HTTPProxy — Contour’s Custom Resource Definition (CRD) which expands upon the functionality of the Ingress API to allow for a richer user experience as well as solve shortcomings in the original design.
  • Gateway API (beta) — A new CRD-based API managed by the Kubernetes SIG-Network community that aims to evolve Kubernetes service networking APIs in a vendor-neutral way.Let us see a simple demo, how Contour exposing Application service to Internet User access.

Pre-Requisite:

To setup local development environment

  1. Colima — container runtimes on macOS (and Linux)
  2. Minikube — minikube is local Kubernetes

Then, install

3. Contour Ingress Controller, Sample Deployment workload, HTTPproxy

Install colima

Ref: https://blog.kubelancer.com/install-colima-on-mac-os/

Install on Mac

$ brew install colima

Start colima

$ colima start

Verify

$ colima status

Install Minikube on MacOS

To run Minikube, need a Hypervisor , here we are using Docker, which is providing by Colima runtime.

Run the below commands to download binary

$ curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-darwin-amd64

Run below command to get Install

$ sudo install minikube-darwin-amd64 /usr/local/bin/minikube

Start Minikube

$ minikube start

Verify

$ minikube status

Let’s start install Contour Ingress Controller on minikube cluster (local Kubernetes cluster)

Complete Code on

https://github.com/kubelancer/kubelancer-lab-minikube-ingress-contour.git

Clone the Git Repo and get start.

$ git clone https://github.com/kubelancer/kubelancer-lab-minikube-ingress-contour.git

Install Contour and Envoy

$ cd kubelancer-lab-minikube-ingress-contour
$ kubectl apply -f contour.yaml

Verify Deployment, DaemonSet, pods, services in projectcontour namespace

$ kubectl get deployments,pods,service,daemonset -n projectcontour

Run minikube tunnel command get Connect to LoadBalancer services of service/envoy LoadBalancer.

💡 (Run this command in separate Terminal/Console and keep it open. Don’t terminate that window.)

$ minikube tunnel

Now verify, LoadBalancer IP address should get allotted by minikube

$ kubectl get svc -n projectcontour

Let now Deploy sample Application, Which creates

  1. namespace: dev
  2. deployment: kubeapp using container image docker.io/kubelaancer/kubewebapp:v1.0.0
  3. service: kubeapp
$ kubectl apply -f deployment.yaml

Verify Application and Service

$ kubectl get all -n dev

Let us expose this application to internet world, localhost is using as DNS name as this is local environment.

Creating an HTTPProxy

Note: Also we can use ingress, in this demo we are using HTTPProxy which provide rich user experience on multi-tenant environments.

Before apply, let view the yaml configuration spec

bala@kubelancer demo-2 % cat contour-httpproxy.yaml
apiVersion: projectcontour.io/v1 # API version
kind: HTTPProxy # Type of resource, here HTTPProxy
metadata:
name: kubeapp-proxy # proxy name
namespace: dev # deploying proxy on dev namesapce
spec:
virtualhost: # Expose to Host, in this case localhost, use DNS for your business
fqdn:
"localhost"
routes:
- conditions: # URL routing PATH, here root path
- prefix: /
services:
- name: kubeapp # mapped kubeapp service
port: 80 # kubeapp service port number
bala@kubelancer demo-2 %

Apply HTTPProxy

$ kubectl apply -f contour-httpproxy.yaml

List and Verify HTTPProxies

$ kubectl get httpproxy -n dev

Validate the App:

To view kubeapp Application: Open browser and type http://localhost/

* Happy Computing *

Originally Posted on

Devops and Cloud Compute Engineering stacks

https://blog.kubelancer.com/

--

--

BalaSubramani K
KUBELANCER PRIVATE LIMITED

Senior Cloud and DevOps Infrastructure Engineer | Multi-Cloud Solution Architect | Consultant | Containerization | Cloud Native | Mobile | Serverless