-
Notifications
You must be signed in to change notification settings - Fork 5
/
deploy-resources.sh
executable file
·77 lines (66 loc) · 2.57 KB
/
deploy-resources.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
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/usr/bin/env bash
set -o errexit
set -o pipefail
set -o nounset
# set -o xtrace
# Set magic variables
__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
__root="$(cd "$(dirname "${__dir}")" && pwd)"
__target="${__root}/target"
__gitremote="$(git remote get-url origin)"
__infra_repo="${__gitremote/baaas-decision-fleet-shard/baaas-infra}"
__infra_path="${__target}/baaas-infra"
__pipeline_resources="${__infra_path}/base/baaas-dfs/resources/build-pipeline"
__credentials="${__dir}/user-credentials.sh"
__pull_secret="${__dir}/user-pull-secret.yaml"
deploy_crds () {
kubectl apply -f "${__root}"/crd || true
}
create_cms () {
kubectl create cm baaas-dfs-build-application-kafka-props --from-file=application.properties="${__pipeline_resources}"/application-kafka.properties || true
kubectl create cm baaas-dfs-build-application-props --from-file="${__pipeline_resources}"/application.properties || true
kubectl create cm baaas-dfs-build-pom-kafka-xml --from-file=pom.xml="${__pipeline_resources}"/pom-kafka.xml || true
kubectl create cm baaas-dfs-build-pom-xml --from-file="${__pipeline_resources}"/pom.xml || true
kubectl create cm baaas-dfs-build-dockerfile --from-file="${__pipeline_resources}"/Dockerfile || true
}
create_pipeline () {
kubectl apply -f "${__pipeline_resources}"/pipeline.yml || true
kubectl apply -f "${__pipeline_resources}"/pvc.yml || true
}
create_user_credentials () {
# from user-credentials.sh file
kubectl create secret generic baaas-dfs-build-aws-credentials \
--from-literal=AWS_ACCESS_KEY_ID="${AWS_ACCESS_KEY_ID}" \
--from-literal=AWS_DEFAULT_REGION="${AWS_DEFAULT_REGION}" \
--from-literal=AWS_SECRET_ACCESS_KEY="${AWS_SECRET_ACCESS_KEY}" || true
kubectl create secret generic baaas-dfs-kafka-credentials \
--from-literal=bootstrapservers=${KAFKA_SERVER} \
--from-literal=clientid=${KAFKA_CLIENT_ID} \
--from-literal=clientsecret=${KAFKA_CLIENT_SECRET} || true
}
create_pull_secret () {
if [ -f "${__pull_secret}" ]
then
kubectl apply -f "${__pull_secret}" || true
secret_name="$(grep name "${__pull_secret}" | awk '{print$2}')"
kubectl patch serviceaccount default -p "{\"imagePullSecrets\": [{\"name\": \"${secret_name}\"}]}" || true
else
echo "Pull secret file not found. Assuming CRC installation."
fi
}
if [ ! -f "${__credentials}" ]
then
echo ERROR missing "${__credentials}" file
exit 1
fi
source "${__credentials}"
if [ ! -d "${__infra_path}" ]
then
mkdir "${__target}"
git clone "${__infra_repo}" "${__infra_path}"
fi
deploy_crds
create_cms
create_pull_secret
create_pipeline
create_user_credentials