This guide walks you through installing the Gateway API CRDs, deploying Contour using Helm with the Gateway API enabled, creating a GatewayClass
, updating the Contour ConfigMap
, and restarting the Contour deployment.
Prerequisites:
- A Kubernetes cluster.
kubectl
installed and configured to connect to your cluster.- Helm installed.
Steps
Install Gateway API CRDs
kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.2.0/standard-install.yaml
This command applies the necessary Custom Resource Definitions (CRDs) for the Gateway API to your cluster.
Install Contour using Helm
helm upgrade --install contour contour \
--repo https://charts.bitnami.com/bitnami \
--set fullnameOverride=gateway \
--namespace projectcontour --create-namespace \
--set contour.ingressClass.create=true \
--set contour.ingressClass.name=contour \
--set gateway.enabled=true \
--set gateway.installCRDs=true
Explanation of Flags:
helm upgrade --install contour contour
: Installs or upgrades the Contour chart with the release name “contour.”--repo https://charts.bitnami.com/bitnami
: Specifies the Bitnami Helm chart repository.--set fullnameOverride=gateway
: Overrides the default resource naming to use “gateway” as the base name. This is important for consistency.--namespace projectcontour --create-namespace
: Creates theprojectcontour
namespace if it doesn’t exist and installs Contour into it. Best practice is to deploy Contour into its namespace.--set contour.ingressClass.create=true
: Creates an IngressClass resource.--set contour.ingressClass.name=contour
: Sets the name of the IngressClass to “contour”. Important if you are using Ingress objects alongside Gateway API objects.--set gateway.enabled=true
: Enables the Gateway API support in Contour.--set gateway.installCRDs=true
: Installs Gateway CRDs. Might not be necessary as you installed them previously, but including it doesn’t hurt.
Create a GatewayClass
kubectl apply -f - <<EOF
apiVersion: gateway.networking.k8s.io/v1beta1
kind: GatewayClass
metadata:
name: contour
spec:
controllerName: projectcontour.io/gateway-controller
EOF
This creates a GatewayClass
named “contour” that tells Kubernetes to use Contour’s Gateway controller for handling Gateways of this class. The controllerName
is crucial for linking the GatewayClass to the Contour controller.
Update the Contour ConfigMap
kubectl apply -f - <<EOF
apiVersion: v1
kind: ConfigMap
metadata:
name: contour
namespace: projectcontour
data:
contour.yaml: |
gateway:
controllerName: projectcontour.io/gateway-controller
EOF
This step configures Contour to be the controller for the gateway. It’s very important to ensure Contour processes the Gateway API resources. It explicitly sets the controllerName
within Contour’s configuration.
Restart Contour Deployment
kubectl -n projectcontour rollout restart deployment/gateway-contour
This restarts the Contour deployment to apply the configuration changes to the ConfigMap
. This ensures that Contour picks up the new controllerName
setting.
Verification
After completing these steps, you can verify the setup by:
- Checking the Contour logs for any errors.
- Create a
Gateway
resource and observe that Contour picks it up and configures the load balancer accordingly. - Creating an
HTTPRoute
resource to route traffic through the Gateway.