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
This blog post shows you the detailed process to deploy Super Mario game to the Kubernetes in HPE GreenLake for Private Cloud Enterprise.
21
22
23
+

24
+
22
25
### Prerequisites
23
26
24
27
Before starting, make sure you have the following:
25
28
26
29
* A K8s cluster, being provisioned in HPE GreenLake for Private Cloud Enterprise
27
-
* The kubectl CLI tool, together with the kubeconfig file for accessing the K8s cluster
28
-
* The optional openssl CLI tool, for validating the generated certificates
30
+
* The *kubectl* CLI tool, together with the kubeconfig file for accessing the K8s cluster
31
+
* The *helm* CLI tool, version 3.12.0 or later
32
+
* A domain and a list of subdomains to generate the SSL certificate and host the applications in the cluster
33
+
* The optional *openssl* CLI tool, for validating the generated certificates
34
+
35
+
### Deploy Super Mario game
36
+
37
+
*Super Mario*, together with *Tetris*, can be deployed to the cluster using the YAML manifest files from the GitHub repo [k8s-games](https://github.com/GuopingJia/k8s-games):
38
+
39
+
```shell
40
+
$ tree k8s-games/
41
+
k8s-games/
42
+
├── README.md
43
+
├── super-mario
44
+
│ ├── deployment.yaml
45
+
│ └── service.yaml
46
+
└── tetris
47
+
├── deployment.yaml
48
+
└── service.yaml
49
+
```
50
+
51
+
Type the following commands to deploy the game *Super Mario* and *Tetris* to the namespace *cfe-games*:
52
+
53
+
54
+
```shell
55
+
$ kubectl create ns cfe-games
56
+
namespace/cfe-games created
57
+
58
+
$ kubectl apply -f super-mario/ -n cfe-games
59
+
deployment.apps/mario-deployment created
60
+
service/mario-service created
61
+
62
+
$ kubectl apply -f tetris/ -n cfe-games
63
+
deployment.apps/tetris-deployment created
64
+
service/tetris-service created
65
+
```
66
+
67
+
Type the command shown below to check the details of game deployment:
Two games, *mario* and *tetris*, are deployed as the *ClusterIP* type, each running with 2 Pod replicas. They provide internal connectivity and can solely be accessed from within the cluster.
91
+
92
+
Type the following commend to check that all the game service endpoints have been populated:
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/).
104
+
105
+
Here is the deployed MetalLB to the namespace *metallb-system* in the cluster:
29
106
30
107
```shell
31
-
$ k get all -n metallb-system
108
+
$ kubectl get all -n metallb-system
32
109
NAME READY STATUS RESTARTS AGE
33
110
pod/controller-57b4fdc957-dr4h4 1/1 Running 0 18d
34
111
pod/speaker-9kx9h 1/1 Running 0 18d
@@ -50,8 +127,70 @@ NAME DESIRED CURRENT READY AGE
50
127
replicaset.apps/controller-57b4fdc957 1 1 1 18d
51
128
```
52
129
130
+
### Deploy Nginx Ingress controller
131
+
132
+
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 part of its configuration.
133
+
134
+
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:
### Generate a self-signed certificate using cert-manager
209
+
210
+
211
+
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/).
212
+
213
+
Here is the deployed cert-manager to the namespace *cert-manager* in the cluster:
The line X509v3 Subject Alternative Name contains the *dnsNames*, *'super-mario.example.com'*&*'tetris.example.com'*, which host two games, *Super Mario*&*Tetris*, respectively in the cluster.
The Ingress resource with TLS has to be created. Here is the sample Ingress TLS resource *ingress-host-based-selfsigned.yaml*, available from the GitHub repo [ingress-demo](https://github.com/GuopingJia/ingress-demo):
246
373
247
374
```shell
248
375
$ cat ingress-host-based-selfsigned-games.yaml
@@ -252,8 +379,7 @@ metadata:
252
379
name: ingress-host-based-selfsigned
253
380
annotations:
254
381
ingress.kubernetes.io/ssl-redirect: "true"
255
-
#kubernetes.io/ingress.class: "nginx"
256
-
cert-manager.io/issuer: "cfe-selfsinged-issuer"
382
+
cert-manager.io/issuer: "cfe-selfsigned-issuer"
257
383
spec:
258
384
ingressClassName: nginx
259
385
tls:
@@ -283,8 +409,14 @@ spec:
283
409
number: 80
284
410
```
285
411
412
+
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.
413
+
414
+
415
+
416
+
Type the following command to deploy the Ingress resource to the namespace *nginx-apps*:
417
+
286
418
```shell
287
-
$ k describe ingress ingress-host-based-selfsigned -n cfe-games
0 commit comments