|
| 1 | +# kind-with-istio-ambient |
| 2 | + |
| 3 | +This example shows how a KIND (Kubernetes-in-Docker) Cluster, configured with Istio in Ambient Mode, can be created with easy steps. |
| 4 | + |
| 5 | +The configuration of the Gateway API Controller is perfomed with the `docker` Provider, following [this guide](https://kubernetes.io/blog/2026/01/28/experimenting-gateway-api-with-kind/). |
| 6 | + |
| 7 | +Additionally, the example will deploy a Workload example taken directly from the [Istio Repository](https://github.com/istio/istio), |
| 8 | + |
| 9 | +The Gateway API Controller will map the port 80 and expose the Service through it. If you want to use the HTTPS port, you need to customise the `example.yaml` file and also register a valid key pair to be used for the TLS communication. |
| 10 | + |
| 11 | +## Requirements |
| 12 | + |
| 13 | +The following tools are required for this project: |
| 14 | + |
| 15 | +* `docker` (up and running) |
| 16 | +* `terraform` (1.6+) / `opentofu` (1.6+) |
| 17 | +* `helm` (3.0+) |
| 18 | +* `kind` (0.30.0+) |
| 19 | + |
| 20 | +## How to run the example |
| 21 | + |
| 22 | +In a Terminal, type the following commands to initialize the Terraform/OpenTofu Workspace and create the cluster: |
| 23 | + |
| 24 | +```sh |
| 25 | +export TF_BIN=tofu # change to `terraform` if you want to use Terraform instead of OpenTofu |
| 26 | +$TF_BIN init |
| 27 | +$TF_BIN plan |
| 28 | +$TF_BIN apply |
| 29 | +# Apply again to overcome a bug with the Kubernetes Provider while applying the Manifest for Gateway |
| 30 | +$TF_BIN apply |
| 31 | +``` |
| 32 | + |
| 33 | +After the completion of the above described commands, if no error has been returned, you should see that 2 Containers are running: |
| 34 | + |
| 35 | +* the Kubernetes Control Plane |
| 36 | +* two Worker Nodes |
| 37 | + |
| 38 | +Additionally, a new file, `kubeconfig`, will be placed in this folder, giving you the possibility to authenticate yourself against the cluster and inspect it with your favorite tool (e.g. k9s, headlamp, Lens). |
| 39 | + |
| 40 | +You can now access the example Service at the following address: |
| 41 | + |
| 42 | +`http://localhost/hello` |
| 43 | + |
| 44 | +e.g. with `cURL`: |
| 45 | + |
| 46 | +```sh |
| 47 | +GW_ADDR=$(kubectl get gateway -n istio-ingress gateway -o jsonpath='{.status.addresses[0].value}') |
| 48 | +curl --resolve helloworld.example.com:80:$GW_ADDR http://helloworld.example.com/hello |
| 49 | +``` |
| 50 | + |
| 51 | +You should see the message: |
| 52 | + |
| 53 | +`Hello version: v2, instance: helloworld-v2-<unique-id>` |
| 54 | + |
| 55 | +At this point you can also use the `istioctl` command line tool to verify that the cluster is working with Istio successfully. |
| 56 | + |
| 57 | +## How to destroy the cluster |
| 58 | + |
| 59 | +In a Terminal, you can simply run: |
| 60 | + |
| 61 | +```sh |
| 62 | +export TF_BIN=tofu # change to `terraform` if you want to use Terraform instead of OpenTofu |
| 63 | +$TF_BIN destroy |
| 64 | +``` |
| 65 | + |
| 66 | +and all the resources will be deleted. |
| 67 | +<!-- BEGIN_TF_DOCS --> |
| 68 | +## Requirements |
| 69 | + |
| 70 | +| Name | Version | |
| 71 | +|------|---------| |
| 72 | +| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.8.0 | |
| 73 | +| <a name="requirement_docker"></a> [docker](#requirement\_docker) | 3.9.0 | |
| 74 | +| <a name="requirement_helm"></a> [helm](#requirement\_helm) | 3.1.1 | |
| 75 | +| <a name="requirement_kind"></a> [kind](#requirement\_kind) | 0.11.0 | |
| 76 | +| <a name="requirement_kubernetes"></a> [kubernetes](#requirement\_kubernetes) | 3.0.1 | |
| 77 | +| <a name="requirement_null"></a> [null](#requirement\_null) | 3.2.4 | |
| 78 | + |
| 79 | +## Modules |
| 80 | + |
| 81 | +| Name | Source | Version | |
| 82 | +|------|--------|---------| |
| 83 | +| <a name="module_istio"></a> [istio](#module\_istio) | ../../modules/istio-mesh | n/a | |
| 84 | +| <a name="module_kind"></a> [kind](#module\_kind) | ../../modules/kind-cluster | n/a | |
| 85 | + |
| 86 | +## Resources |
| 87 | + |
| 88 | +| Name | Type | |
| 89 | +|------|------| |
| 90 | +| [docker_container.cloud_controller_manager](https://registry.terraform.io/providers/kreuzwerker/docker/3.9.0/docs/resources/container) | resource | |
| 91 | +| [docker_image.cloud_controller_manager](https://registry.terraform.io/providers/kreuzwerker/docker/3.9.0/docs/resources/image) | resource | |
| 92 | +| [kubernetes_manifest.gateway](https://registry.terraform.io/providers/hashicorp/kubernetes/3.0.1/docs/resources/manifest) | resource | |
| 93 | +| [kubernetes_namespace_v1.ingress](https://registry.terraform.io/providers/hashicorp/kubernetes/3.0.1/docs/resources/namespace_v1) | resource | |
| 94 | +| [kubernetes_namespace_v1.workshop](https://registry.terraform.io/providers/hashicorp/kubernetes/3.0.1/docs/resources/namespace_v1) | resource | |
| 95 | +| [null_resource.install_example](https://registry.terraform.io/providers/hashicorp/null/3.2.4/docs/resources/resource) | resource | |
| 96 | + |
| 97 | +## Inputs |
| 98 | + |
| 99 | +| Name | Description | Type | Default | Required | |
| 100 | +|------|-------------|------|---------|:--------:| |
| 101 | +| <a name="input_port_configuration"></a> [port\_configuration](#input\_port\_configuration) | Defines the port mappings for the cluster nodes | <pre>map(object({<br/> app_protocol = string<br/> node_port = number<br/> host_port = number<br/> target_port = number<br/> protocol = string<br/> }))</pre> | <pre>{<br/> "http": {<br/> "app_protocol": "http",<br/> "host_port": 80,<br/> "node_port": 30000,<br/> "protocol": "TCP",<br/> "target_port": 80<br/> },<br/> "https": {<br/> "app_protocol": "https",<br/> "host_port": 443,<br/> "node_port": 30001,<br/> "protocol": "TCP",<br/> "target_port": 443<br/> },<br/> "status-port": {<br/> "app_protocol": "http",<br/> "host_port": 15021,<br/> "node_port": 30002,<br/> "protocol": "TCP",<br/> "target_port": 15021<br/> }<br/>}</pre> | no | |
| 102 | + |
| 103 | +## Outputs |
| 104 | + |
| 105 | +No outputs. |
| 106 | +<!-- END_TF_DOCS --> |
0 commit comments