-
Notifications
You must be signed in to change notification settings - Fork 0
/
test
executable file
·130 lines (93 loc) · 3.54 KB
/
test
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#!/bin/bash
set -e
HERE=$(dirname "$(readlink --canonicalize "$BASH_SOURCE")")
. "$HERE/../scripts/_env"
. "$HERE/_env"
. "$ROOT/scripts/_trap"
PROVIDER=${PROVIDER:-simple}
NAMESPACE=${NAMESPACE:-workspace}
REPOSITORY=${REPOSITORY:-catalog}
if [ "$PROVIDER" == openshift ]; then
REPOSITORY=$NAMESPACE
fi
m "provider: $PROVIDER"
mkdir --parents "$WORKSPACE"
m 'cleaning up...'
kubectl create namespace "$NAMESPACE" || true
kubectl config set-context --current --namespace="$NAMESPACE"
kubectl delete --ignore-not-found=true pods hello-world
kubectl delete --ignore-not-found=true secret reposure-simple-htpasswd
kubectl delete --ignore-not-found=true secret reposure-simple-authorization
reposure operator uninstall --wait -v
reposure simple uninstall --wait -v
kubectl delete events --all
if [ "$1" == '-b' ]; then
"$ROOT/scripts/build-container-images"
"$ROOT/scripts/publish-container-images"
fi
m 'installing operator...'
if [ "$PROVIDER" == minikube ] || [ "$PROVIDER" == openshift ]; then
reposure operator install --role=view --wait -v
else
reposure operator install --wait -v
fi
if [ "$PROVIDER" == simple ]; then
m 'creating htpasswd secret...'
rm --recursive --force "$WORKSPACE/htpasswd"
# Note: Docker registry requires bcrypt
# https://docs.docker.com/registry/configuration/#htpasswd
htpasswd -cbB "$WORKSPACE/htpasswd" username password
kubectl create secret generic reposure-simple-htpasswd \
--from-file="$WORKSPACE/htpasswd"
m 'installing simple registry...'
# Authentication requires Cert-Manager
# Authorization requires "reposure-simple-htpasswd" secret
reposure simple install --authentication --authorization --wait
m 'creating authorization secret...'
HOST=$(reposure simple host)
kubectl create secret docker-registry reposure-simple-authorization \
--docker-server="$HOST" \
--docker-username=username \
--docker-password=password
fi
m 'creating registry...'
if [ "$PROVIDER" == simple ]; then
reposure registry create default --provider="$PROVIDER" --authorization-secret=reposure-simple-authorization --wait -v
else
reposure registry create default --provider="$PROVIDER" --wait -v
fi
m "pushing text file to \"$REPOSITORY/hello\""
echo 'hello world' > "$WORKSPACE/hello.txt"
reposure image push default "$REPOSITORY/hello" "$WORKSPACE/hello.txt" -v
sleep 1
m "pulling text file from \"$REPOSITORY/hello\""
reposure image pull default "$REPOSITORY/hello" --unpack -v
m 'creating container image tarball'
HOST=$(reposure registry info default host)
PUBLIC_IMAGE=docker.io/paulbouwer/hello-kubernetes:1.8
PRIVATE_IMAGE=$HOST/$REPOSITORY/myimage
IMAGE_FILE=$WORKSPACE/myimage.tar
podman rmi "$PRIVATE_IMAGE" || true
podman rmi "$PUBLIC_IMAGE" || true
podman pull "$PUBLIC_IMAGE"
podman tag "$PUBLIC_IMAGE" "$PRIVATE_IMAGE"
rm --force "$IMAGE_FILE"
podman save "$PRIVATE_IMAGE" --output "$IMAGE_FILE"
m "pushing container image tarball to \"$REPOSITORY/myimage\""
reposure image push default "$REPOSITORY/myimage" "$IMAGE_FILE" -v
sleep 8
m "pulling container image tarball from \"$REPOSITORY/myimage\""
reposure image pull default "$REPOSITORY/myimage" -v > "$WORKSPACE/myimage-pulled.tar"
m "creating \"hello-world\" pod"
if [ "$PROVIDER" == simple ]; then
IMAGE=$PRIVATE_IMAGE SECRET=reposure-simple-authorization envsubst < "$ROOT/assets/kubernetes/hello-world-with-secret.yaml" | \
kubectl apply -f -
else
IMAGE=$PRIVATE_IMAGE envsubst < "$ROOT/assets/kubernetes/hello-world.yaml" | \
kubectl apply -f -
fi
m 'listing images'
# Not permitted on OpenShift
if [ "$PROVIDER" != openshift ]; then
reposure image list default -v
fi