|
11 | 11 |
|
12 | 12 | ## 1. Deploy the Ingress Controller |
13 | 13 |
|
14 | | -1. Create an Ingress controller either for NGINX or NGINX Plus: |
15 | | - ``` |
16 | | - $ kubectl create -f nginx-ingress-rc.yaml |
17 | | - ``` |
18 | | - or |
19 | | - ``` |
20 | | - $ kubectl create -f nginx-plus-ingress-rc.yaml |
21 | | - ``` |
22 | | - |
23 | | -1. The controller container exposes ports 80, 443 (and 8080 for NGINX Plus ) |
| 14 | +1. Create a Secret with an SSL certificate and key for the default server of NGINX/NGINX Plus. The default server returns the Not Found page with the 404 status code for all requests for domains for which there are no Ingress rules defined. |
| 15 | + ``` |
| 16 | + $ kubectl create -f default-server-secret.yaml |
| 17 | + ``` |
| 18 | +
|
| 19 | +2. Create an Ingress controller either for NGINX or NGINX Plus: |
| 20 | + ``` |
| 21 | + $ kubectl create -f nginx-ingress-rc.yaml |
| 22 | + ``` |
| 23 | + or |
| 24 | + ``` |
| 25 | + $ kubectl create -f nginx-plus-ingress-rc.yaml |
| 26 | + ``` |
| 27 | +
|
| 28 | +3. The controller container exposes ports 80, 443 (and 8080 for NGINX Plus ) |
24 | 29 | on the host it is running on. Make sure to add a firewall rule to allow incoming traffic |
25 | 30 | though these ports. |
26 | 31 |
|
27 | 32 | ## 2. Deploy the Cafe Application |
28 | 33 |
|
29 | 34 | 1. Create the coffee and the tea services and replication controllers: |
30 | | - |
31 | | - ``` |
32 | | - $ kubectl create -f tea-rc.yaml |
33 | | - $ kubectl create -f tea-svc.yaml |
34 | | - $ kubectl create -f coffee-rc.yaml |
35 | | - $ kubectl create -f coffee-svc.yaml |
36 | | - ``` |
| 35 | + ``` |
| 36 | + $ kubectl create -f tea-rc.yaml |
| 37 | + $ kubectl create -f tea-svc.yaml |
| 38 | + $ kubectl create -f coffee-rc.yaml |
| 39 | + $ kubectl create -f coffee-svc.yaml |
| 40 | + ``` |
37 | 41 |
|
38 | 42 | ## 3. Configure Load Balancing |
39 | 43 |
|
40 | 44 | 1. Create a secret with an SSL certificate and a key: |
41 | | - ``` |
42 | | - $ kubectl create -f cafe-secret.yaml |
43 | | - ``` |
| 45 | + ``` |
| 46 | + $ kubectl create -f cafe-secret.yaml |
| 47 | + ``` |
44 | 48 |
|
45 | | -1. Create an Ingress Resource: |
46 | | - ``` |
47 | | - $ kubectl create -f cafe-ingress.yaml |
48 | | - ``` |
| 49 | +2. Create an Ingress Resource: |
| 50 | + ``` |
| 51 | + $ kubectl create -f cafe-ingress.yaml |
| 52 | + ``` |
49 | 53 |
|
50 | 54 | ## 4. Test the Application |
51 | 55 |
|
52 | 56 | 1. Find out the external IP address of the node where the controller is running: |
53 | | - ``` |
54 | | - $ kubectl get pods -o wide |
55 | | - NAME READY STATUS RESTARTS AGE NODE |
56 | | - coffee-rc-mtjuw 1/1 Running 0 3m kubernetes-minion-iikt |
57 | | - coffee-rc-mu9ns 1/1 Running 0 3m kubernetes-minion-cm0y |
58 | | - nginx-plus-ingress-rc-86kkq 1/1 Running 0 1m kubernetes-minion-iikt |
59 | | - tea-rc-7w3fq 1/1 Running 0 3m kubernetes-minion-iikt |
60 | | - ``` |
61 | | - |
62 | | - ``` |
63 | | - $ kubectl get node kubernetes-minion-iikt -o json | grep -A 2 ExternalIP |
64 | | - "type": "ExternalIP", |
65 | | - "address": "XXX.YYY.ZZZ.III" |
66 | | - } |
67 | | - ``` |
68 | | - |
69 | | -1. To see that the controller is working, let's curl the coffee and the tea services. |
| 57 | + ``` |
| 58 | + $ kubectl get pods -o wide |
| 59 | + NAME READY STATUS RESTARTS AGE NODE |
| 60 | + coffee-rc-mtjuw 1/1 Running 0 3m kubernetes-minion-iikt |
| 61 | + coffee-rc-mu9ns 1/1 Running 0 3m kubernetes-minion-cm0y |
| 62 | + nginx-plus-ingress-rc-86kkq 1/1 Running 0 1m kubernetes-minion-iikt |
| 63 | + tea-rc-7w3fq 1/1 Running 0 3m kubernetes-minion-iikt |
| 64 | + ``` |
| 65 | +
|
| 66 | + ``` |
| 67 | + $ kubectl get node kubernetes-minion-iikt -o json | grep -A 2 ExternalIP |
| 68 | + "type": "ExternalIP", |
| 69 | + "address": "XXX.YYY.ZZZ.III" |
| 70 | + } |
| 71 | + ``` |
| 72 | +
|
| 73 | +2. To see that the controller is working, let's curl the coffee and the tea services. |
70 | 74 | We'll use ```curl```'s --insecure option to turn off certificate verification of our self-signed |
71 | 75 | certificate and the --resolve option to set the Host header of a request with ```cafe.example.com``` |
72 | | - To get coffee: |
73 | | - ``` |
74 | | - $ curl --resolve cafe.example.com:443:XXX.YYY.ZZZ.III https://cafe.example.com/coffee --insecure |
75 | | - <!DOCTYPE html> |
76 | | - <html> |
77 | | - <head> |
78 | | - <title>Hello from NGINX!</title> |
79 | | - <style> |
80 | | - body { |
81 | | - width: 35em; |
82 | | - margin: 0 auto; |
83 | | - font-family: Tahoma, Verdana, Arial, sans-serif; |
84 | | - } |
85 | | - </style> |
86 | | - </head> |
87 | | - <body> |
88 | | - <h1>Hello!</h1> |
89 | | - <h2>URI = /coffee</h2> |
90 | | - <h2>My hostname is coffee-rc-mu9ns</h2> |
91 | | - <h2>My address is 10.244.0.3:80</h2> |
92 | | - </body> |
93 | | - </html> |
94 | | - ``` |
95 | | - If your rather prefer tea: |
96 | | - ``` |
97 | | - $ curl --resolve cafe.example.com:443:XXX.YYY.ZZZ.III https://cafe.example.com/tea --insecure |
98 | | - <!DOCTYPE html> |
99 | | - <html> |
100 | | - <head> |
101 | | - <title>Hello from NGINX!</title> |
102 | | - <style> |
103 | | - body { |
104 | | - width: 35em; |
105 | | - margin: 0 auto; |
106 | | - font-family: Tahoma, Verdana, Arial, sans-serif; |
107 | | - } |
108 | | - </style> |
109 | | - </head> |
110 | | - <body> |
111 | | - <h1>Hello!</h1> |
112 | | - <h2>URI = /tea</h2> |
113 | | - <h2>My hostname is tea-rc-w7rjr</h2> |
114 | | - <h2>My address is 10.244.0.5:80</h2> |
115 | | - </body> |
116 | | - </html> |
117 | | - ``` |
118 | | - |
119 | | - 1. If you're using NGINX Plus, you can open the live activity monitoring dashboard, which is available at http://XXX.YYY.ZZZ.III:8080/status.html |
| 76 | + |
| 77 | + To get coffee: |
| 78 | + ``` |
| 79 | + $ curl --resolve cafe.example.com:443:XXX.YYY.ZZZ.III https://cafe.example.com/coffee --insecure |
| 80 | + <!DOCTYPE html> |
| 81 | + <html> |
| 82 | + <head> |
| 83 | + <title>Hello from NGINX!</title> |
| 84 | + <style> |
| 85 | + body { |
| 86 | + width: 35em; |
| 87 | + margin: 0 auto; |
| 88 | + font-family: Tahoma, Verdana, Arial, sans-serif; |
| 89 | + } |
| 90 | + </style> |
| 91 | + </head> |
| 92 | + <body> |
| 93 | + <h1>Hello!</h1> |
| 94 | + <h2>URI = /coffee</h2> |
| 95 | + <h2>My hostname is coffee-rc-mu9ns</h2> |
| 96 | + <h2>My address is 10.244.0.3:80</h2> |
| 97 | + </body> |
| 98 | + </html> |
| 99 | + ``` |
| 100 | + If your rather prefer tea: |
| 101 | + ``` |
| 102 | + $ curl --resolve cafe.example.com:443:XXX.YYY.ZZZ.III https://cafe.example.com/tea --insecure |
| 103 | + <!DOCTYPE html> |
| 104 | + <html> |
| 105 | + <head> |
| 106 | + <title>Hello from NGINX!</title> |
| 107 | + <style> |
| 108 | + body { |
| 109 | + width: 35em; |
| 110 | + margin: 0 auto; |
| 111 | + font-family: Tahoma, Verdana, Arial, sans-serif; |
| 112 | + } |
| 113 | + </style> |
| 114 | + </head> |
| 115 | + <body> |
| 116 | + <h1>Hello!</h1> |
| 117 | + <h2>URI = /tea</h2> |
| 118 | + <h2>My hostname is tea-rc-w7rjr</h2> |
| 119 | + <h2>My address is 10.244.0.5:80</h2> |
| 120 | + </body> |
| 121 | + </html> |
| 122 | + ``` |
| 123 | +
|
| 124 | + 3. If you're using NGINX Plus, you can open the live activity monitoring dashboard, which is available at http://XXX.YYY.ZZZ.III:8080/status.html |
120 | 125 | If you go to the Upstream tab, you'll see:  |
0 commit comments