|
| 1 | +--- |
| 2 | +title: Securing Cilium Gateway API |
| 3 | +description: 'cert-manager tutorials: Using Cilium Gateway API to solve Automatic Certificate Management Environment (ACME) challenges' |
| 4 | +--- |
| 5 | + |
| 6 | +This tutorial will specify how to automate ingress traffic encryption to your Kubernetes cluster with `Kubernetes Gateway API`, `Cilium` and `cert-manager`. |
| 7 | + |
| 8 | +## Steps |
| 9 | + |
| 10 | +* [Step 1 - Install Helm](#step-1---install-helm) |
| 11 | +* [Step 2 - Deploy Kubernetes Gateway API](#step-2---deploy-kubernetes-gateway-api) |
| 12 | +* [Step 3 - Deploy Cilium](#step-3---deploy-cilium) |
| 13 | +* [Step 4 - Deploy cert-manager and Configure an Issuer](#step-4---deploy-cert-manager-and-configure-an-issuer) |
| 14 | +* [Step 5 - Configure a Gateway and HTTPRoute](#step-5---configure-a-gateway-and-httproute) |
| 15 | + |
| 16 | +## Step 1 - Install Helm |
| 17 | + |
| 18 | +> *Skip this step if you have helm already installed on your client.* |
| 19 | +
|
| 20 | +The easiest way to install and manage `cert-manager` and `Cilium` is to use [`Helm`](https://helm.sh), a templating and deployment tool for Kubernetes resources. |
| 21 | + |
| 22 | +First, ensure the Helm client is installed on your client by following the [Helm installation instructions](https://helm.sh/docs/intro/install/). |
| 23 | + |
| 24 | +For example, on MacOS: |
| 25 | + |
| 26 | +```shell |
| 27 | +$ brew install helm |
| 28 | +``` |
| 29 | + |
| 30 | +For a detailed description read the documentation provided at: https://helm.sh/docs/intro/install/ |
| 31 | + |
| 32 | +## Step 2 - Deploy Kubernetes Gateway API |
| 33 | + |
| 34 | +> *In this tutorial we are focusing on Cilium version `1.17.5`, which supports Gateway API version `1.2.0`.* |
| 35 | +
|
| 36 | +Install the Gateway API Custom Resource Definitions (CRDs): |
| 37 | + |
| 38 | +```shell |
| 39 | +$ kubectl apply -f https://raw.githubusercontent.com/kubernetes-sigs/gateway-api/v1.2.0/config/crd/standard/gateway.networking.k8s.io_gatewayclasses.yaml |
| 40 | +$ kubectl apply -f https://raw.githubusercontent.com/kubernetes-sigs/gateway-api/v1.2.0/config/crd/standard/gateway.networking.k8s.io_gateways.yaml |
| 41 | +$ kubectl apply -f https://raw.githubusercontent.com/kubernetes-sigs/gateway-api/v1.2.0/config/crd/standard/gateway.networking.k8s.io_httproutes.yaml |
| 42 | +$ kubectl apply -f https://raw.githubusercontent.com/kubernetes-sigs/gateway-api/v1.2.0/config/crd/standard/gateway.networking.k8s.io_referencegrants.yaml |
| 43 | +$ kubectl apply -f https://raw.githubusercontent.com/kubernetes-sigs/gateway-api/v1.2.0/config/crd/standard/gateway.networking.k8s.io_grpcroutes.yaml |
| 44 | +``` |
| 45 | + |
| 46 | +Optionally the *experimental* TLSRoute CRD: |
| 47 | + |
| 48 | +```shell |
| 49 | +$ kubectl apply -f https://raw.githubusercontent.com/kubernetes-sigs/gateway-api/v1.2.0/config/crd/experimental/gateway.networking.k8s.io_tlsroutes.yaml |
| 50 | +``` |
| 51 | + |
| 52 | +This is also described in the [cilium docs](https://docs.cilium.io/en/stable/network/servicemesh/gateway-api/gateway-api/#prerequisites). |
| 53 | + |
| 54 | +## Step 3 - Deploy Cilium |
| 55 | + |
| 56 | +Install the cilium cli either via your package manager or GitHub releases. For example: |
| 57 | + |
| 58 | +```shell |
| 59 | + $ brew install cilium-cli |
| 60 | +``` |
| 61 | + |
| 62 | +Install cilium on a newly deployed Kubernetes cluster with the Gateway API integration enabled: |
| 63 | + |
| 64 | +```shell |
| 65 | +$ cilium install \ |
| 66 | + --set kubeProxyReplacement=true \ |
| 67 | + --set gatewayAPI.enabled=true |
| 68 | + |
| 69 | +$ cilium status --wait |
| 70 | +``` |
| 71 | + |
| 72 | +There is a detailed description in the [cilium docs](https://docs.cilium.io/en/stable/gettingstarted/k8s-install-default/). |
| 73 | + |
| 74 | +## Step 4 - Deploy cert-manager and Configure an Issuer |
| 75 | + |
| 76 | +Install the Helm repository: |
| 77 | + |
| 78 | +```shell |
| 79 | +$ helm repo add jetstack https://charts.jetstack.io --force-update |
| 80 | +``` |
| 81 | + |
| 82 | +Install cert-manager: |
| 83 | + |
| 84 | +```shell |
| 85 | +$ helm install \ |
| 86 | + cert-manager jetstack/cert-manager \ |
| 87 | + --namespace cert-manager \ |
| 88 | + --create-namespace \ |
| 89 | + --set crds.enabled=true |
| 90 | +``` |
| 91 | + |
| 92 | +There is also a detailed installation documentation with [Helm](/docs/installation/helm/). |
| 93 | + |
| 94 | +Defining a letsencrypt ACME HTTP01 cluster issuer: |
| 95 | + |
| 96 | +`custerissuer-letsencrypt.yaml` |
| 97 | +```yaml |
| 98 | +apiVersion: cert-manager.io/v1 |
| 99 | +kind: ClusterIssuer |
| 100 | +metadata: |
| 101 | + name: letsencrypt |
| 102 | +spec: |
| 103 | + acme: |
| 104 | + |
| 105 | + privateKeySecretRef: |
| 106 | + name: letsencrypt-clusterissuer |
| 107 | + server: https://acme-v02.api.letsencrypt.org/directory |
| 108 | + solvers: |
| 109 | + - http01: |
| 110 | + ingress: {} |
| 111 | +``` |
| 112 | +
|
| 113 | +Apply it to the cluster: |
| 114 | +```shell |
| 115 | +$ kubectl apply -f clusterissuer-letsencrypt.yaml |
| 116 | +``` |
| 117 | + |
| 118 | +## Step 5 - Configure a Gateway and HTTPRoute |
| 119 | + |
0 commit comments