Contour development locally on macOS using Colima #6078
                  
                    
                      tsaarni
                    
                  
                
                  started this conversation in
                Show and tell
              
            Replies: 0 comments
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm mainly a Linux user but sometimes I develop on mac as well. Since Docker Desktop is commercial software, I would prefer colima instead. If you have not heard of it, Colima is a tool for running container runtimes on mac. By default it uses the free Docker Engine runtime, also known as "Community Edition". I'll include some tips here on how I configured it for local development of Contour itself. I prefer fast feedback cycle (who wouldn't?) so I usually try to avoid container image builds & re-deployment, and sometimes I need to step through the code under debugger.
As a pre-condition, I assume you already have git, golang, vscode (or other IDE) and that you have cloned Contour source code to your machine.
Install following tools
To start colima run
This will launch new Ubuntu VM with Kubernetes in it, k3s to be more precise. The additional arguments will avoid installing the default ingress controller and load balancer, since we intend to run our own.
Next deploy Contour
To test that everything works, deploy echoserver (check the manifest here)
Wait for the pod to come up and make a HTTP request
This will work directly from mac because Colima has set up port forwarding from localhost to the VM. Envoy container uses hostports to bind to ports
80and443. For having real hostname for the virtualhost, I used nip.io.You can (re)build and deploy your own Contour container image, and for certain type of testing it can be better approach. On other cases, I run Contour locally on mac. For that to work, we need Envoy to connect to a process outside the Kubernetes cluster which requires few tricks but it is not that complicated at the end. The required information is found in the lima documentation: "The loopback addresses of the host is 192.168.5.2". So we need to instruct Envoy to connect to
192.168.5.2.First shut down Contour pod by scaling down the instances
Envoy will connect to hostname
contourto receive its configuration. One approach is to change the XDS server address in Envoy bootstrap configuration file, but I've used an alternative way: I "detach" theServicefrom the Contour pod (which is not anymore running) and manually createEndpointsobject that pointscontourto192.168.5.2:You can restart Envoy to have it immediately connect to the new address
Envoy uses TLS to connect to Contour so we need Contour's server certificate and private key, and CA certificate available locally. Run following on Contour source directory to download them from the cluster
Configure vscode debugger for launching
contour serveNow we are ready to run Contour under debugger and enjoy super fast development!
Note that Contour will be able to connect to Kubernetes API server without any additional configuration because Colima has set up Kubernetes admin credentials and server address to
~/.kube/config. The cluster admin is more powerful than the service account that Contour uses when running inside cluster. Be aware of this when testing functionality related to RBAC! It is possible to copy service account with correct privileges from the cluster but for most cases it is not really necessary.Happy hacking!
Beta Was this translation helpful? Give feedback.
All reactions