Skip to content

Commit

Permalink
feat: add nginx external ingress addons instalation
Browse files Browse the repository at this point in the history
feat: add nginx external ingress example
  • Loading branch information
LukaK committed Oct 27, 2024
1 parent b8d4d5e commit dfd3138
Show file tree
Hide file tree
Showing 20 changed files with 135 additions and 0 deletions.
27 changes: 27 additions & 0 deletions examples/apps/nginx-external.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: example-nginx-external
namespace: argocd

# remove resources when deleting application
finalizers:
- resources-finalizer.argocd.argoproj.io
spec:
project: default
source:
repoURL: https://github.com/LukaK/aws-eks-infrastructure.git
targetRevision: main
path: examples/nginx-external
destination:
server: https://kubernetes.default.svc
syncPolicy:
automated:
prune: true # delete resources
selfHeal: true # drift override
syncOptions:
- Validate=true # validate deployment fields
- CreateNamespace=false # don't create namespaces automatically
- PrunePropagationPolicy=foreground
- PruneLast=true
5 changes: 5 additions & 0 deletions examples/nginx-external/0-namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
apiVersion: v1
kind: Namespace
metadata:
name: nginx-external-example
21 changes: 21 additions & 0 deletions examples/nginx-external/1-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: myapp
namespace: nginx-external-example
spec:
selector:
matchLabels:
app: myapp
template:
metadata:
labels:
app: myapp
spec:
containers:
- name: echoserver
image: ealen/echo-server
ports:
- name: http
containerPort: 80
13 changes: 13 additions & 0 deletions examples/nginx-external/2-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
apiVersion: v1
kind: Service
metadata:
name: myapp
namespace: nginx-external-example
spec:
type: ClusterIP
ports:
- port: 8080
targetPort: http
selector:
app: myapp
20 changes: 20 additions & 0 deletions examples/nginx-external/3-ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: myapp
namespace: nginx-external-example
spec:
ingressClassName: external-nginx
rules:
- host: test.lukakrapic.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: myapp
port:
number: 8080

11 changes: 11 additions & 0 deletions examples/nginx-external/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Nginx External Ingress

Wait until `Address` field is populated in the ingress and get the value.
```bash
kubectl get ingress -n nginx-external-example
```

To test the example use
```bash
curl -i --header "Host: test.lukakrapic.com" http://ADDRESS
```
8 changes: 8 additions & 0 deletions examples/nginx-external/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- 0-namespace.yaml
- 1-deployment.yaml
- 2-service.yaml
- 3-ingress.yaml
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ variable "argocd_chart_version" {
default = "7.6.12"
}

variable "nginx_chart_version" {
type = string
description = "Helm chart version for nginx"
default = "4.10.1"
}

variable "tags" {
type = map(string)
default = {}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
13 changes: 13 additions & 0 deletions infrastructure/modules/addons/10-nginx-external-ingress.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
resource "helm_release" "external_nginx" {
name = "external-nginx"

repository = "https://kubernetes.github.io/ingress-nginx"
chart = "ingress-nginx"
version = var.nginx_chart_version

namespace = "ingress"
create_namespace = true
values = [file("values/nginx-external-ingress.yaml")]

depends_on = [helm_release.aws_lbc]
}
2 changes: 2 additions & 0 deletions infrastructure/modules/addons/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ No modules.
| [helm_release.aws_lbc](https://registry.terraform.io/providers/hashicorp/helm/2.16.0/docs/resources/release) | resource |
| [helm_release.cluster_autoscaler](https://registry.terraform.io/providers/hashicorp/helm/2.16.0/docs/resources/release) | resource |
| [helm_release.efs_csi_driver](https://registry.terraform.io/providers/hashicorp/helm/2.16.0/docs/resources/release) | resource |
| [helm_release.external_nginx](https://registry.terraform.io/providers/hashicorp/helm/2.16.0/docs/resources/release) | resource |
| [helm_release.metric_server](https://registry.terraform.io/providers/hashicorp/helm/2.16.0/docs/resources/release) | resource |

## Inputs
Expand All @@ -50,6 +51,7 @@ No modules.
| <a name="input_ebs_csi_driver_version"></a> [ebs\_csi\_driver\_version](#input\_ebs\_csi\_driver\_version) | Version of the ebs csi driver. | `string` | `"v1.35.0-eksbuild.1"` | no |
| <a name="input_efs_csi_chart_version"></a> [efs\_csi\_chart\_version](#input\_efs\_csi\_chart\_version) | Helm chart version for efs csi driver | `string` | `"3.0.8"` | no |
| <a name="input_metric_server_chart_version"></a> [metric\_server\_chart\_version](#input\_metric\_server\_chart\_version) | Helm chart version for metric server | `string` | `"3.12.1"` | no |
| <a name="input_nginx_chart_version"></a> [nginx\_chart\_version](#input\_nginx\_chart\_version) | Helm chart version for nginx | `string` | `"4.10.1"` | no |
| <a name="input_pod_identity_version"></a> [pod\_identity\_version](#input\_pod\_identity\_version) | Version of the pod identity agent | `string` | `"v1.3.2-eksbuild.2"` | no |
| <a name="input_region"></a> [region](#input\_region) | Aws region | `string` | `"eu-west-1"` | no |
| <a name="input_tags"></a> [tags](#input\_tags) | n/a | `map(string)` | `{}` | no |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
controller:
ingressClassResource:
name: external-nginx
service:
annotations:
service.beta.kubernetes.io/aws-load-balancer-type: external
service.beta.kubernetes.io/aws-load-balancer-nlb-target-type: ip
service.beta.kubernetes.io/aws-load-balancer-scheme: internet-facing

0 comments on commit dfd3138

Please sign in to comment.