Skip to content

Commit d45bc4d

Browse files
committed
Fix build by using generated password
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <[email protected]>
1 parent bd29b93 commit d45bc4d

File tree

4 files changed

+12
-40
lines changed

4 files changed

+12
-40
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,4 @@ of_kind_portforward.pid
3333

3434
jwt_key
3535
jwt_key.pub
36+
/*.pid

contrib/create_dev.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,14 @@ contrib/create_cluster.sh || exit 0;
77
contrib/deploy.sh
88
contrib/run_function.sh
99

10+
PASSWORD=$(kubectl get secret -n openfaas basic-auth -o=go-template='{{index .data "basic-auth-password"}}' | base64 --decode)
11+
12+
1013
cd "$(git rev-parse --show-toplevel)"
1114
echo ""
1215
echo ""
1316
echo "Local dev cluster details:"
1417
printf '%-10s:\t %s\n' 'Web UI' 'http://localhost:8080/ui'
1518
printf '%-10s:\t %s\n' 'User' 'admin'
16-
printf '%-10s:\t %s\n' 'Password' "$(cat password.txt)"
17-
printf '%-10s:\t %s\n' 'CLI Login' "faas-cli login --username admin --password $(cat password.txt)"
19+
printf '%-10s:\t %s\n' 'Password' '$PASSWORD'
20+
printf '%-10s:\t %s\n' 'CLI Login' "faas-cli login --username admin --password $PASSWORD"

contrib/deploy.sh

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -3,39 +3,11 @@
33
set -e
44

55
DEVENV=${OF_DEV_ENV:-kind}
6-
OPERATOR=${OPERATOR:-0}
76

87
echo ""
98
echo "Applying namespaces"
109
kubectl --context "kind-$DEVENV" apply -f ./namespaces.yml
1110

12-
sha_cmd="sha256sum"
13-
if [ ! -x "$(command -v $sha_cmd)" ]; then
14-
sha_cmd="shasum -a 256"
15-
fi
16-
17-
if [ -x "$(command -v $sha_cmd)" ]; then
18-
sha_cmd="shasum"
19-
fi
20-
21-
PASSWORD_EXISTS=$(kubectl get secret -n openfaas basic-auth | wc -c)
22-
if [ $PASSWORD_EXISTS -eq 0 ]; then
23-
PASSWORD=$(head -c 16 /dev/urandom| $sha_cmd | cut -d " " -f 1)
24-
echo -n $PASSWORD > password.txt
25-
26-
kubectl --context "kind-$DEVENV" -n openfaas create secret generic basic-auth \
27-
--from-literal=basic-auth-user=admin \
28-
--from-literal=basic-auth-password="$PASSWORD"
29-
else
30-
PASSWORD=$(kubectl get secret -n openfaas basic-auth -o=go-template='{{index .data "basic-auth-password"}}' | base64 --decode)
31-
echo -n $PASSWORD > password.txt
32-
fi
33-
34-
CREATE_OPERATOR=false
35-
if [ "${OPERATOR}" == "1" ]; then
36-
CREATE_OPERATOR="true"
37-
fi
38-
3911
echo ""
4012
echo "Waiting for helm install to complete."
4113

@@ -44,16 +16,7 @@ helm upgrade \
4416
--install \
4517
openfaas \
4618
./chart/openfaas \
47-
--namespace openfaas \
48-
--set basic_auth=true \
49-
--set functionNamespace=openfaas-fn \
50-
--set operator.create=$CREATE_OPERATOR
51-
52-
if [ "${OPERATOR}" == "1" ]; then
53-
54-
kubectl --context "kind-$DEVENV" patch -n openfaas deploy/gateway \
55-
-p='[{"op": "add", "path": "/spec/template/spec/containers/1/command", "value": ["./faas-netes", "-operator=true"]} ]' --type=json
56-
fi
19+
--namespace openfaas
5720

5821
kubectl --context "kind-$DEVENV" rollout status deploy/prometheus -n openfaas
5922
kubectl --context "kind-$DEVENV" rollout status deploy/gateway -n openfaas

contrib/run_function.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ kubectl --context "kind-$DEVENV" port-forward deploy/gateway -n openfaas 8080:80
2424
# port-forward needs some time to start
2525
sleep 10
2626

27+
28+
echo "Using existing password for OpenFaaS gateway retrieved from Kubernetes."
29+
PASSWORD=$(kubectl get secret -n openfaas basic-auth -o=go-template='{{index .data "basic-auth-password"}}' | base64 --decode)
30+
echo -n $PASSWORD > password.txt
31+
2732
export OPENFAAS_URL=http://127.0.0.1:8080
2833

2934
# Login into the gateway

0 commit comments

Comments
 (0)