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: content/blog/exposing-an-application-using-ingress-and-tls-termination-on-kubernetes-in-hpe-greenlake-for-private-cloud-enterprise.md
+14-17Lines changed: 14 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
title: Exposing applications using Ingress and TLS termination on Kubernetes in
3
3
HPE GreenLake for Private Cloud Enterprise
4
-
date: 2024-03-14T13:35:56.941Z
4
+
date: 2024-03-20T10:06:33.740Z
5
5
author: Guoping Jia
6
6
authorimage: /img/guoping.png
7
7
disable: false
@@ -26,7 +26,7 @@ tags:
26
26
27
27
Once applications are deployed in a K8s cluster, the next step is to create services that expose these applications. By default, K8s services are created with the *ClusterIP* type, which supports internal connectivity among different components of the applications. However, these services are not directly accessible from outside the cluster. The challenge arises with a requirement to securely expose the applications over HTTPS. This involves generating and managing SSL/TLS certificates for multiple applications deployed in the cluster. These certificates are crucial for secure communication between services, and their correct installation and management are essential to avoid access issues and security risks. To address exposing applications over HTTPS, K8s provides the concept of *Ingress*. An Ingress acts as an entry point for external traffic into the cluster. It can be configured with TLS termination. However, setting up K8s Ingress is intricate. It involves creating a K8s Secret to host the certificate and referencing the Secret in the Ingress resource. It also requires an additional load balancer configuration in the cluster.
28
28
29
-
This blog post outlines the comprehensive steps for exposing applications using Ingress and TLS termination on K8s in HPE GreenLake for Private Cloud Enterprise. MetalLB is deployed to the cluster to set up the load balancer. It enables external access to services within the cluster. Cert-manager is utilized for creating and managing SSL/TLS certificates. The generated certificate is stored as a K8s *Secret* object. This Secret can be mounted by application Pods or used by an Ingress controller. The Nginx Ingress controller is deployed and configured in the cluster. It handles SSL certificates and facilitates secure access to applications in the backend.
29
+
This blog post outlines the comprehensive steps for exposing applications using Ingress and TLS termination on K8s in HPE GreenLake for Private Cloud Enterprise. [MetalLB](https://metallb.universe.tf/) is deployed to the cluster to set up the load balancer. It enables external access to services within the cluster. [Cert-manager](https://cert-manager.io/) is utilized for creating and managing SSL/TLS certificates. The generated certificate is stored as a K8s *Secret* object. This Secret can be mounted by application Pods or used by an Ingress controller. The [Nginx Ingress controller](https://www.nginx.com/products/nginx-ingress-controller/) is deployed and configured in the cluster. It handles SSL certificates and facilitates secure access to applications in the backend.
30
30
31
31

32
32
@@ -71,7 +71,7 @@ NAME DESIRED CURRENT READY AGE
71
71
replicaset.apps/controller-57b4fdc957 1 1 1 22m
72
72
```
73
73
74
-
Here is the range of virtual IP addresses, *"10.6.115.251-10.6.115.254"*, defined in the CRD resource *IPAddressPool*, and the layer 2 service IP address announcement in the CRD resource *L2Advertisement*:
74
+
You can see the range of virtual IP addresses, *"10.6.115.251-10.6.115.254"*, defined in the CRD resource *IPAddressPool*, and the layer 2 service IP address announcement in the CRD resource *L2Advertisement*:
The service *ingress-nginx-controller* gets deployed as the service type of *LoadBalancer* with the *EXTERNAL-IP* assigned as *10.6.115.251*.
162
+
The service *ingress-nginx-controller* gets deployed as the service type of *LoadBalancer* with the *EXTERNAL-IP* assigned as *10.6.115.251*. This IP address will be used for setting up domain and subdomain name resolution.
163
163
164
164
### Generate a self-signed certificate using cert-manager
Here is the deployed self-signed custom resource definition (CRD) *Issuer* in the namespace *nginx-apps* in which you want to generate certificates:
192
+
Below is the deployed self-signed custom resource definition (CRD) *Issuer* in the namespace *nginx-apps* in which you want to generate certificate:
193
193
194
194
```shell
195
195
$ kubectl get issuer -n nginx-apps
196
196
NAME READY AGE
197
197
cfe-selfsigned-issuer True 115s
198
198
```
199
199
200
-
Below is the generated self-signed certificate in the namespace *nginx-apps*:
200
+
Here is the generated self-signed certificate in the namespace *nginx-apps*:
201
201
202
202
```shell
203
203
$ kubectl apply -f certificate.yaml -n nginx-apps
204
204
certificate.cert-manager.io/cfe-selfsigned-tls created
205
205
```
206
206
207
-
The following K8s secret*cfe-tls-key-pair* is created automatically in the same namespace as part of certificate deployment:
207
+
The following K8s Secret*cfe-tls-key-pair* is created automatically in the same namespace as part of certificate deployment:
208
208
209
209
```shell
210
210
$ kubectl get secrets -n nginx-apps cfe-tls-key-pair
@@ -431,7 +431,7 @@ spec:
431
431
```
432
432
433
433
434
-
In the above sample YAML manifest file, there is the *tls block* that contains the hostname *'nginx.example.com'* and the tls secret *cfe-tls-key-pair* created in the certification steps. There is also the *rules block* in which a list of routing rules is defined per host, e.g., host *nginx.example.com* will be routed to the application service *nginx-main* in the backend.
434
+
In the above sample YAML manifest file, there is the *tls* block that contains the hostname *'nginx.example.com'* and the tls secret *cfe-tls-key-pair* created in the certification step. There is also the *rules* block in which a list of routing rules is defined per host, e.g., host *nginx.example.com* will be routed to the application service *nginx-main* in the backend.
435
435
436
436
Type the following command to deploy the Ingress resource to the namespace *nginx-apps*:
With three Nginx applications and the K8s Ingress resource being deployed to the cluster, you need set up and make sure the domain and the subdomain names, i.e., *example.com* & **.nginx.example.com*, point to the the external IP address *'10.6.115.251'* which is assigned to the *Nginx ingress controller*.
475
+
Before start accessing the deployed Nginx applications, you need set up the domain and the subdomain name resolution. For the sample domain name *nginx.example.com*, and its subdomains, *blue.nginx.example.com* and *green.nginx.example.com*, the workstation host file has been used for DNS resolution.
479
476
480
477
Type the following commands to check this is done correctly:
You can then validate the Ingres TLS configuration of the deployed Nginx applications to the cluster using the browser.
490
+
You can then validate the Ingres TLS configuration using the browser.
494
491
495
492
Start the browser and type the URL *nginx.example.com*, it will be rediected over HTTPS with the warning message *'Your connection is not private'*:
496
493
497
494

498
495
499
-
This is due to the fact the self-signed certifcate is generated in cert-manager and configured in the K8s Ingress resource.
496
+
This is due to the fact that the self-signed certifcate is generated in cert-manager and configured in the K8s Ingress resource.
500
497
501
498
Click *Not secure* and start the Certificate Viewer to check the certificate:
502
499
@@ -527,6 +524,6 @@ You have successfully configured the Ingress with the generated TLS certifica
527
524
### Conclusion
528
525
529
526
530
-
This blog post provided a comprehensive guide on how to expose applications and make them accessible securely via HTTPS in a K8 cluster in HPE GreenLake for Private Cloud Enterprise. It detailed the process of configuring TLS termination on an Ingress controller, utilizing a K8s Ingress resource and a self-signed TLS certificate generated with cert-manager. Although the emphasis was on self-signed certificates, the procedure is applicable to any type of certificates. This enables customers to follow up the steps using their own CA certificates for Ingress TLS termination.
527
+
This blog post provided a comprehensive guide on how to expose applications and make them accessible securely via HTTPS in a K8 cluster in HPE GreenLake for Private Cloud Enterprise. It detailed the process of configuring TLS termination on an Ingress controller, utilizing a K8s Ingress resource and a self-signed TLS certificate generated with cert-manager. While the blog post emphasized on self-signed certificates, the outlined procedure is equally applicable to any type of certificates. This flexibility allows customers to follow the steps using their own CA certificates or any commercially issued certificates for Ingress TLS termination, ensuring secure exposure of their applications in the K8s cluster over HTTPS.
531
528
532
529
Please keep coming back to the [HPE Developer Community blog](https://developer.hpe.com/blog/) to learn more about HPE GreenLake for Private Cloud Enterprise.
0 commit comments