Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kubernetes Builds #172

Closed
wants to merge 149 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
149 commits
Select commit Hold shift + click to select a range
4d2596d
[F] NewsPosts have optional Hero Captions
Aug 10, 2023
86ef297
Supervisord impl work in progress
ericdrosas87 Aug 25, 2023
340e373
Cleaned up supervisord code
ericdrosas87 Aug 25, 2023
a64139a
Updated composer.json to install new DAM plugin
ericdrosas87 Aug 25, 2023
63d6dab
add build and push workflow
jtrouth Sep 7, 2023
ae07bec
fix quotes
jtrouth Sep 7, 2023
359363e
fix condition
jtrouth Sep 7, 2023
ea401b2
fix image name
jtrouth Sep 7, 2023
49107d0
add PRs to workflow
jtrouth Sep 7, 2023
40d68ca
update trigger branches
jtrouth Sep 7, 2023
56e5c68
add redis config
jtrouth Sep 7, 2023
8624b68
add yii2 redis package
jtrouth Sep 8, 2023
093d00e
temp update base tag
jtrouth Sep 8, 2023
5d23268
add image build caching
jtrouth Sep 8, 2023
589e3df
[F] ImageGrid content block
Sep 13, 2023
bee50b9
[F] Composer updates
Sep 13, 2023
f84b993
[C] Bump project config dateModified
Sep 13, 2023
d264f23
add yii2 redis package
jtrouth Sep 8, 2023
60bae36
Override runQueueAutomatically default value
ericdrosas87 Sep 27, 2023
3cdeaf9
[C] lsst/canto-dam-integrator version bump
Oct 3, 2023
300aa46
Updated new DAM plugin
ericdrosas87 Oct 12, 2023
b5fcbd7
add build and push workflow
jtrouth Sep 7, 2023
1b2dee2
Merge branch 'master' into k8s-build-updates
jtrouth Nov 2, 2023
95faa80
add temp condition
jtrouth Nov 2, 2023
1745d17
add temp condition
jtrouth Nov 2, 2023
bcce516
add temp condition
jtrouth Nov 2, 2023
469a6b1
add temp condition
jtrouth Nov 2, 2023
5af6cd5
Change GCS plugin bucket names from choose to man
ericdrosas87 Nov 29, 2023
be6900c
[C] Remove PR github workflows and update README
Nov 7, 2023
89f9b4f
[F] Transition from AWS to GCS for asset_variants volume
Nov 16, 2023
1b13ecd
[C] Update Canto DAM Plugin to latest
Nov 16, 2023
4cd124d
[F] Callouts use new DAM plugin
Nov 21, 2023
19bdb73
Change GCS plugin bucket names from choose to man
ericdrosas87 Nov 29, 2023
99e0517
Quick release test
ericdrosas87 Nov 30, 2023
edd7574
[F] NewsPosts have optional Hero Captions
Aug 10, 2023
90f267a
Supervisord impl work in progress
ericdrosas87 Aug 25, 2023
aeee6bd
Cleaned up supervisord code
ericdrosas87 Aug 25, 2023
2b2f6cf
Updated composer.json to install new DAM plugin
ericdrosas87 Aug 25, 2023
c504b82
add yii2 redis package
jtrouth Sep 8, 2023
05477d7
[F] ImageGrid content block
Sep 13, 2023
85fe862
[F] Composer updates
Sep 13, 2023
b48b7a3
Merge remote-tracking branch 'origin/master' into k8s-build-updates
jtrouth Dec 19, 2023
2537bca
fix image tags
jtrouth Dec 19, 2023
8bbc7c0
fix image tags
jtrouth Dec 19, 2023
cd4eac0
Merge branch 'develop' into k8s-build-updates
jtrouth Dec 19, 2023
8d563e6
Merge remote-tracking branch 'origin/develop' into k8s-build-updates
jtrouth Dec 19, 2023
95c6507
fix composer lock
jtrouth Dec 19, 2023
5ed2acd
fix files
jtrouth Dec 19, 2023
b444c63
change tag
jtrouth Dec 19, 2023
1265e51
change tag
jtrouth Dec 19, 2023
16901eb
fix dep
jtrouth Dec 20, 2023
b39df79
fix dep
jtrouth Dec 20, 2023
970238b
update gcp actions
jtrouth Dec 20, 2023
907918d
update project config
jtrouth Dec 21, 2023
ad4921a
fix dev build logic
jtrouth Dec 21, 2023
c3e55b8
Update deployment workflow
jtrouth Dec 21, 2023
338b591
Update deployment workflow
jtrouth Dec 21, 2023
e8a39d9
Update deployment workflow
jtrouth Dec 21, 2023
d91e17c
Update deployment workflow
jtrouth Dec 21, 2023
ecbc5af
Update workflow
jtrouth Dec 27, 2023
dad0f08
Update workflow
jtrouth Dec 27, 2023
f044487
Update workflow
jtrouth Dec 27, 2023
d3d743d
Update workflow
jtrouth Dec 27, 2023
e130584
Update workflow
jtrouth Dec 27, 2023
4f9b255
Update workflow
jtrouth Dec 27, 2023
75f83e1
Update workflow
jtrouth Dec 27, 2023
0a41a8a
Update workflow
jtrouth Dec 27, 2023
e9eef06
Update workflow
jtrouth Dec 27, 2023
02cd68c
Update workflow
jtrouth Dec 27, 2023
3ad9f58
Update workflow
jtrouth Dec 27, 2023
8cc9723
Update workflow
jtrouth Dec 27, 2023
9b79274
Update workflow
jtrouth Dec 27, 2023
bb61455
Update workflow
jtrouth Dec 27, 2023
3d251bb
Update workflow
jtrouth Dec 27, 2023
4eb634c
Update workflow
jtrouth Dec 27, 2023
86dbb81
Update workflow
jtrouth Dec 27, 2023
d1aea98
Update workflow
jtrouth Dec 27, 2023
3e420f8
Update workflow
jtrouth Dec 27, 2023
42fe2bc
Update workflow
jtrouth Dec 27, 2023
e36c763
Update workflow
jtrouth Dec 27, 2023
f159be7
Update workflow
jtrouth Dec 27, 2023
c87e4c6
Update workflow
jtrouth Dec 28, 2023
bbd318c
Update workflow
jtrouth Dec 28, 2023
4c0ee96
Update workflow
jtrouth Dec 28, 2023
8c82a15
Update workflow
jtrouth Dec 28, 2023
1ff8762
Update workflow
jtrouth Dec 28, 2023
ee80d19
Update workflow
jtrouth Dec 28, 2023
4648243
Update workflow
jtrouth Dec 28, 2023
3f73747
Update workflow
jtrouth Dec 28, 2023
4b3e343
Update workflow
jtrouth Dec 28, 2023
c9372e6
Update workflow
jtrouth Dec 28, 2023
c4a0398
Update workflow
jtrouth Dec 28, 2023
68edfb7
Update workflow
jtrouth Dec 28, 2023
1c08795
Update workflow
jtrouth Dec 28, 2023
1f85002
Update workflow
jtrouth Dec 28, 2023
c0d378b
Update workflow
jtrouth Dec 28, 2023
45caafc
Update workflow
jtrouth Dec 28, 2023
3397d7e
Update workflow
jtrouth Dec 28, 2023
66372b3
Update workflow
jtrouth Dec 28, 2023
b5e9abb
Update workflow
jtrouth Dec 28, 2023
8228252
Update workflow
jtrouth Dec 28, 2023
a5888ff
Update workflow
jtrouth Dec 28, 2023
dc15d8d
Update workflow
jtrouth Dec 28, 2023
1a1a2db
Update workflow
jtrouth Dec 28, 2023
351c320
Update workflow
jtrouth Dec 28, 2023
3706eb3
Update workflow
jtrouth Dec 28, 2023
b2cbae5
Update workflow
jtrouth Dec 28, 2023
156edac
Update workflow
jtrouth Dec 28, 2023
e602580
Update workflow
jtrouth Dec 28, 2023
1917980
Update workflow
jtrouth Dec 28, 2023
cfaac1f
Update workflow
jtrouth Dec 28, 2023
c9ecb47
Update workflow
jtrouth Dec 28, 2023
e4741ac
Update workflow
jtrouth Dec 28, 2023
64b8c5c
Update workflow
jtrouth Dec 28, 2023
1aeea22
Update workflow
jtrouth Dec 28, 2023
3d582f3
Update workflow
jtrouth Dec 28, 2023
ccddb99
Update workflow
jtrouth Dec 28, 2023
45ce472
Update workflow
jtrouth Dec 28, 2023
ceb3692
Update workflow
jtrouth Dec 28, 2023
f97758f
Update workflow
jtrouth Dec 28, 2023
525d6ac
Update workflow
jtrouth Dec 28, 2023
458eec2
Update workflow
jtrouth Dec 28, 2023
4ee8ddf
Update workflow
jtrouth Dec 28, 2023
6d1a767
Update workflow
jtrouth Dec 28, 2023
fc715ba
Update workflow
jtrouth Dec 28, 2023
931fde1
Update workflow
jtrouth Dec 28, 2023
97ccf97
Update workflow
jtrouth Dec 28, 2023
54e8940
Update workflow
jtrouth Dec 28, 2023
30811fa
Update workflow
jtrouth Dec 28, 2023
037f161
Update workflow
jtrouth Dec 28, 2023
485e73a
Update workflow
jtrouth Dec 28, 2023
dd0b9c0
Update workflow
jtrouth Dec 28, 2023
82d5a18
Update workflow
jtrouth Dec 28, 2023
d581214
Update workflow
jtrouth Dec 28, 2023
710368d
Update workflow
jtrouth Dec 28, 2023
e42c496
Update workflow
jtrouth Dec 28, 2023
8b9e0fc
Update workflow
jtrouth Dec 28, 2023
5119383
Update workflow
jtrouth Dec 28, 2023
04d2319
Update workflow
jtrouth Dec 28, 2023
73ee321
Update workflow
jtrouth Dec 28, 2023
e8dce75
update workflow
jtrouth Jan 2, 2024
2a5b270
update workflow
jtrouth Jan 2, 2024
863632e
update workflow
jtrouth Jan 2, 2024
b6853ff
update workflow
jtrouth Jan 2, 2024
73a0c4f
update workflow
jtrouth Jan 2, 2024
dcd031f
update workflow
jtrouth Jan 2, 2024
ac590c4
increase timeout
jtrouth Jan 2, 2024
0660af7
update
jtrouth Jan 3, 2024
f1bb60e
Merge remote-tracking branch 'origin/develop' into k8s-build-updates
jtrouth Mar 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
ENVIRONMENT=dev
SECURITY_KEY=

# For Craft Postgres DB
DB_DSN=pgsql:host=postgres;dbname=craft
DB_SERVER=postgres
DB_NAME=
DB_USER=
DB_PASSWORD=
DB_DATABASE=
DB_SCHEMA=public
DB_DRIVER=pgsql
DB_PORT=5432

ENABLE_MEMCACHED="true"
MEMCACHED_IP=cache

# For Google Storage Assets
GCP_PROJECT_ID=
GCS_GENERAL_BUCKET=
GCS_HEROES_BUCKET=
GCS_CONTENT_BUCKET=
GCS_CALLOUTS_BUCKET=
GCS_STAFF_BUCKET=

# For required and custom Craft aliases
PRIMARY_SITE_URL=http://localhost:8080
WEB_BASE_URL=http://localhost:3000
ALIAS_PREVIEW_URL_FORMAT=http://localhost:3000/api/preview?site={site}&entryUid={sourceUid}

# For AWS Assets
AWS_ASSET_KEY_ID=
AWS_ASSET_SECRET_KEY=
AWS_ASSET_S3_BUCKET=
AWS_ASSET_S3_REGION=
AWS_ASSET_S3_ASSET_VARIANT_SUBFOLDER=

# For contact form
EMAIL_FROM_ADDRESS=
EMAIL_REPLY_TO_ADDRESS=
EMAIL_SENDER_NAME=
EMAIL_HTML_EMAIL_TEMPLATE=

EMAIL_SMTP_HOST_NAME=
EMAIL_SMTP_PORT=
EMAIL_SMTP_USERNAME=
EMAIL_SMTP_PASSWORD=

# For GraphQL Authentication
GOOGLE_APP_ID=
GOOGLE_APP_SECRET=

FACEBOOK_APP_ID=
FACEBOOK_APP_SECRET=
FACEBOOK_APP_REDIRECT_URL=

# FE User account management paths
VERIFY_EMAIL_PATH=http://localhost:3000/?activate=true
SET_PASSWORD_PATH=http://localhost:3000/?set_password=true
157 changes: 157 additions & 0 deletions .github/workflows/build-and-push.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
name: Build, Push, and Deploy

on:
push:
branches:
- 'develop'
- 'master'
tags:
- 'v.*'
pull_request:
types:
- 'opened'
- 'synchronize'
- 'reopened'
- 'closed'
branches:
- 'develop'
- 'master'

jobs:
build:
name: Build Container Image
runs-on: ubuntu-latest
outputs:
image_tag: ${{ steps.deploy-info.outputs.image_tag }}
image_name: ${{ steps.deploy-info.outputs.image_name }}
environment_name: ${{ steps.deploy-info.outputs.environment_name }}
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
# list of Docker images to use as base name for tags
images: |
gcr.io/skyviewer/rubinobs-api,enable=${{ github.ref != 'master' && github.ref_type != 'tag' && github.base_ref == 'develop' }}
gcr.io/edc-int-6c5e/rubinobs-api,enable=${{ github.ref == 'master' || github.base_ref == 'master'}}
gcr.io/edc-prod-eef0/rubinobs-api,enable=${{ github.ref_type == 'tag'}}
flavor: |
latest=${{ github.event_name == 'push'}}
# generate Docker tags based on the following events/attributes
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
-
name: Parse deployment info
id: deploy-info
run: |
# Determine environment to deploy to
if ${{ github.ref != 'master' && github.ref_type != 'tag' && github.base_ref == 'develop' }}; then
environment_name="dev"
credentials_json='${{ secrets.DEV_SA_KEY }}'
elif ${{ github.ref == 'master' || github.base_ref == 'master'}}; then
environment_name="int"
credentials_json='${{ secrets.SKYVIEWER_INT_SERVICE_ACCOUNT }}'
elif ${{ github.ref_type == 'tag'}}; then
environment_name="prod"
credentials_json='${{ secrets.PIPELINE_EPO_PROD_PROJECT }}'
else
environment_name=""
credentials_json=""
fi
echo environment_name=$environment_name >> "$GITHUB_OUTPUT"
echo credentials_json=$credentials_json >> "$GITHUB_OUTPUT"

# Parse container image tag to deploy
full_tag=$(echo "$DOCKER_METADATA_OUTPUT_JSON" | jq -r '.tags[] | limit(1; select(. | test(":sha-|:v.")))')
echo "Will use tag \"$full_tag\" for deployment."
echo image_tag=$(echo "$full_tag" | cut -f2 -d:) >> "$GITHUB_OUTPUT"
echo image_name=$(echo "$full_tag" | cut -f1 -d:) >> "$GITHUB_OUTPUT"
echo full_tag=$full_tag >> "$GITHUB_OUTPUT"

-
name: Set up QEMU
uses: docker/setup-qemu-action@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
-
name: Login to GCP
uses: 'google-github-actions/auth@v2'
with:
credentials_json: ${{ steps.deploy-info.outputs.credentials_json }}
-
name: 'Set up Cloud SDK'
uses: 'google-github-actions/setup-gcloud@v2'
-
run: gcloud --quiet auth configure-docker
-
name: Build and push
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-to: |
type=gha
cache-from: |
type=gha
build-args: |
BASE_TAG=k8s
-
name: Summary
run: |
cat <<-EOT >> "$GITHUB_STEP_SUMMARY"
# Container Build Completed

## Tags
${{ steps.meta.outputs.tags }}
EOT

deploy:
name: Trigger deploy to ${{ needs.build.outputs.environment_name }}
needs: build
runs-on: ubuntu-latest
steps:
- name: Generate Webhook Payload
id: payload
run: |-
PARAMETERS=(
api.image.tag=${{ needs.build.outputs.image_tag }}
api.image.repository=${{ needs.build.outputs.image_name }}
)
DATA="{
\"app_name\": \"rubinobs-site\",
\"environment_name\": \"${{ needs.build.outputs.environment_name }}\",
\"parameters\": $(jq -c -n '$ARGS.positional' --args ${PARAMETERS[@]})
}"
echo "data=$(echo $DATA | jq -rc '.')" >> "$GITHUB_OUTPUT"
- uses: lasith-kg/[email protected]
id: dispatch
name: Trigger Deployment
with:
dispatch-method: repository_dispatch
repo: edc-deploy
owner: lsst-epo
event-type: app_update_values
token: ${{ secrets.EDC_DEPLOY_GITHUB_TOKEN_FOR_REST_API }}
workflow-inputs: ${{ steps.payload.outputs.data }}
discover: true
- name: Await Run ID ${{ steps.dispatch.outputs.run-id }}
uses: Codex-/[email protected]
with:
token: ${{ secrets.EDC_DEPLOY_GITHUB_TOKEN_FOR_REST_API }}
repo: edc-deploy
owner: lsst-epo
run_id: ${{ steps.dispatch.outputs.run-id }}
run_timeout_seconds: 1500
156 changes: 156 additions & 0 deletions .github/workflows/deploy-gke.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
name: Deploy to GKE

on:
workflow_call:
inputs:
environment:
description: The environment to deploy to (prod, int, or dev)
type: string
required: true
image_tag:
description: The container image tag to deploy
type: string
required: false
default: latest
image_name:
description: The repo URL (minus the tag) of the container image to deploy
type: string
required: true
preview:
description: A boolean indicating if this is a preview deployment
type: boolean
required: false
default: false
application_name:
description: The name of the application to deploy (e.g. 'rubinobs-site')
type: string
required: false
default: rubinobs-site

concurrency: ${{ inputs.environment }}-deploy

env:
MANIFEST_FILENAME: ${{ inputs.application_name }}-${{inputs.environment}}-${{ github.sha }}.yaml

jobs:
generate-manifest:
name: Make App Manifest
runs-on: ubuntu-latest
steps:
-
name: Make Sync Patch File
if: ${{ !inputs.preview }}
run: |
cat <<-EOF > ${{ env.MANIFEST_FILENAME }}
spec:
source:
helm:
parameters:
- name: api.image.tag
value: ${{ inputs.image_tag }}
- name: api.image.repository
value: ${{ inputs.image_name }}
info:
- name: api-repo-url
value: ${{ github.repositoryUrl }}
- name: api-commit
value: ${{ github.sha }}
- name: api-ref
value: ${{ github.ref }}
operation:
initiatedBy:
username: ${{ github.actor }}
sync:
resources:
- kind: Deployment
group: apps
name: edc-${{ inputs.environment }}-${{ inputs.application_name }}-api
namespace: rubinobs
syncStrategy:
hook: {}
EOF

# -
# name: Make Preview Version Manifest
# if: ${{ inputs.preview }}
# run: |
# cat <<-EOF > ${{ env.MANIFEST_FILENAME }}
# apiVersion: argoproj.io/v1alpha1
# kind: Application
# metadata:
# name: edc-${{ inputs.environment }}-${{ inputs.application_name }}-preview-${{ github.ref }}
# namespace: argocd
# spec:
# source:
# repoURL: '[email protected]:lsst-epo/edc-deploy.git'
# path: environment/applications/epo-site/charts/epo-api
# targetRevision: master
# helm:
# parameters:
# - name: test
# value: test
# destination:
# server: 'https://kubernetes.default.svc'
# namespace: rubinobs
# operation:
# initiatedBy:
# username: ${{ github.actor }}
# sync:
# syncStrategy:
# hook: {}
# EOF

-
uses: actions/upload-artifact@v4
with:
path: ${{ env.MANIFEST_FILENAME }}
name: deployment-manifest
deploy:
runs-on: ubuntu-latest
steps:
-
name: Login to GCP Int
uses: 'google-github-actions/auth@v2'
if: ${{ inputs.environment == 'int'}}
with:
credentials_json: ${{ secrets.SKYVIEWER_INT_SERVICE_ACCOUNT }}

-
name: Login to GCP Prod
uses: 'google-github-actions/auth@v2'
if: ${{ inputs.environment == 'prod'}}
with:
credentials_json: ${{ secrets.PIPELINE_EPO_PROD_PROJECT }}

-
name: 'Set up Cloud SDK'
uses: 'google-github-actions/setup-gcloud@v2'

-
name: Get Int Cluster Credentials
uses: 'google-github-actions/get-gke-credentials@v2'
if: ${{ inputs.environment == 'int' }}
with:
cluster_name: gke-ap-edc-int
location: us-central1

-
name: Get Prod Cluster Credentials
uses: 'google-github-actions/get-gke-credentials@v2'
if: ${{ inputs.environment == 'prod' }}
with:
cluster_name: gke-ap-edc-prod
location: us-central1

-
name: Download Manifest
id: download
uses: actions/download-artifact@v4
with:
name: deployment-manifest

-
name: Apply Application Manifest
run: |
kubectl patch -n argocd app edc-${{ inputs.environment }}-${{ inputs.application_name }} \
--patch-file ${{ steps.download.outputs.download-path }}/${{ env.MANIFEST_FILENAME }}
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ RUN mkdir /var/secrets && [ -d ./storage ] || mkdir storage

USER www-data

CMD ["supervisord"]
CMD ["supervisord"]
3 changes: 2 additions & 1 deletion api/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"venveo/craft-bulkedit": "4.0.1",
"verbb/super-table": "3.0.9",
"vlucas/phpdotenv": "^3.4.0",
"wrav/oembed": "^2.2.2"
"wrav/oembed": "^2.2.2",
"yiisoft/yii2-redis": "^2.0"
},
"repositories": [
{
Expand Down
Loading
Loading