Skip to content

Commit e6f6d6d

Browse files
committed
Migrate svcpolicies E2E test to docker
Signed-off-by: Derek Nola <[email protected]>
1 parent 21dcbb7 commit e6f6d6d

File tree

9 files changed

+209
-174
lines changed

9 files changed

+209
-174
lines changed

.github/workflows/e2e.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ jobs:
160160
strategy:
161161
fail-fast: false
162162
matrix:
163-
dtest: [autoimport, basics, bootstraptoken, cacerts, etcd, hardened, lazypull, skew, secretsencryption, snapshotrestore, token, upgrade]
163+
dtest: [autoimport, basics, bootstraptoken, cacerts, etcd, hardened, lazypull, skew, secretsencryption, snapshotrestore, svcpoliciesandfirewall, token, upgrade]
164164
arch: [amd64, arm64]
165165
exclude:
166166
- dtest: autoimport
@@ -209,7 +209,7 @@ jobs:
209209
cd ./tests/docker/${{ matrix.dtest }}
210210
211211
# These tests use rancher/systemd-node and have different flags.
212-
CI_TESTS="autoimport hardened secretsencryption snapshotrestore token"
212+
CI_TESTS="autoimport hardened secretsencryption snapshotrestore svcpoliciesandfirewall token"
213213
if [ ${{ matrix.dtest }} = "upgrade" ] || [ ${{ matrix.dtest }} = "skew" ]; then
214214
./${{ matrix.dtest }}.test -k3sImage=$K3S_IMAGE -channel=$CHANNEL
215215
elif [[ $CI_TESTS =~ ${{ matrix.dtest }} ]]; then

tests/client.go

+17
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,23 @@ func ParseNodes(kubeconfigFile string) ([]corev1.Node, error) {
6262
return nodes.Items, nil
6363
}
6464

65+
// Returns all internal IPs of the nodes in the cluster as map[node][ip]
66+
func GetInternalIPs(kubeconfigFile string) (map[string]string, error) {
67+
nodes, err := ParseNodes(kubeconfigFile)
68+
if err != nil {
69+
return nil, err
70+
}
71+
ips := make(map[string]string)
72+
for _, node := range nodes {
73+
for _, address := range node.Status.Addresses {
74+
if address.Type == corev1.NodeInternalIP {
75+
ips[node.Name] = address.Address
76+
}
77+
}
78+
}
79+
return ips, nil
80+
}
81+
6582
func ParsePods(kubeconfigFile string) ([]corev1.Pod, error) {
6683
clientSet, err := K8sClient(kubeconfigFile)
6784
if err != nil {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
apiVersion: v1
3+
kind: ConfigMap
4+
metadata:
5+
name: nginx-config
6+
data:
7+
default.conf: |
8+
server {
9+
listen 80;
10+
location /ip {
11+
return 200 "$remote_addr\n";
12+
}
13+
# Default location block to serve the default "Welcome to nginx" page
14+
location / {
15+
root /usr/share/nginx/html;
16+
index index.html;
17+
}
18+
}
19+
---
20+
apiVersion: apps/v1
21+
kind: Deployment
22+
metadata:
23+
name: test-loadbalancer
24+
spec:
25+
selector:
26+
matchLabels:
27+
k8s-app: nginx-app-loadbalancer
28+
replicas: 2
29+
template:
30+
metadata:
31+
labels:
32+
k8s-app: nginx-app-loadbalancer
33+
spec:
34+
containers:
35+
- name: nginx
36+
image: ranchertest/mytestcontainer
37+
ports:
38+
- containerPort: 80
39+
volumeMounts:
40+
- name: nginx-config-volume
41+
mountPath: /etc/nginx/conf.d
42+
volumes:
43+
- name: nginx-config-volume
44+
configMap:
45+
name: nginx-config
46+
---
47+
apiVersion: v1
48+
kind: Service
49+
metadata:
50+
name: nginx-loadbalancer-svc
51+
labels:
52+
k8s-app: nginx-app-loadbalancer
53+
spec:
54+
type: LoadBalancer
55+
ports:
56+
- port: 81
57+
targetPort: 80
58+
protocol: TCP
59+
name: http
60+
selector:
61+
k8s-app: nginx-app-loadbalancer
+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
labels:
5+
app: client
6+
name: client-deployment
7+
spec:
8+
replicas: 2
9+
selector:
10+
matchLabels:
11+
app: client
12+
template:
13+
metadata:
14+
labels:
15+
app: client
16+
spec:
17+
containers:
18+
- image: ranchertest/mytestcontainer
19+
imagePullPolicy: Always
20+
name: client-curl
21+
affinity:
22+
podAntiAffinity:
23+
requiredDuringSchedulingIgnoredDuringExecution:
24+
- labelSelector:
25+
matchExpressions:
26+
- key: app
27+
operator: In
28+
values:
29+
- client
30+
topologyKey: kubernetes.io/hostname
31+
---
32+
apiVersion: v1
33+
kind: Service
34+
metadata:
35+
name: client-curl
36+
labels:
37+
app: client
38+
service: client-curl
39+
spec:
40+
type: ClusterIP
41+
selector:
42+
app: client
43+
ports:
44+
- port: 8080

0 commit comments

Comments
 (0)