You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+28-73
Original file line number
Diff line number
Diff line change
@@ -170,69 +170,6 @@ rerun this command to reinitialize your working directory. If you forget, other
170
170
commands will detect it and remind you to do so if necessary.
171
171
```
172
172
173
-
#### Generate sel signed SSL certificate for the public LB (L7)
174
-
175
-
**NOTE** If you already own a valid certificate skip this step and set the correct values for the variables: PATH_TO_PUBLIC_LB_CERT and PATH_TO_PUBLIC_LB_KEY
176
-
177
-
We need to generate the certificates (sel signed) for our public load balancer (Layer 7). To do this we need *openssl*, open a terminal and follow this step:
178
-
179
-
Generate the key:
180
-
181
-
```
182
-
openssl genrsa 2048 > privatekey.pem
183
-
Generating RSA private key, 2048 bit long modulus (2 primes)
184
-
.......+++++
185
-
...............+++++
186
-
e is 65537 (0x010001)
187
-
```
188
-
189
-
Generate the a new certificate request:
190
-
191
-
```
192
-
openssl req -new -key privatekey.pem -out csr.pem
193
-
You are about to be asked to enter information that will be incorporated
194
-
into your certificate request.
195
-
What you are about to enter is what is called a Distinguished Name or a DN.
196
-
There are quite a few fields but you can leave some blank
197
-
For some fields there will be a default value,
198
-
If you enter '.', the field will be left blank.
199
-
-----
200
-
Country Name (2 letter code) [AU]:IT
201
-
State or Province Name (full name) [Some-State]:Italy
202
-
Locality Name (eg, city) []:Brescia
203
-
Organization Name (eg, company) [Internet Widgits Pty Ltd]:GL Ltd
204
-
Organizational Unit Name (eg, section) []:IT
205
-
Common Name (e.g. server FQDN or YOUR name) []:testlb.domainexample.com
In the *example/* directory of this repo you need to create a terraform.tfvars file, the file will look like:
@@ -266,8 +203,6 @@ Once you have created the terraform.tfvars file edit the main.tf file (always in
266
203
|`k3s_token`|`yes`| The token of your K3s cluster. [How to](#generate-random-token) generate a random token |
267
204
|`my_public_ip_cidr`|`yes`| your public ip in cidr format (Example: 195.102.xxx.xxx/32) |
268
205
|`environment`|`yes`| Current work environment (Example: staging/dev/prod). This value is used for tag all the deployed resources |
269
-
|`PATH_TO_PUBLIC_LB_CERT`|`yes`| Path to the public LB certificate. See [how to](#generate-sel-signed-ssl-certificate-for-the-public-lb-l7) generate the certificate |
270
-
|`PATH_TO_PUBLIC_LB_KEY`|`yes`| Path to the public LB key. See [how to](#generate-sel-signed-ssl-certificate-for-the-public-lb-l7) generate the key |
271
206
|`compute_shape`|`no`| Compute shape to use. Default VM.Standard.A1.Flex. **NOTE** Is mandatory to use this compute shape for provision 4 always free VMs |
272
207
|`os_image_id`|`no`| Image id to use. Default image: Canonical-Ubuntu-20.04-aarch64-2022.01.18-0. See [how](#how-to-list-all-the-os-images) to list all available OS images |
273
208
|`oci_core_vcn_dns_label`|`no`| VCN DNS label. Default: defaultvcn |
@@ -287,12 +222,17 @@ Once you have created the terraform.tfvars file edit the main.tf file (always in
287
222
|`k3s_server_pool_size`|`no`| Number of k3s servers deployed. Default 2 |
288
223
|`k3s_worker_pool_size`|`no`| Number of k3s workers deployed. Default 2 |
289
224
|`install_nginx_ingress`|`no`| Boolean value, install kubernetes nginx ingress controller instead of Traefik. Default: true. For more information see [Nginx ingress controller](#nginx-ingress-controller)|
225
+
nginx_ingress_controller_http_nodeport
226
+
|`nginx_ingress_controller_http_nodeport`|`30080`| NodePort where nginx ingress will listen for http traffic |
227
+
|`nginx_ingress_controller_https_nodeport`|`30443`| NodePort where nginx ingress will listen for https traffic |
|`certmanager_email_address`|`no`| Email address used for signing https certificates. Defaul: [email protected]|
292
233
|`unique_tag_key`|`no`| Unique tag name used for tagging all the deployed resources. Default: k3s-provisioner |
293
234
|`unique_tag_value`|`no`| Unique value used with unique_tag_key. Default: https://github.com/garutilorenzo/k3s-oci-cluster|
294
235
|`PATH_TO_PUBLIC_KEY`|`no`| Path to your public ssh key (Default: "~/.ssh/id_rsa.pub) |
295
-
|`PATH_TO_PRIVATE_KEY`|`no`| Path to your private ssh key (Default: "~/.ssh/id_rsa) |
296
236
297
237
#### Generate random token
298
238
@@ -399,7 +339,7 @@ This setup will automatically install [longhorn](https://longhorn.io/). Longhorn
399
339
400
340
In this environment [Nginx ingress controller](https://kubernetes.github.io/ingress-nginx/) is used instead of the standard [Traefik](https://traefik.io/) ingress controller.
401
341
402
-
The installation is the [bare metal](https://kubernetes.github.io/ingress-nginx/deploy/#bare-metal-clusters) installation, the ingress controller then is exposed via a LoadBalancer Service.
342
+
The installation is the [bare metal](https://kubernetes.github.io/ingress-nginx/deploy/#bare-metal-clusters) installation, the ingress controller then is exposed via a NodePort Service.
403
343
404
344
```yaml
405
345
---
@@ -418,25 +358,26 @@ spec:
418
358
port: 80
419
359
protocol: TCP
420
360
targetPort: 80
361
+
nodePort: ${nginx_ingress_controller_http_nodeport} # default to 30080
421
362
- name: https
422
363
port: 443
423
364
protocol: TCP
424
-
targetPort: 80
425
-
type: LoadBalancer
365
+
targetPort: 443
366
+
nodePort: ${nginx_ingress_controller_https_nodeport} # default to 30443
367
+
type: NodePort
426
368
```
427
369
428
-
To properly configure all the Forwarded HTTP Headers (L7 Headers) this parameters are added to che ConfigMap:
370
+
To get the real ip address of the clients using a public L4 load balancer we need to use the proxy protocol feature of nginx ingress controller:
429
371
430
372
```yaml
431
373
---
432
374
apiVersion: v1
433
375
data:
434
376
allow-snippet-annotations: "true"
435
-
use-forwarded-headers: "true"
436
-
compute-full-forwarded-for: "true"
437
377
enable-real-ip: "true"
438
-
forwarded-for-header: "X-Forwarded-For"
439
378
proxy-real-ip-cidr: "0.0.0.0/0"
379
+
proxy-body-size: "20m"
380
+
use-proxy-protocol: "true"
440
381
kind: ConfigMap
441
382
metadata:
442
383
labels:
@@ -451,6 +392,20 @@ metadata:
451
392
namespace: ingress-nginx
452
393
```
453
394
395
+
**NOTE** to use nginx ingress controller with the proxy protocol enabled, an external nginx instance is used as proxy. Nginx will be installed on each worker node and the configuation of nginx will:
396
+
397
+
* listen in proxy protocol mode
398
+
* forward the traffic from port 80 to nginx_ingress_controller_http_nodeport (default to 30080) on any server of the cluster
399
+
* forward the traffic from port 443 to nginx_ingress_controller_https_nodeport (default to 30443) on any server of the cluster
[cert-manager](https://cert-manager.io/docs/) is used to issue certificates from a variety of supported source. To use cert-manager take a look at [nginx-ingress-cert-manager.yml](deployments/nginx/nginx-ingress-cert-manager.yml) and [nginx-configmap-cert-manager.yml](deployments/nginx/nginx-configmap-cert-manager.yml) example. To use cert-manager and get the certificate you **need** set on your DNS configuration the public ip address of the load balancer.
408
+
454
409
## Deploy
455
410
456
411
We are now ready to deploy our infrastructure. First we ask terraform to plan the execution with:
0 commit comments