I deployed a Kubernetes deployment with 3 pod replicas using the following yaml:
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx
labels:
app: nginx
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx
ports:
- containerPort: 80
The command I used was kubectl create -f nginx-deployment.yaml
I then deployed a NodePort service using the following yaml:
apiVersion: v1
kind: Service
metadata:
name: ngnix-service
spec:
selector:
app: nginx
type: NodePort
ports:
- protocol: TCP
port: 80
targetPort: 80
The command I used was kubectl create -f nginx-service.yaml
Output of kubectl get pods -o wide
(master node):
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
nginx-5rnn9 1/1 Running 0 18s 10.244.6.7 5dd0e0ff-a0b4-4230-b529-72a0349c4c87-node6
nginx-p54r6 1/1 Running 0 9m43s 10.244.3.8 9c41d0cd-a133-4922-96cf-681c3c2ba410-node3
nginx-r66wv 1/1 Running 0 9m36s 10.244.1.10 1c26fd12-c0c3-43af-96d5-3b725c5e5eff-node1
Output of kubectl get svc -o wide
(master):
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR
kubernetes ClusterIP 10.96.0.1 443/TCP 20h
ngnix-service NodePort 10.109.68.106 80:32466/TCP 4s app=nginx
I am having intermittent issues with the pods: when I send web requests to the webservers deployed at the pods, they frequently timeout. Note that if deploy only one replica, I do not have such issues.
To test the pods, I’m logging directly to the nodes, for example node1. Inside the node, I’m issuing wget 127.0.0.1:32466
command. The result of the command is not stable. On the example below, out of four wget requests, only 2 were successful.
ubuntu@1c26fd12-c0c3-43af-96d5-3b725c5e5eff-node1:~$ wget 127.0.0.1:32466
–2024-05-17 16:03:32– http://127.0.0.1:32466/
Connecting to 127.0.0.1:32466… ^C
ubuntu@1c26fd12-c0c3-43af-96d5-3b725c5e5eff-node1:~$ wget 127.0.0.1:32466
–2024-05-17 16:03:34– http://127.0.0.1:32466/
Connecting to 127.0.0.1:32466… connected.
HTTP request sent, awaiting response… 200 OK
Length: 615 [text/html]
Saving to: ‘index.html.4’index.html.4 100%[========================================================>] 615 –.-KB/s in 0s
2024-05-17 16:03:34 (214 MB/s) – ‘index.html.4’ saved [615/615]
ubuntu@1c26fd12-c0c3-43af-96d5-3b725c5e5eff-node1:~$ wget 127.0.0.1:32466
–2024-05-17 16:03:36– http://127.0.0.1:32466/
Connecting to 127.0.0.1:32466… ^C
ubuntu@1c26fd12-c0c3-43af-96d5-3b725c5e5eff-node1:~$ wget 127.0.0.1:32466
–2024-05-17 16:03:37– http://127.0.0.1:32466/
Connecting to 127.0.0.1:32466… connected.
HTTP request sent, awaiting response… 200 OK
Length: 615 [text/html]
Saving to: ‘index.html.5’index.html.5 100%[========================================================>] 615 –.-KB/s in 0s
2024-05-17 16:03:37 (22.4 MB/s) – ‘index.html.5’ saved [615/615]