Created
June 12, 2025 22:54
-
-
Save dalthonmh/e72243749d9a0ea5158d6814ac0c77a8 to your computer and use it in GitHub Desktop.
Test networking in Kubernetes with two Nginx pods on two different nodes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: v1 | |
kind: Pod | |
metadata: | |
name: nginx-pod-node1 | |
labels: | |
app: nginx-test | |
node: node1 | |
spec: | |
nodeSelector: | |
kubernetes.io/hostname: spacex | |
containers: | |
- name: nginx | |
image: nginx:alpine | |
ports: | |
- containerPort: 80 | |
env: | |
- name: NODE_NAME | |
value: "spacex" | |
--- | |
apiVersion: v1 | |
kind: Pod | |
metadata: | |
name: nginx-pod-node2 | |
labels: | |
app: nginx-test | |
node: node2 | |
spec: | |
nodeSelector: | |
kubernetes.io/hostname: falcon9 | |
containers: | |
- name: nginx | |
image: nginx:alpine | |
ports: | |
- containerPort: 80 | |
env: | |
- name: NODE_NAME | |
value: "falcon9" | |
--- | |
apiVersion: v1 | |
kind: Service | |
metadata: | |
name: nginx-service-node1 | |
spec: | |
selector: | |
app: nginx-test | |
node: node1 | |
ports: | |
- port: 80 | |
targetPort: 80 | |
type: ClusterIP | |
--- | |
apiVersion: v1 | |
kind: Service | |
metadata: | |
name: nginx-service-node2 | |
spec: | |
selector: | |
app: nginx-test | |
node: node2 | |
ports: | |
- port: 80 | |
targetPort: 80 | |
type: ClusterIP |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment