Skip to content

Commit 5a178eb

Browse files
committed
Update Blog “exposing-an-application-using-ingress-and-tls-termination-on-kubernetes-in-hpe-greenlake-for-private-cloud-enterprise”
1 parent 85620d8 commit 5a178eb

File tree

1 file changed

+109
-113
lines changed

1 file changed

+109
-113
lines changed

content/blog/exposing-an-application-using-ingress-and-tls-termination-on-kubernetes-in-hpe-greenlake-for-private-cloud-enterprise.md

Lines changed: 109 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@ tags:
2222

2323
### Overview
2424

25-
[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.
2828

2929
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.
3030

3131
![](/img/tls-termination-s.png)
3232

3333
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+
3535
### Prerequisites
3636

3737
Before starting, make sure you have the following:
@@ -43,7 +43,7 @@ Before starting, make sure you have the following:
4343

4444
### Set up the load balancer with MetalLB
4545

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/).
4747

4848
Here is the deployed MetalLB to the namespace *metallb-system* in the cluster:
4949

@@ -85,9 +85,9 @@ cfe-l2advert ["cfe-pool"]
8585

8686
### Deploy Nginx Ingress controller
8787

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.
8989

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:
9191

9292
```shell
9393
$ helm upgrade --install ingress-nginx ingress-nginx \
@@ -163,7 +163,7 @@ replicaset.apps/ingress-nginx-controller-548768956f 1 1 1
163163

164164
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.
165165

166-
### Generate a self-signed certificate using cert-manager
166+
### Generate a self-signed certificate using cert-manager
167167

168168
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/).
169169

@@ -191,7 +191,7 @@ replicaset.apps/cert-manager-cainjector-69548575fb 1 1 1
191191
replicaset.apps/cert-manager-webhook-57b78f476d 1 1 1 18s
192192
```
193193

194-
Below is the deployed self-signed custom resource definition (CRD) *Issuer* in the namespace *nginx-apps* in which you want to generate certificate:
194+
Below is the deployed self-signed custom resource definition (CRD) *Issuer* in the namespace *nginx-apps* in which you want to generate certificate:
195195

196196
```shell
197197
$ kubectl get issuer -n nginx-apps
@@ -202,116 +202,116 @@ cfe-selfsigned-issuer True 115s
202202
Here is the generated self-signed certificate in the namespace *nginx-apps*:
203203

204204
```shell
205-
$ kubectl get certificate -n nginx-apps
206-
NAME READY SECRET AGE
205+
$ kubectl get certificate -n nginx-apps
206+
NAME READY SECRET AGE
207207
cfe-selfsigned-tls True cfe-tls-key-pair 2m23s
208208
```
209209

210-
The following K8s Secret *cfe-tls-key-pair* is created automatically in the same namespace as part of certificate deployment:
210+
The K8s Secret *cfe-tls-key-pair* is created automatically in the same namespace as part of certificate deployment:
211211

212212
```shell
213213
$ kubectl get secrets -n nginx-apps cfe-tls-key-pair
214214
NAME TYPE DATA AGE
215215
cfe-tls-key-pair kubernetes.io/tls 3 2m25s
216216
```
217217

218-
Type the following command to check the *commonName* and the *dnsNames* that are used to generate the certificate:
218+
Type the following command to check the *commonName* and the *dnsNames* in the generated certificate:
219219

220220
```shell
221-
$ kubectl describe certificate cfe-selfsigned-tls -n nginx-apps
222-
Name: cfe-selfsigned-tls
223-
Namespace: nginx-apps
224-
Labels: <none>
225-
Annotations: <none>
226-
API Version: cert-manager.io/v1
227-
Kind: Certificate
228-
Metadata:
229-
Creation Timestamp: 2024-03-06T17:58:51Z
230-
Generation: 1
231-
Managed Fields:
232-
API Version: cert-manager.io/v1
233-
Fields Type: FieldsV1
234-
fieldsV1:
235-
f:metadata:
236-
f:annotations:
237-
.:
238-
f:kubectl.kubernetes.io/last-applied-configuration:
239-
f:spec:
240-
.:
241-
f:commonName:
242-
f:dnsNames:
243-
f:isCA:
244-
f:issuerRef:
245-
.:
246-
f:kind:
247-
f:name:
248-
f:secretName:
249-
Manager: kubectl-client-side-apply
250-
Operation: Update
251-
Time: 2024-03-06T17:58:51Z
252-
API Version: cert-manager.io/v1
253-
Fields Type: FieldsV1
254-
fieldsV1:
255-
f:status:
256-
f:revision:
257-
Manager: cert-manager-certificates-issuing
258-
Operation: Update
259-
Subresource: status
260-
Time: 2024-03-06T17:58:52Z
261-
API Version: cert-manager.io/v1
262-
Fields Type: FieldsV1
263-
fieldsV1:
264-
f:status:
265-
.:
266-
f:conditions:
267-
.:
268-
k:{"type":"Ready"}:
269-
.:
270-
f:lastTransitionTime:
271-
f:message:
272-
f:observedGeneration:
273-
f:reason:
274-
f:status:
275-
f:type:
276-
f:notAfter:
277-
f:notBefore:
278-
f:renewalTime:
279-
Manager: cert-manager-certificates-readiness
280-
Operation: Update
281-
Subresource: status
282-
Time: 2024-03-06T17:58:52Z
283-
Resource Version: 2128063
284-
UID: 977eaa8a-1612-489b-a34d-0e78ab113096
285-
Spec:
286-
Common Name: example.com
287-
Dns Names:
288-
green.nginx.example.com
289-
blue.nginx.example.com
290-
nginx.example.com
291-
example.com
292-
Is CA: true
293-
Issuer Ref:
294-
Kind: Issuer
295-
Name: cfe-selfsigned-issuer
296-
Secret Name: cfe-tls-key-pair
297-
Status:
298-
Conditions:
299-
Last Transition Time: 2024-03-06T17:58:52Z
300-
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
221+
$ kubectl describe certificate cfe-selfsigned-tls -n nginx-apps
222+
Name: cfe-selfsigned-tls
223+
Namespace: nginx-apps
224+
Labels: <none>
225+
Annotations: <none>
226+
API Version: cert-manager.io/v1
227+
Kind: Certificate
228+
Metadata:
229+
Creation Timestamp: 2024-03-06T17:58:51Z
230+
Generation: 1
231+
Managed Fields:
232+
API Version: cert-manager.io/v1
233+
Fields Type: FieldsV1
234+
fieldsV1:
235+
f:metadata:
236+
f:annotations:
237+
.:
238+
f:kubectl.kubernetes.io/last-applied-configuration:
239+
f:spec:
240+
.:
241+
f:commonName:
242+
f:dnsNames:
243+
f:isCA:
244+
f:issuerRef:
245+
.:
246+
f:kind:
247+
f:name:
248+
f:secretName:
249+
Manager: kubectl-client-side-apply
250+
Operation: Update
251+
Time: 2024-03-06T17:58:51Z
252+
API Version: cert-manager.io/v1
253+
Fields Type: FieldsV1
254+
fieldsV1:
255+
f:status:
256+
f:revision:
257+
Manager: cert-manager-certificates-issuing
258+
Operation: Update
259+
Subresource: status
260+
Time: 2024-03-06T17:58:52Z
261+
API Version: cert-manager.io/v1
262+
Fields Type: FieldsV1
263+
fieldsV1:
264+
f:status:
265+
.:
266+
f:conditions:
267+
.:
268+
k:{"type":"Ready"}:
269+
.:
270+
f:lastTransitionTime:
271+
f:message:
272+
f:observedGeneration:
273+
f:reason:
274+
f:status:
275+
f:type:
276+
f:notAfter:
277+
f:notBefore:
278+
f:renewalTime:
279+
Manager: cert-manager-certificates-readiness
280+
Operation: Update
281+
Subresource: status
282+
Time: 2024-03-06T17:58:52Z
283+
Resource Version: 2128063
284+
UID: 977eaa8a-1612-489b-a34d-0e78ab113096
285+
Spec:
286+
Common Name: example.com
287+
Dns Names:
288+
green.nginx.example.com
289+
blue.nginx.example.com
290+
nginx.example.com
291+
example.com
292+
Is CA: true
293+
Issuer Ref:
294+
Kind: Issuer
295+
Name: cfe-selfsigned-issuer
296+
Secret Name: cfe-tls-key-pair
297+
Status:
298+
Conditions:
299+
Last Transition Time: 2024-03-06T17:58:52Z
300+
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
309309
Events: <none>
310310
```
311311

312312
### Deploy sample Nginx applications
313313

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):
315315

316316
```shell
317317
$ tree ingress-demo/
@@ -325,7 +325,7 @@ ingress-demo/
325325
└── README.md
326326
```
327327

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.
329329

330330
Type the following commands to deploy those Nginx applications to the namespace *nginx-apps*:
331331

@@ -367,16 +367,15 @@ replicaset.apps/nginx-green-8956bbd9f 1 1 1 24s
367367
replicaset.apps/nginx-main-64bfd77895 1 1 1 32s
368368
```
369369

370-
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.
372371

373372
Type the following commend to check that all the application service endpoints have been populated:
374373

375374
```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
380379
nginx-main 10.192.4.44:80 1m
381380
```
382381

@@ -392,7 +391,6 @@ metadata:
392391
name: ingress-host-based-selfsigned
393392
annotations:
394393
ingress.kubernetes.io/ssl-redirect: "true"
395-
#kubernetes.io/ingress.class: "nginx"
396394
cert-manager.io/issuer: "nginx-selfsinged-issuer"
397395
spec:
398396
ingressClassName: nginx
@@ -432,7 +430,6 @@ spec:
432430
port:
433431
number: 80
434432
```
435-
436433

437434
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.
438435

@@ -490,7 +487,7 @@ $ host blue.nginx.example.com
490487
blue.nginx.example.com has address 10.6.115.251
491488
```
492489

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.
494491

495492
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'*:
496493

@@ -526,7 +523,6 @@ You have successfully configured the Ingress with the generated TLS certifica
526523

527524
### Conclusion
528525

529-
530526
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.
531527

532528
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

Comments
 (0)