Contour Ingress on Minikube Kubernetes Cluster
Setting up Contour ingress on Local Kubernetes using Minikube
Contour is a modern ingress controller for Kubernetes. Contour works by deploying the Envoy proxy as a reverse proxy and load balancer.
A good feature of Contour… it supports multiple configuration APIs to meet our business needs.
- Ingress - A stable upstream API that enables basic ingress use cases.
2. HTTP Proxy - 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.
3. 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, of how Contour exposing the Application service to Internet User access.
Pre-Requisite:
To setup our local development environment
- Colima — container runtimes on macOS (and Linux)
- Minikube — local Kubernetes
Then, install
3. Contour Ingress Controller, Sample Deployment workload, HTTP proxy
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 started.
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, Daemon Set, pods, and services in the project contour namespace
$ kubectl get deployments,pods,service,daemonset -n projectcontour
Run minikube tunnel command to get Connect to LoadBalancer services of service/envoy LoadBalancer.
Note: (Run this command in a 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 a sample Application, which creates
- namespace: dev
2. deployment: kubeapp using container image docker.io/kubelancer/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, localhost is used as DNS name as this is a local environment.
Creating an HTTP proxy
Note: Also, we can use ingress, in this demo we are using HTTP Proxy which provide a rich user experience in multi-tenant environments.
Before applying, 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 HTTP Proxy
$ kubectl apply -f contour-httpproxy.yaml
List and Verify HTTP proxies
$ kubectl get httpproxy -n dev
End Result:
To view Kubeapp application:
Open the browser and type http://localhost/