Skip to content

Commit 014114b

Browse files
committed
Update chapter 1: Add ConfigMap, fix nodeSelector/container name, update outputs, add service selector explanation
1 parent c54e02e commit 014114b

1 file changed

Lines changed: 42 additions & 33 deletions

File tree

  • content/learning-paths/servers-and-cloud-computing/multiarch_nginx_on_aks

content/learning-paths/servers-and-cloud-computing/multiarch_nginx_on_aks/1-deploy-intel.md

Lines changed: 42 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,16 @@ layout: learningpathall
88

99
## Deployment and service
1010

11-
In this section, you'll add a new namespace, deployment, and service for nginx on Intel. The end result will be a K8s cluster running nginx accessible via the Internet through a load balancer.
11+
In this section, you'll add a new namespace, deployment, and service for nginx on Intel. The end result will be a K8s cluster running nginx accessible via the Internet through a load balancer.
1212

1313
To better understand the individual components, the configuration is split into two files:
1414

15-
1. Applying the namespace.yaml creates a new namespace called `nginx`, which contains all your K8s nginx objects.
15+
1. **namespace.yaml** - Creates a new namespace called `nginx`, which contains all your K8s nginx objects
1616

17-
2. Applying the intel_nginx.yaml creates the following K8s objects:
18-
19-
2. 1. A K8s deployment called `nginx-intel-deployment`. This deployment pulls a multi-architecture [nginx image](https://hub.docker.com/_/nginx) from DockerHub, and launches a pod for it on the x86 node.
20-
21-
2. 2. A K8s load balancer service `nginx-intel-svc`, targeting any pod with the `arch: intel` label (the Intel deployment will create this pod).
17+
2. **intel_nginx.yaml** - Creates the following K8s objects:
18+
- **ConfigMap** (`nginx-intel-config`) - Contains performance-optimized nginx configuration
19+
- **Deployment** (`nginx-intel-deployment`) - Pulls a multi-architecture [nginx image](https://hub.docker.com/_/nginx) from DockerHub, launches a pod on the Intel node, and mounts the ConfigMap as `/etc/nginx/nginx.conf`
20+
- **Service** (`nginx-intel-svc`) - Load balancer targeting pods with both `app: nginx-multiarch` and `arch: intel` labels
2221

2322

2423
The following commands download, create, and apply the namespace and Intel nginx deployment and service configuration:
@@ -32,33 +31,24 @@ kubectl apply -f intel_nginx.yaml
3231

3332
```
3433

35-
When pasted into your terminal, you will see output similar to the following for each command:
36-
3734
You will see output similar to:
3835

3936
```output
40-
curl -o intel_nginx.yaml https://raw.githubusercontent.com/geremyCohen/nginxOnAKS/refs/heads/main/intel_nginx.yaml
41-
kubectl apply -f intel_nginx.yaml
42-
% Total % Received % Xferd Average Speed Time Time Time Current
43-
Dload Upload Total Spent Left Speed
44-
100 55 100 55 0 0 1242 0 --:--:-- --:--:-- --:--:-- 1250
45-
namespace/nginx unchanged
46-
% Total % Received % Xferd Average Speed Time Time Time Current
47-
Dload Upload Total Spent Left Speed
48-
100 751 100 751 0 0 16192 0 --:--:-- --:--:-- --:--:-- 16326
49-
deployment.apps/nginx-intel-deployment unchanged
50-
service/nginx-intel-svc unchanged```
37+
namespace/nginx created
38+
configmap/nginx-intel-config created
39+
deployment.apps/nginx-intel-deployment created
40+
service/nginx-intel-svc created
5141
```
5242

5343
### Examining the deployment configuration
5444
Taking a closer look at the `intel_nginx.yaml` deployment file, you'll see some settings that ensure the deployment runs as we expect on the Intel node:
5545

56-
* The `nodeSelector` `agentpool`, with the value of `intel`. This ensures that the deployment only runs on Intel nodes, utilizing the amd64 version of the nginx container image.
46+
* The `nodeSelector` `kubernetes.io/arch: amd64`. This ensures that the deployment only runs on x86_64 nodes, utilizing the amd64 version of the nginx container image.
5747

5848
```yaml
5949
spec:
6050
nodeSelector:
61-
agentpool: intel
51+
kubernetes.io/arch: amd64
6252
```
6353
6454
* The A `sessionAffinity` tag, which removes sticky connections to the target pods. This removes persistent connections to the same pod on each request.
@@ -68,11 +58,20 @@ spec:
6858
sessionAffinity: None
6959
```
7060

61+
* The service selector uses both `app: nginx-multiarch` and `arch: intel` labels to target only Intel pods. This dual-label approach allows for both architecture-specific and multi-architecture service routing.
62+
63+
```yaml
64+
selector:
65+
app: nginx-multiarch
66+
arch: intel
67+
```
68+
7169
* Since the final goal is running nginx on multiple architectures, the deployment uses the standard nginx image from DockerHub. This image supports multiple architectures, including amd64 (Intel), arm64 (ARM), and others.
7270

7371
```yaml
74-
- image: nginx:latest
75-
name: nginx-multiarch
72+
containers:
73+
- image: nginx:latest
74+
name: nginx
7675
```
7776
{{% notice Note %}}
7877
Optionally, you can set the `default Namespace` to `nginx` to simplify future commands by removing the need to specify the `-nnginx` flag each time:
@@ -90,19 +89,29 @@ You've deployed the objects, so now it's time to verify everything is running as
9089
kubectl get nodes,pods,svc -nnginx
9190
```
9291

93-
Your output should be similar to the following, showing three nodes, one pod, and one service:
92+
Your output should be similar to the following, showing two nodes, one pod, and one service:
9493

9594
```output
96-
NAME STATUS ROLES AGE VERSION
97-
node/aks-amd-10099357-vmss000000 Ready <none> 10m v1.32.7
98-
node/aks-arm-49028967-vmss000000 Ready <none> 12m v1.32.7
99-
node/aks-intel-34846084-vmss000000 Ready <none> 15m v1.32.7
95+
NAME STATUS ROLES AGE VERSION
96+
node/aks-arm-56500727-vmss000000 Ready <none> 50m v1.32.7
97+
node/aks-intel-31372303-vmss000000 Ready <none> 55m v1.32.7
98+
99+
NAME READY STATUS RESTARTS AGE
100+
pod/nginx-intel-deployment-78bb8885fd-mw24f 1/1 Running 0 38s
101+
102+
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
103+
service/nginx-intel-svc LoadBalancer 10.0.226.250 20.80.128.191 80:30080/TCP 39s
104+
```
100105

101-
NAME READY STATUS RESTARTS AGE
102-
pod/nginx-intel-deployment-7d4c8f9b-xyz12 1/1 Running 0 2m
106+
You can also verify the ConfigMap was created:
103107

104-
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
105-
service/nginx-intel-svc LoadBalancer 10.0.45.123 20.1.2.3 80:30080/TCP 2m
108+
```bash
109+
kubectl get configmap -nnginx
110+
```
111+
112+
```output
113+
NAME DATA AGE
114+
nginx-intel-config 1 51s
106115
```
107116

108117
With the pods in a `Ready` state and the service showing a valid `External IP`, you're now ready to test the nginx Intel service.

0 commit comments

Comments
 (0)