Skip to content

Commit 2b11d29

Browse files
authored
Move to bosh lites from shepherd envs (#3539)
1 parent fb19e7a commit 2b11d29

File tree

18 files changed

+399
-468
lines changed

18 files changed

+399
-468
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
variable "dns_zone_name" {}
2+
variable "system_domain_suffix" {}
3+
4+
resource "google_dns_record_set" "default" {
5+
name = "*.${var.env_id}.${var.system_domain_suffix}."
6+
type = "A"
7+
ttl = 300
8+
9+
managed_zone = var.dns_zone_name
10+
rrdatas = [ google_compute_address.bosh-director-ip.address ]
11+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
system_domain_suffix="app-runtime-interfaces.ci.cloudfoundry.org"
2+
dns_zone_name="app-runtime-interfaces"
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
# Configure sizes for bosh-lite on gcp
3+
- type: replace
4+
path: /resource_pools/name=vms/cloud_properties/machine_type
5+
value: n2-standard-8
6+
- type: replace
7+
path: /disk_pools/name=disks/disk_size
8+
value: 250000
9+
- type: replace
10+
path: /resource_pools/name=vms/cloud_properties/root_disk_size_gb
11+
value: 32

.github/ops-files/diego-cell-instances.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,3 @@
22
- type: replace
33
path: /instance_groups/name=diego-cell/instances
44
value: 4
5-
6-
- type: replace
7-
path: /instance_groups/name=isolated-diego-cell/jobs/name=rep/properties?/set_kernel_parameters
8-
value: false
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
- type: replace
3+
path: /instance_groups/name=uaa/jobs/name=route_registrar/properties?/route_registrar/routes/name=uaa/registration_interval
4+
value: 30s
5+
- type: replace
6+
path: /instance_groups/name=api/jobs/name=route_registrar/properties?/route_registrar/routes/name=api/registration_interval
7+
value: 30s
8+
- type: replace
9+
path: /instance_groups/name=api/jobs/name=route_registrar/properties?/route_registrar/routes/name=policy-server/registration_interval
10+
value: 30s
11+
- type: remove
12+
path: /instance_groups/name=api/jobs/name=route_registrar/properties?/route_registrar/routes/name=api/health_check/timeout
Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
name: Create environment
2+
on:
3+
workflow_dispatch:
4+
workflow_call:
5+
outputs:
6+
env-name:
7+
value: ${{ jobs.create-env.outputs.envName }}
8+
description: "Name of the created environment"
9+
10+
env:
11+
BBL_IAAS: gcp
12+
BBL_GCP_REGION: us-east1
13+
BBL_GCP_SERVICE_ACCOUNT_KEY: ${{ secrets.GCP_CREDENTIALS_JSON }}
14+
BOSH_DEPLOYMENT: cf
15+
BOSH_NON_INTERACTIVE: true
16+
BBL_CLI_VERSION: ${{ vars.BBL_CLI_VERSION }}
17+
BOSH_CLI_VERSION: ${{ vars.BOSH_CLI_VERSION }}
18+
CREDHUB_CLI_VERSION: ${{ vars.CREDHUB_CLI_VERSION }}
19+
20+
jobs:
21+
create-env:
22+
runs-on: ubuntu-latest
23+
outputs:
24+
envName: ${{steps.setup-bbl-env.outputs.envName}}
25+
steps:
26+
- name: Install Tools
27+
run: |
28+
go version
29+
30+
install_location=/usr/local/bin
31+
32+
sudo curl https://github.com/cloudfoundry/bosh-bootloader/releases/download/v${BBL_CLI_VERSION}/bbl-v${BBL_CLI_VERSION}_linux_amd64 --silent --location --output $install_location/bbl
33+
sudo chmod +x $install_location/bbl
34+
bbl --version
35+
36+
sudo curl https://github.com/cloudfoundry/bosh-cli/releases/download/v${BOSH_CLI_VERSION}/bosh-cli-${BOSH_CLI_VERSION}-linux-amd64 --silent --output $install_location/bosh --location
37+
sudo chmod +x $install_location/bosh
38+
bosh --version
39+
40+
sudo curl https://github.com/cloudfoundry/credhub-cli/releases/download/${CREDHUB_CLI_VERSION}/credhub-linux-amd64-${CREDHUB_CLI_VERSION}.tgz --silent --location --output /tmp/credhub.tgz
41+
sudo tar -xzf /tmp/credhub.tgz -C $install_location
42+
sudo chmod +x $install_location/credhub
43+
credhub --version
44+
45+
sudo apt update
46+
sudo apt install -y build-essential unzip wamerican
47+
48+
- name: Checkout bosh-bootloader
49+
uses: actions/checkout@v4
50+
with:
51+
repository: cloudfoundry/bosh-bootloader
52+
path: bosh-bootloader
53+
54+
- name: Checkout cli
55+
uses: actions/checkout@v4
56+
with:
57+
path: cli
58+
59+
- name: Setup bbl
60+
id: setup-bbl-env
61+
run: |
62+
env_name="$(grep '^.\{1,4\}$' /usr/share/dict/words |
63+
shuf -n1 |
64+
tr -dc '[:alnum:]\n\r' |
65+
tr '[:upper:]' '[:lower:]')"
66+
67+
if [ ! -z "${env_name}" ]; then
68+
env_name=cli-${env_name}
69+
mkdir -p $env_name/bbl-state
70+
fi
71+
echo "Bbl environment name: $env_name"
72+
echo "envName=$env_name" >> $GITHUB_OUTPUT
73+
74+
- name: Create bbl env
75+
run: |
76+
env_name=${{ steps.setup-bbl-env.outputs.envName }}
77+
cd $env_name/bbl-state
78+
79+
cp -R ${GITHUB_WORKSPACE}/bosh-bootloader/plan-patches/bosh-lite-gcp/* .
80+
bbl plan --name $env_name
81+
cp ${GITHUB_WORKSPACE}/cli/.github/bosh-lite-files/bosh-lite-dns.tf terraform/
82+
cp ${GITHUB_WORKSPACE}/cli/.github/bosh-lite-files/bosh-lite.tfvars vars/
83+
cp ${GITHUB_WORKSPACE}/cli/.github/ops-files/bosh-lite-vm-type.yml bosh-deployment/gcp/
84+
bbl up
85+
86+
- name: Authenticate to Google Cloud
87+
uses: google-github-actions/auth@v2
88+
with:
89+
credentials_json: ${{ secrets.GCP_CREDENTIALS_JSON }}
90+
91+
- name: Setup gcloud CLI
92+
uses: google-github-actions/setup-gcloud@v1
93+
94+
- name: Save bbl state
95+
run: |
96+
env_name=${{ steps.setup-bbl-env.outputs.envName }}
97+
gsutil -m cp -R -P ./$env_name gs://cf-cli-bosh-lites/
98+
99+
- name: Checkout cf-deployment
100+
uses: actions/checkout@v4
101+
with:
102+
repository: cloudfoundry/cf-deployment
103+
ref: release-candidate
104+
path: cf-deployment
105+
106+
- name: Checkout bosh-deployment
107+
uses: actions/checkout@v4
108+
with:
109+
repository: cloudfoundry/bosh-deployment
110+
path: bosh-deployment
111+
112+
- name: Upload latest CAPI release
113+
if: ${{ (vars.USE_LATEST_CAPI == true) || (vars.CAPI_RELEASE_VERSION != '') }}
114+
env:
115+
capi_release_version: ${{ vars.CAPI_RELEASE_VERSION }}
116+
run: |
117+
if [ -z "$capi_release_version" ]; then
118+
capi_release_version=$(curl -s https://api.github.com/repos/cloudfoundry/capi-release/releases/latest | jq -r .tag_name)
119+
fi
120+
121+
echo "Latest CAPI release is $capi_release_version"
122+
123+
env_name="${{ steps.setup-bbl-env.outputs.envName }}"
124+
cd $env_name/bbl-state
125+
eval "$(bbl print-env)"
126+
127+
jq -r .bosh.jumpbox_private_key metadata.json > /tmp/${env_name}.priv
128+
129+
bosh upload-release "https://bosh.io/d/github.com/cloudfoundry/capi-release?v=$capi_release_version"
130+
- name: Deploy cf
131+
run: |
132+
env_name="${{ steps.setup-bbl-env.outputs.envName }}"
133+
cd $env_name/bbl-state
134+
eval "$(bbl print-env)"
135+
bosh update-runtime-config ${GITHUB_WORKSPACE}/bosh-deployment/runtime-configs/dns.yml --name dns
136+
STEMCELL_VERSION=$(bosh interpolate ${GITHUB_WORKSPACE}/cf-deployment/cf-deployment.yml --path /stemcells/alias=default/version)
137+
bosh upload-stemcell "https://bosh.io/d/stemcells/bosh-warden-boshlite-ubuntu-jammy-go_agent?v=${STEMCELL_VERSION}"
138+
bosh update-cloud-config ${GITHUB_WORKSPACE}/cf-deployment/iaas-support/bosh-lite/cloud-config.yml
139+
SYSTEM_DOMAIN="$env_name.app-runtime-interfaces.ci.cloudfoundry.org"
140+
141+
additional_args=''
142+
if [ -n "${{ vars.USE_LATEST_CAPI }}" ] || [ -n "${{ vars.CAPI_RELEASE_VERSION }}" ]; then
143+
additional_args="-o ${GITHUB_WORKSPACE}/cli/.github/ops-files/use-latest-capi.yml"
144+
fi
145+
146+
bosh interpolate ${GITHUB_WORKSPACE}/cf-deployment/cf-deployment.yml \
147+
-o ${GITHUB_WORKSPACE}/cf-deployment/operations/bosh-lite.yml \
148+
-o ${GITHUB_WORKSPACE}/cf-deployment/operations/use-compiled-releases.yml \
149+
-o ${GITHUB_WORKSPACE}/cf-deployment/operations/enable-v2-api.yml \
150+
-o ${GITHUB_WORKSPACE}/cf-deployment/operations/use-internal-lookup-for-route-services.yml \
151+
-o ${GITHUB_WORKSPACE}/cli/.github/ops-files/diego-cell-instances.yml \
152+
-o ${GITHUB_WORKSPACE}/cli/.github/ops-files/add-uaa-client-credentials.yml \
153+
-o ${GITHUB_WORKSPACE}/cli/.github/ops-files/increase-route-registration-interval.yml \
154+
-o ${GITHUB_WORKSPACE}/cli/.github/ops-files/add-oidc-provider.yml ${additional_args} \
155+
-v client-secret="${{ secrets.CLIENT_SECRET }}" \
156+
-v system_domain=${SYSTEM_DOMAIN} \
157+
> ./director.yml
158+
159+
bosh deploy director.yml
160+
161+
- name: delete bosh
162+
if: failure()
163+
run: |
164+
env_name="${{ steps.setup-bbl-env.outputs.envName }}"
165+
if [ -d ${env_name}/bbl_state ]; then
166+
cd ${env_name}/bbl-state
167+
eval "$(bbl print-env)"
168+
169+
echo "Deleting env ${env_name}"
170+
bbl down --no-confirm --gcp-service-account-key=key.json
171+
172+
echo "Deleting bbl state directory"
173+
if gsutil ls gs://cf-cli-bosh-lites | grep -q /${env_name}/; then
174+
gsutil rm -R gs://cf-cli-bosh-lites/${env_name}
175+
fi
176+
fi
177+
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Delete environment
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
env-name:
6+
description: Env name to delete
7+
required: true
8+
type: string
9+
workflow_call:
10+
inputs:
11+
env-name:
12+
required: true
13+
type: string
14+
15+
env:
16+
BBL_IAAS: gcp
17+
BBL_GCP_REGION: us-east1
18+
BBL_GCP_SERVICE_ACCOUNT_KEY: ${{ secrets.GCP_CREDENTIALS_JSON }}
19+
BOSH_DEPLOYMENT: cf
20+
BOSH_NON_INTERACTIVE: true
21+
ENV_NAME: ${{ inputs.env-name }}
22+
23+
jobs:
24+
delete-env:
25+
runs-on: ubuntu-latest
26+
outputs:
27+
envName: ${{steps.setup-bbl-env.outputs.env_name}}
28+
steps:
29+
- name: Install Tools
30+
run: |
31+
go version
32+
33+
install_location=/usr/local/bin
34+
bbl_version=v9.0.35
35+
bosh_cli_artifact=bosh-cli-7.7.2-linux-amd64
36+
37+
sudo curl https://github.com/cloudfoundry/bosh-bootloader/releases/download/${bbl_version}/bbl-${bbl_version}_linux_amd64 --silent --location --output $install_location/bbl
38+
sudo chmod +x $install_location/bbl
39+
bbl --version
40+
41+
sudo curl https://github.com/cloudfoundry/bosh-cli/releases/download/v7.7.2/$bosh_cli_artifact --silent --output $install_location/bosh --location
42+
sudo chmod +x $install_location/bosh
43+
bosh --version
44+
45+
sudo apt update
46+
sudo apt install -y build-essential unzip wamerican
47+
48+
- name: Checkout cli
49+
uses: actions/checkout@v4
50+
with:
51+
path: cli
52+
53+
- name: Checkout bosh-bootloader
54+
uses: actions/checkout@v4
55+
with:
56+
repository: cloudfoundry/bosh-bootloader
57+
path: bosh-bootloader
58+
59+
- name: Authenticate to Google Cloud
60+
uses: google-github-actions/auth@v2
61+
with:
62+
credentials_json: ${{ secrets.GCP_CREDENTIALS_JSON }}
63+
64+
- name: Setup gcloud CLI
65+
uses: google-github-actions/setup-gcloud@v1
66+
67+
- name: Download file from GCS
68+
run: |
69+
gsutil -m cp -P -R gs://cf-cli-bosh-lites/${ENV_NAME} .
70+
71+
- name: delete bosh
72+
run: |
73+
cd ${ENV_NAME}/bbl-state
74+
eval "$(bbl print-env)"
75+
76+
echo "Deleting env ${ENV_NAME}"
77+
echo ${BBL_GCP_SERVICE_ACCOUNT_KEY} > key.json
78+
bbl down --no-confirm --gcp-service-account-key=key.json
79+
80+
- name: delete gcs bucket
81+
run: |
82+
gsutil rm -R gs://cf-cli-bosh-lites/${ENV_NAME}

0 commit comments

Comments
 (0)