I'm currently creating a Kubernetes cluster in Azure Kubernetes for a production environment. In my cluster, I will have single node in the node pool - pool1.
Now, I want to deploy an application with 2 replicas as shown below
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment-1
spec:
selector:
matchLabels:
app: nginx
replicas: 2
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.16.1
on which port the application will listen to? as two pods will be deployed on the same node, how does the port will be allocated?
Update: As suggested, have updated the manifest with service definition.
apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2
kind: Deployment
metadata:
name: nginx-deployment
spec:
selector:
matchLabels:
app: nginx
replicas: 2
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.16.1
ports:
- containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
name: web
spec:
selector:
app: nginx
ports:
- protocol: TCP
port: 80
targetport: 80
type: LoadBalancer