-
Notifications
You must be signed in to change notification settings - Fork 2
/
cf_deployment_warden
executable file
·100 lines (83 loc) · 3.5 KB
/
cf_deployment_warden
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
#!/bin/bash -exu
## Install and create Bosh lite under vbox then deploy cf-deployment on top of it
#requires vbox
#requires bosh2 cli
#requires cf cli
#Set environment variables for installation directories
source ./environment/bosh_env.sh
##Create Bosh-lite
#source for these steps: http://bosh.io/docs/bosh-lite.html
#clone bosh-deployment
if [ -d "$BOSH_LITE_DIRECTORY" ]
then
(cd $BOSH_LITE_DIRECTORY; git pull)
else
git clone https://github.com/cloudfoundry/bosh-deployment $BOSH_LITE_DIRECTORY
fi
#set up your workspace
if [ -d "$DEPLOYMENT_DIRECTORY" ]
then
echo "deployment directory exists"
awk '!/current_manifest_sha/' $DEPLOYMENT_DIRECTORY/state.json > temp && mv temp $DEPLOYMENT_DIRECTORY/state.json #using awk for portablity
else
mkdir -p $DEPLOYMENT_DIRECTORY
fi
#edit deployment manifest
#Raise the RAM for more wiggle room
awk '{ gsub("memory: 4096","memory: 6144"); print $0 }' $BOSH_LITE_DIRECTORY/virtualbox/cpi.yml > temp.cpi && mv temp.cpi $BOSH_LITE_DIRECTORY/virtualbox/cpi.yml
#TODO: raise disk
#Raise CPUs for more efficiency
awk '{ gsub("cpus: 4","cpus: 6"); print $0 }' $BOSH_LITE_DIRECTORY/virtualbox/cpi.yml > temp.cpi && mv temp.cpi $BOSH_LITE_DIRECTORY/virtualbox/cpi.yml
#create bosh director
bosh create-env $BOSH_LITE_DIRECTORY/bosh.yml \
--state $DEPLOYMENT_DIRECTORY/state.json \
-o $BOSH_LITE_DIRECTORY/virtualbox/cpi.yml \
-o $BOSH_LITE_DIRECTORY/virtualbox/outbound-network.yml \
-o $BOSH_LITE_DIRECTORY/bosh-lite.yml \
-o $BOSH_LITE_DIRECTORY/uaa.yml \
-o $BOSH_LITE_DIRECTORY/misc/config-server.yml \
-o $BOSH_LITE_DIRECTORY/jumpbox-user.yml \
--vars-store $DEPLOYMENT_DIRECTORY/creds.yml \
-v director_name="Bosh Lite Director" \
-v internal_ip=192.168.56.6 \
-v internal_gw=192.168.56.1 \
-v internal_cidr=192.168.56.0/24 \
-v outbound_network_name=NatNetwork
#Set route
sudo ip route add 10.244.0.0/16 via 192.168.56.6
#Set bosh log-in info
source ./environment/bosh_login.sh
#confirm works
bosh -e vbox env
#Enable BOSH DNS
bosh -e vbox update-runtime-config $BOSH_LITE_DIRECTORY/runtime-configs/dns.yml --vars-store $DEPLOYMENT_DIRECTORY/bosh-dns-certs.yml -n
##Deploy cf-deployment
#source for these steps(https://github.com/cloudfoundry/cf-deployment#deploying-cf)
if [ -d "$DEPLOYMENT_DIRECTORY/cf-deployment" ]
then
(cd $DEPLOYMENT_DIRECTORY/cf-deployment; git pull)
else
git clone https://github.com/cloudfoundry/cf-deployment $DEPLOYMENT_DIRECTORY/cf-deployment
fi
#TODO: edit deployment manifest
#TODO: reduce disk sizes
#TODO: reduce memory sizes
#configure cloud config (this file need to be tweaked)
bosh -e vbox update-cloud-config $DEPLOYMENT_DIRECTORY/cf-deployment/iaas-support/bosh-lite/cloud-config.yml -n
#upload the latest stemcell
CF_STEMCELL_VERSION=`bosh int $DEPLOYMENT_DIRECTORY/cf-deployment/cf-deployment.yml --path /stemcells | grep version | cut -f2 -d\"`
bosh -e vbox upload-stemcell https://bosh.io/d/stemcells/bosh-warden-boshlite-ubuntu-xenial-go_agent?v=$CF_STEMCELL_VERSION
#deploy the environment
bosh -e vbox -d cf deploy $DEPLOYMENT_DIRECTORY/cf-deployment/cf-deployment.yml \
-o $DEPLOYMENT_DIRECTORY/cf-deployment/operations/bosh-lite.yml \
-o $DEPLOYMENT_DIRECTORY/cf-deployment/operations/scale-to-one-az.yml \
--vars-store $DEPLOYMENT_DIRECTORY/cf-deployment/deployment-vars.yml \
-v system_domain=bosh-lite.com \
--recreate \
--fix \
-n
#run smoketests
bosh -e vbox -d cf run-errand smoke-tests
#set env vars for cf logins
#if this fails, you didn't set your routes 99% of the time
source ./environment/cf_env.sh