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
[HPE GreenLake for Private Cloud Enterprise: Containers](https://www.hpe.com/us/en/greenlake/containers.html) ("containers service"), one of the HPE GreenLake cloud services available on the HPE GreenLake for Private Cloud Enterprise, allows customers to create a K8s cluster and deploy containerized applications to the cluster. It provides an enterprise-grade container management service using open source K8s.
26
-
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 deployed 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.
25
+
[HPE GreenLake for Private Cloud Enterprise: Containers](https://www.hpe.com/us/en/greenlake/containers.html), one of the HPE GreenLake cloud services available on the HPE GreenLake for Private Cloud Enterprise, allows customers to create a K8s cluster and deploy containerized applications to the cluster. It provides an enterprise-grade container management service using open source K8s.
26
+
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 deployed 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 with TLS termination 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
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
33
33
Despite the complexities, securely exposing applications in a K8s cluster over HTTPS is attainable. This can be achieved by leveraging Ingress and TLS termination, along with a suite of suitable tools and utilities deployed within the K8s cluster in HPE GreenLake for Private Cloud Enterprise.
34
-
34
+
35
35
### Prerequisites
36
36
37
37
Before starting, make sure you have the following:
@@ -43,7 +43,7 @@ Before starting, make sure you have the following:
43
43
44
44
### Set up the load balancer with MetalLB
45
45
46
-
You can install MetalLB and set up the load balancer in the K8s cluster by following up the blog post [Setting up the load balancer with MetalLB](https://developer.hpe.com/blog/set-up-load-balancer-with-metallb-in-hpe-greenlake-for-private-cloud-enterprise/).
46
+
You can install MetalLB and set up the load balancer in the K8s cluster by following up the blog post [Setting up the load balancer with MetalLB](https://developer.hpe.com/blog/set-up-load-balancer-with-metallb-in-hpe-greenlake-for-private-cloud-enterprise/).
47
47
48
48
Here is the deployed MetalLB to the namespace *metallb-system* in the cluster:
49
49
@@ -85,9 +85,9 @@ cfe-l2advert ["cfe-pool"]
85
85
86
86
### Deploy Nginx Ingress controller
87
87
88
-
In order for an Ingress to work in the cluster, there must be an Ingress controller being deployed and running. It's the Ingress controller that accesses the certificate and routing rules defined on the Ingress resource and makes them par of its configuration.
88
+
In order for an Ingress to work in the cluster, there must be an Ingress controller being deployed and running. It's the Ingress controller that accesses the certificate and the routing rules defined on the Ingress resource and makes them par of its configuration.
89
89
90
-
There is a list of Ingress controllers, such as [Traefik](https://doc.traefik.io/traefik/providers/kubernetes-ingress/), [HAProxy](https://github.com/haproxytech/kubernetes-ingress#readme), [Nginx Ingress controller](https://www.nginx.com/products/nginx-ingress-controller/), you can deploy in the cluster. The following command shows to install the Nginx Ingress controller to the cluster using helm:
90
+
A variety of Ingress controllers are available for deployment in the cluster, including [Traefik](https://doc.traefik.io/traefik/providers/kubernetes-ingress/), [HAProxy](https://github.com/haproxytech/kubernetes-ingress#readme) and [Nginx Ingress controller](https://www.nginx.com/products/nginx-ingress-controller/). Execute the command below to install the Nginx Ingress controller to the cluster using helm:
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.
165
165
166
-
### Generate a self-signed certificate using cert-manager
166
+
### Generate a self-signed certificate using cert-manager
167
167
168
168
You can deploy cert-manager to the K8s cluster and generate a self-signed certificate by following up the blog post [Generating self-signed certificates using cert-manager](https://developer.hpe.com/blog/generating-self-signed-certificates-using-cert-manager-for-kubernetes-in-hpe-greenlake-for-private-cloud-entreprise/).
Message: Certificate is up to date and has not expired
301
+
Observed Generation: 1
302
+
Reason: Ready
303
+
Status: True
304
+
Type: Ready
305
+
Not After: 2024-06-04T17:58:52Z
306
+
Not Before: 2024-03-06T17:58:52Z
307
+
Renewal Time: 2024-05-05T17:58:52Z
308
+
Revision: 1
309
309
Events: <none>
310
310
```
311
311
312
312
### Deploy sample Nginx applications
313
313
314
-
In order to validate the Ingress TLS termination, three sample Nginx applications will be deployed to the cluster using the YAML manifest files from the GitHub repo [ingress-demo](https://github.com/GuopingJia/ingress-demo):
314
+
In order to configure and validate the Ingress TLS termination, three sample Nginx applications will be deployed to the cluster using the YAML manifest files from the GitHub repo [ingress-demo](https://github.com/GuopingJia/ingress-demo):
315
315
316
316
```shell
317
317
$ tree ingress-demo/
@@ -325,7 +325,7 @@ ingress-demo/
325
325
└── README.md
326
326
```
327
327
328
-
Each YAML manifest file in the folder *apps* defines the *Deployment* and the *Service* resource.
328
+
Each YAML manifest file in the folder *'apps'* defines the *Deployment* and the *Service* resource.
329
329
330
330
Type the following commands to deploy those Nginx applications to the namespace *nginx-apps*:
Three Nginx applications, *nginx-main*, *nginx-blue* and *nginx-green*, are deployed as the service type of *ClusterIP*. They provide internal connectivity and can solely be accessed from within the cluster.
371
-
370
+
Three Nginx services, *nginx-main*, *nginx-blue* and *nginx-green*, are deployed as the *ClusterIP* type. They provide internal connectivity and can solely be accessed from within the cluster.
372
371
373
372
Type the following commend to check that all the application service endpoints have been populated:
374
373
375
374
```shell
376
-
$ kubectl get endpoints -n nginx-apps
377
-
NAME ENDPOINTS AGE
378
-
nginx-blue 10.192.3.78:80 1m
379
-
nginx-green 10.192.4.45:80 1m
375
+
$ kubectl get endpoints -n nginx-apps
376
+
NAME ENDPOINTS AGE
377
+
nginx-blue 10.192.3.78:80 1m
378
+
nginx-green 10.192.4.45:80 1m
380
379
nginx-main 10.192.4.44:80 1m
381
380
```
382
381
@@ -392,7 +391,6 @@ metadata:
392
391
name: ingress-host-based-selfsigned
393
392
annotations:
394
393
ingress.kubernetes.io/ssl-redirect: "true"
395
-
#kubernetes.io/ingress.class: "nginx"
396
394
cert-manager.io/issuer: "nginx-selfsinged-issuer"
397
395
spec:
398
396
ingressClassName: nginx
@@ -432,7 +430,6 @@ spec:
432
430
port:
433
431
number: 80
434
432
```
435
-
436
433
437
434
In the above sample YAML manifest file, there is the *'tls'* block that contains the hostname *'nginx.example.com'* and the 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.
438
435
@@ -490,7 +487,7 @@ $ host blue.nginx.example.com
490
487
blue.nginx.example.com has address 10.6.115.251
491
488
```
492
489
493
-
You can then validate the Ingres TLS configuration using the browser.
490
+
You can then validate the Ingres TLS configuration of the deployed Nginx applications 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
@@ -526,7 +523,6 @@ You have successfully configured the Ingress with the generated TLS certifica
526
523
527
524
### Conclusion
528
525
529
-
530
526
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
527
532
528
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