Skip to content

Commit cfc5a2e

Browse files
authored
Multinode support (#24)
Update action.yaml to support multiple nodes
1 parent c7aa7f6 commit cfc5a2e

File tree

4 files changed

+37
-12
lines changed

4 files changed

+37
-12
lines changed

.github/actions/create-local-test-infra-resources/action.yaml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ inputs:
88
oc_pod_timeout:
99
description: "Timeout for the `oc wait` command"
1010
default: 90s
11+
put_deployment_name:
12+
description: "The expected value of the test deployment name"
13+
default: test
1114
put_pod_label_app:
1215
description: "The expected value of the test pod's `app` label"
1316
default: test
@@ -33,23 +36,27 @@ runs:
3336
run: oc config set-context $(oc config current-context) --namespace=${{ inputs.oc_namespace }}
3437
shell: bash
3538

36-
- name: (PUT) Wait for the test pod to be ready
37-
run: oc wait pod --for=condition=ready -l "app=${{ inputs.put_pod_label_app }}" --timeout=${{ inputs.oc_pod_timeout }}
39+
- name: (PUT) Wait for the test deployment to be available
40+
run: oc wait deployment ${{ inputs.put_deployment_name }} --for=condition=available --timeout=${{ inputs.oc_pod_timeout }}
3841
shell: bash
3942

4043
- name: (TPP) Wait for the partner pod to be ready
4144
run: oc wait pod --for=condition=ready -l "app=${{ inputs.tpp_pod_label_app }}" --timeout=${{ inputs.oc_pod_timeout }}
4245
shell: bash
4346

44-
- name: (PUT) Ensure only one pod with the label is present
45-
run: '[[ $(oc get pods -l "app=${{ inputs.put_pod_label_app }}" -o name | wc -l) -eq "1" ]]'
47+
- name: Display all pods in namespace
48+
run: oc get pods -o wide
49+
shell: bash
50+
51+
- name: (PUT) Ensure that two pods with the label are present
52+
run: '[[ $(oc get pods -l "app=${{ inputs.put_pod_label_app }}" -o name | wc -l) -eq "2" ]]'
4653
shell: bash
4754

4855
- name: (TPP) Ensure only one pod with the label is present
4956
run: '[[ $(oc get pods -l "app=${{ inputs.tpp_pod_label_app }}" -o name | wc -l) -eq "1" ]]'
5057
shell: bash
5158

52-
- name: (PUT) Discover the name of the test pod
59+
- name: (PUT) Discover the name of the first test pod
5360
run: |
5461
PUT_POD_NAME=$(oc get pods -l 'app=${{ inputs.put_pod_label_app }}' -o jsonpath='{.items[0].metadata.name}')
5562
echo "${{ inputs.put_pod_name_env_var }}=$PUT_POD_NAME" >> $GITHUB_ENV

.github/actions/start-minikube/action.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ inputs:
66
minikube_driver:
77
default: docker
88
minikube_extra_options:
9-
default: '--embed-certs'
9+
default: '--embed-certs --nodes 2'
1010
oc_kcm_timeout:
1111
default: 5m
1212

@@ -41,6 +41,10 @@ runs:
4141
- name: Display kube-system pods
4242
run: oc get pods -n kube-system -o wide
4343
shell: bash
44+
45+
- name: Display cluster nodes
46+
run: oc get nodes
47+
shell: bash
4448

4549
- name: Display a friendly summary message
4650
run: echo "TNF-compatible minikube cluster is ready to go! Have fun!"

README.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,14 @@ In order to run the local test setup, the following dependencies are needed:
9191
To start minikube, issue the following command:
9292

9393
```shell-script
94-
minikube start --embed-certs --driver="virtualbox"
94+
minikube start --embed-certs --driver="virtualbox" --nodes 2
9595
```
9696

9797
The `--embed-certs` flag will cause minikube to embed certificates directly in its kubeconfig file.
9898
This will allow the minikube cluster to be reached directly from the container without the need of binding additional volumes for certificates.
9999

100+
The `--nodes 2` flag creates a cluster with one master node and one worker node. This is to support anti-affinity test cases.
101+
100102
To avoid having to specify this flag, set the `embed-certs` configuration key:
101103

102104
```shell-script
@@ -120,11 +122,12 @@ To verify `partner` and `test` pods are running:
120122
oc get pods -n tnf -o wide
121123
```
122124

123-
You should see something like this:
125+
You should see something like this (note that the 2 test pods are running on different nodes due to a anti-affinity rule):
124126
```shell-script
125-
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
126-
partner 1/1 Running 0 22m 172.17.0.3 minikube <none> <none>
127-
test 1/1 Running 0 22m 172.17.0.4 minikube <none> <none>
127+
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
128+
partner-68cf756959-tp2c5 1/1 Running 0 110s 10.244.1.7 minikube-m02 <none> <none>
129+
test-7799cc9677-6d8qz 1/1 Running 0 110s 10.244.1.8 minikube-m02 <none> <none>
130+
test-7799cc9677-rv8nv 1/1 Running 0 110s 10.244.0.5 minikube <none> <none>
128131
```
129132

130133
To avoid having to specify the `tnf` namespace with the `-n` option, set the namespace for the current context:

local-test-infra/local-pod-under-test.yaml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ metadata:
55
name: test
66
namespace: tnf
77
spec:
8-
replicas: 1
8+
replicas: 2
99
selector:
1010
matchLabels:
1111
app: test
@@ -28,3 +28,14 @@ spec:
2828
limits:
2929
memory: 512Mi
3030
cpu: 0.25
31+
affinity:
32+
podAntiAffinity:
33+
requiredDuringSchedulingIgnoredDuringExecution:
34+
- labelSelector:
35+
matchExpressions:
36+
- key: app
37+
operator: In
38+
values:
39+
- test
40+
topologyKey: "kubernetes.io/hostname"
41+

0 commit comments

Comments
 (0)