Skip to content

Commit

Permalink
New layout (#5)
Browse files Browse the repository at this point in the history
Created Modules and examples
  • Loading branch information
madduci authored Dec 14, 2024
1 parent 7b4d1cc commit e2f3d8d
Show file tree
Hide file tree
Showing 43 changed files with 1,244 additions and 366 deletions.
24 changes: 6 additions & 18 deletions .github/workflows/opentofu-plan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
strategy:
fail-fast: false
matrix:
type: [plain, istio, cilium]
type: [nginx, istio, cilium]

name: 'Terraform'
runs-on: ubuntu-latest
Expand All @@ -35,30 +35,18 @@ jobs:
- name: Setup OpenTofu
uses: opentofu/setup-opentofu@v1

- name: Terraform Init
run: cd cluster && tofu init

- name: Terraform Plan (Plain)
if: matrix.type == 'plain'
run: cd cluster && tofu plan -no-color -out=tfplan.out && tofu show -json tfplan.out > tfplan.json

- name: Terraform Plan (With Istio)
if: matrix.type == 'istio'
run: cd cluster && tofu plan -var="enable_istio=true" -no-color -out=tfplan.out && tofu show -json tfplan.out > tfplan.json

- name: Terraform Plan (With Cilium)
if: matrix.type == 'cilium'
run: cd cluster && tofu plan -var="enable_cilium=true" -no-color -out=tfplan.out && tofu show -json tfplan.out > tfplan.json
- name: Tofu Plan
run: cd examples/kind-with-${{matrix.type}} && tofu init && tofu plan -no-color -out=tfplan.out && tofu show -json tfplan.out > tfplan.json

- name: Output Plan
run: cat cluster/tfplan.json
run: cat examples/kind-with-${{matrix.type}}/tfplan.json

- name: Checkov Analysis
id: checkov
uses: bridgecrewio/checkov-action@v12
with:
directory: cluster/
file: cluster/tfplan.json
directory: examples/kind-with-${{matrix.type}}/
file: examples/kind-with-${{matrix.type}}/tfplan.json
output_format: cli,sarif
output_file_path: console,results.sarif
# Ignoring checks since the original helm charts is so configure
Expand Down
24 changes: 6 additions & 18 deletions .github/workflows/terraform-plan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
strategy:
fail-fast: false
matrix:
type: [plain, istio, cilium]
type: [nginx, istio, cilium]

name: 'Terraform'
runs-on: ubuntu-latest
Expand All @@ -35,30 +35,18 @@ jobs:
- name: Setup Terraform
uses: hashicorp/setup-terraform@v3

- name: Terraform Init
run: cd cluster && terraform init

- name: Terraform Plan (Plain)
if: matrix.type == 'plain'
run: cd cluster && terraform plan -no-color -out=tfplan.out && terraform show -json tfplan.out > tfplan.json

- name: Terraform Plan (With Istio)
if: matrix.type == 'istio'
run: cd cluster && terraform plan -var="enable_istio=true" -no-color -out=tfplan.out && terraform show -json tfplan.out > tfplan.json

- name: Terraform Plan (With Cilium)
if: matrix.type == 'cilium'
run: cd cluster && terraform plan -var="enable_cilium=true" -no-color -out=tfplan.out && terraform show -json tfplan.out > tfplan.json
- name: Terraform Plan
run: cd examples/kind-with-${{matrix.type}} && terraform init && terraform plan -no-color -out=tfplan.out && terraform show -json tfplan.out > tfplan.json

- name: Output Plan
run: cat cluster/tfplan.json
run: cat examples/kind-with-${{matrix.type}}/tfplan.json

- name: Checkov Analysis
id: checkov
uses: bridgecrewio/checkov-action@v12
with:
directory: cluster/
file: cluster/tfplan.json
directory: examples/kind-with-${{matrix.type}}/
file: examples/kind-with-${{matrix.type}}/tfplan.json
output_format: cli,sarif
output_file_path: console,results.sarif
# Ignoring checks since the original helm charts is so configure
Expand Down
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2023-2024 Michele Adduci
Copyright (c) 2024 Michele Adduci

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand All @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
SOFTWARE.
198 changes: 99 additions & 99 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,99 +1,99 @@
# kind-with-mesh

[![Terraform Plan](https://github.com/madduci/kind-with-mesh/actions/workflows/terraform-plan.yaml/badge.svg)](https://github.com/madduci/kind-with-mesh/actions/workflows/terraform-plan.yaml) [![OpenTofu Plan](https://github.com/madduci/kind-with-mesh/actions/workflows/opentofu-plan.yaml/badge.svg)](https://github.com/madduci/kind-with-mesh/actions/workflows/opentofu-plan.yaml)

This Terraform project allows an user create a local Kubernetes Cluster using the [Kubernetes-in-Docker Stack](https://github.com/kubernetes-sigs/kind) (KIND) and configuring optionally one between NGINX-Ingress (default), Istio or Cilium.

The following steps are performed within the project:

* A local cluster composed by a Control-Plane node and one or more Worker-Nodes is bootstrapped (defaults to 3)
* The Ports 80, 443, 9879 and 15021 are bound on the host, mapping NodePorts on the Control-Plane Node
* A `kubeconfig` file is created locally in the project folder
* The namespace `ingress-nginx` with the NGINX Ingress controller is created, if it is enabled
* The namespace `istio-system` with the basic Istio services is created, if Istio is enabled
* When choosing Cilium, the services will be installed in the `kube-system` namespace

In case of further operations/configuration of the Kind cluster, it's suggested to download the latest release of the `kind` tool from the [GitHub Repository](https://github.com/kubernetes-sigs/kind/releases/latest).

## Requirements

The following tools are required for this project:

* `docker` (up and running)
* `terraform` (1.6+) / `opentofu` (1.6+)
* `helm` (3.0+)
* `kind` (0.22.0+)
* `make`

## Creating the Cluster

The bootstrapping and configuration of cluster can be performed with the command:

```sh
cd cluster
terraform init
terraform apply
```

There are variables that can be changed, they hold the following default values:

```hcl
kubernetes_version=v1.30.0
cluster_name=local-cluster
enable_istio=false
enable_cilium=false
```

### Alternative: using Makefile

To simplify the execution of the commands, a `Makefile` is available and this is used to perform the `terraform` commands seamless. All you need to do is to type from the root folder:

```sh
make cluster
```

If you want to delete the cluster, then type:

```sh
make cleanup
```

## Configuring Istio

Istio deploys a Service Mesh, offering the possibility to configure Mutual-TLS between Pods in a cluster, by defining some configurations. It helps to create an Ingress Object, exposing then ports 80, 443 and 15021 outside (as NodePort).

The configuration of the cluster with Istio can be performed with the command:

```sh
cd istio
terraform init
terraform apply -var=enable_istio=true
```

### Alternative: using Makefile

To simplify the execution of the commands, a `Makefile` is available and this is used to perform the `terraform` commands seamless. All you need to do is to type from the root folder:

```sh
make cluster-istio
```

## Configuring Cilium

Cilium deploys a Service Mesh, offering the possibility to configure Mutual-TLS between Pods in a cluster, by defining some configurations. It helps to create an Ingress Object, exposing then ports 80, 443 and 9879 outside (as NodePort).

The configuration of Cilium can be performed with the command:

```sh
cd cilium
terraform init
terraform apply -var=enable_cilium=true
```

### Alternative: using Makefile

To simplify the execution of the commands, a `Makefile` is available and this is used to perform the `terraform` commands seamless. All you need to do is to type from the root folder:

```sh
make cluster-cilium
```
# kind-with-mesh

[![Terraform Plan](https://github.com/madduci/kind-with-mesh/actions/workflows/terraform-plan.yaml/badge.svg)](https://github.com/madduci/kind-with-mesh/actions/workflows/terraform-plan.yaml) [![OpenTofu Plan](https://github.com/madduci/kind-with-mesh/actions/workflows/opentofu-plan.yaml/badge.svg)](https://github.com/madduci/kind-with-mesh/actions/workflows/opentofu-plan.yaml)

This Terraform project allows an user create a local Kubernetes Cluster using the [Kubernetes-in-Docker Stack](https://github.com/kubernetes-sigs/kind) (KIND) and configuring optionally one between NGINX-Ingress (default), Istio or Cilium.

The following steps are performed within the project:

* A local cluster composed by a Control-Plane node and one or more Worker-Nodes is bootstrapped (defaults to 3)
* The Ports 80, 443, 9879 and 15021 are bound on the host, mapping NodePorts on the Control-Plane Node
* A `kubeconfig` file is created locally in the project folder
* The namespace `ingress-nginx` with the NGINX Ingress controller is created, if it is enabled
* The namespace `istio-system` with the basic Istio services is created, if Istio is enabled
* When choosing Cilium, the services will be installed in the `kube-system` namespace

In case of further operations/configuration of the Kind cluster, it's suggested to download the latest release of the `kind` tool from the [GitHub Repository](https://github.com/kubernetes-sigs/kind/releases/latest).

## Requirements

The following tools are required for this project:

* `docker` (up and running)
* `terraform` (1.6+) / `opentofu` (1.6+)
* `helm` (3.0+)
* `kind` (0.22.0+)
* `make`

## Creating the Cluster

The bootstrapping and configuration of cluster can be performed with the command:

```sh
cd cluster
terraform init
terraform apply
```

There are variables that can be changed, they hold the following default values:

```hcl
kubernetes_version=v1.30.0
cluster_name=local-cluster
enable_istio=false
enable_cilium=false
```

### Alternative: using Makefile

To simplify the execution of the commands, a `Makefile` is available and this is used to perform the `terraform` commands seamless. All you need to do is to type from the root folder:

```sh
make cluster
```

If you want to delete the cluster, then type:

```sh
make cleanup
```

## Configuring Istio

Istio deploys a Service Mesh, offering the possibility to configure Mutual-TLS between Pods in a cluster, by defining some configurations. It helps to create an Ingress Object, exposing then ports 80, 443 and 15021 outside (as NodePort).

The configuration of the cluster with Istio can be performed with the command:

```sh
cd istio
terraform init
terraform apply -var=enable_istio=true
```

### Alternative: using Makefile

To simplify the execution of the commands, a `Makefile` is available and this is used to perform the `terraform` commands seamless. All you need to do is to type from the root folder:

```sh
make cluster-istio
```

## Configuring Cilium

Cilium deploys a Service Mesh, offering the possibility to configure Mutual-TLS between Pods in a cluster, by defining some configurations. It helps to create an Ingress Object, exposing then ports 80, 443 and 9879 outside (as NodePort).

The configuration of Cilium can be performed with the command:

```sh
cd cilium
terraform init
terraform apply -var=enable_cilium=true
```

### Alternative: using Makefile

To simplify the execution of the commands, a `Makefile` is available and this is used to perform the `terraform` commands seamless. All you need to do is to type from the root folder:

```sh
make cluster-cilium
```
11 changes: 0 additions & 11 deletions cluster/cilium-mesh/variables.tf

This file was deleted.

Loading

0 comments on commit e2f3d8d

Please sign in to comment.