Skip to content

Commit 1470006

Browse files
committed
Add podaffinity to pack pods into nodes
1 parent a9e0bf1 commit 1470006

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

applications/python-echo-server/deploy/manifest.yaml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ metadata:
77
name: python-echo-server
88
namespace: python-echo-server
99
spec:
10-
replicas: 1
10+
replicas: 4
1111
selector:
1212
matchLabels:
1313
app: python-echo-server
@@ -16,6 +16,18 @@ spec:
1616
labels:
1717
app: python-echo-server
1818
spec:
19+
affinity:
20+
podAffinity:
21+
preferredDuringSchedulingIgnoredDuringExecution:
22+
- weight: 100
23+
podAffinityTerm:
24+
labelSelector:
25+
matchExpressions:
26+
- key: app
27+
operator: In
28+
values:
29+
- python-echo-server
30+
topologyKey: "kubernetes.io/hostname"
1931
containers:
2032
- env:
2133
- name: PORT

applications/python-echo-server/main.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ def ping():
3333
def echo():
3434
kubernetes_info = [
3535
"Kubernetes Info: ",
36+
"\tHostname: " + os.environ.get("HOSTNAME", "N/A"),
3637
"\tCluster Name: " + os.environ.get("CLUSTER_NAME", "N/A"),
3738
"\tNamespace: " + os.environ.get("POD_NAMESPACE", "N/A"),
3839
"\tNode Name: " + os.environ.get("NODE_NAME", "N/A"),

0 commit comments

Comments
 (0)