-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathmetallb.sh
executable file
·63 lines (54 loc) · 1.64 KB
/
metallb.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
# SPDX-license-identifier: Apache-2.0
##############################################################################
# Copyright (c) 2021
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
set -o errexit
set -o nounset
set -o pipefail
# shellcheck source=tests/_functions.sh
source _functions.sh
# shellcheck source=tests/_assertions.sh
source _assertions.sh
function cleanup {
kubectl delete service nginx --ignore-not-found
kubectl delete ipaddresspools metallb-test-cidr --ignore-not-found
}
trap cleanup EXIT
# Setup
# editorconfig-checker-disable
cat <<EOF | kubectl apply -f -
apiVersion: metallb.io/v1beta1
kind: IPAddressPool
metadata:
name: metallb-test-cidr
namespace: metallb-system
spec:
addresses:
- 172.18.0.0/20
EOF
# editorconfig-checker-enable
# Test
info "===== Test started ====="
# editorconfig-checker-disable
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: Service
metadata:
name: nginx
spec:
ports:
- port: 80
targetPort: 80
selector:
app: nginx
type: LoadBalancer
EOF
# editorconfig-checker-enable
assert_non_empty "$(kubectl get svc nginx -o jsonpath='{.status.loadBalancer.ingress[0].ip}')" "IP address wasn't assigned to nginx service"
assert_are_equal "$(kubectl get svc nginx -o jsonpath='{.status.loadBalancer.ingress[0].ip}')" "172.18.0.0" "IP address wasn't different than expected"
info "===== Test completed ====="