Skip to content

Commit b27bc44

Browse files
authored
fix: correct command in GKE deployment step (#333)
* fix: correct command in GKE deployment step * fix: format Kptfile description for better readability * fix: remove unnecessary comment from README.md * fix: remove unnecessary comments from app-config.yaml and Kptfile * fix: update GKE deploy action to use docker protocol * fix: enable deployment in workflow and streamline GKE deploy args * fix: add environment declaration in cleanup workflow and update kubectl version in mise.toml * fix: replace GKE deploy action with kubectl apply command for deployment * fix: update GKE deployment to use google-github-actions for improved management * fix: add namespace input to deployment workflows for improved flexibility * fix: use namespace input in GKE deployment for improved flexibility * fix: refactor namespace handling in deployment workflows for consistency * fix: update GKE deployment to use gke-deploy for improved management * test * test * fix: update gke-deploy installation path for correct execution * fix: streamline GKE deployment process by replacing gke-deploy with kubectl apply * fix: restore and enable Backstage image build step in CI workflow * fix: update GKE deployment step to use docker image and add custom PATH directory * fix: update GKE deploy step to use deprecated public image and remove custom PATH directory * test * test * fix: add Mise deactivate step before GKE Deploy * fix: replace Mise deactivate step with kubectl check in deployment workflow * fix: remove kubectl entry from mise.toml * test * test * test * test * test * test * refactor: rename job to "Hydrate Manifests" and streamline deployment steps * test * test * test * refactor: uncomment and enable Backstage image build step in CI workflow * dependabot updates * revert * test * fix: change GKE deploy command from 'apply' to 'run' this way the image digest is used * feat: add image_tag input for deployment workflows * fix: remove ignored comment from app-config.yaml * fix: improve formatting in README.md for package commands * fix: remove kpt_linux_amd64 binary file
1 parent 2915572 commit b27bc44

File tree

7 files changed

+60
-19
lines changed

7 files changed

+60
-19
lines changed

.github/workflows/build.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ jobs:
7474
uses: ./.github/workflows/deploy.yaml
7575
needs: build
7676
with:
77-
deploy: false
77+
deploy: true
7878
environment: development
7979
dry_run: "server"
80+
image_tag: ${{ github.sha }}

.github/workflows/cleanup.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@ jobs:
1212
permissions:
1313
contents: "read"
1414
id-token: "write"
15+
environment: development
1516
steps:
1617
- name: Set _REPONAME environment variable
1718
run: echo "_REPONAME=${GITHUB_REPOSITORY#"broadinstitute/"}" >> $GITHUB_ENV
1819

19-
- uses: "actions/checkout@v5"
20+
- uses: "actions/checkout@v6"
2021
- uses: "google-github-actions/auth@v3"
2122
with:
2223
workload_identity_provider: ${{ vars._WORKLOAD_IDENTITY_PROVIDER }}
@@ -35,4 +36,4 @@ jobs:
3536

3637
- id: "scale-down-pods"
3738
name: "Scale Down Dev Deployment"
38-
run: kubectl scale deployment ${{ vars._APP }} -n ${{ vars._APP }}-dev --replicas=0
39+
run: kubectl scale deployment ${{ vars._APP }} -n ${{ vars._NAMESPACE }} --replicas=0

.github/workflows/deploy-prod.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
name: "Production Environment"
3-
'on':
3+
"on":
44
pull_request_target:
55
types:
66
- closed
@@ -16,3 +16,4 @@ jobs:
1616
with:
1717
deploy: true
1818
environment: production
19+
image_tag: ${{ github.event.number }}

.github/workflows/deploy.yaml

Lines changed: 44 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ name: "Kubernetes Deployment"
2323
default: "client"
2424
required: false
2525
type: string
26+
image_tag:
27+
description: The image tag to deploy
28+
default: "latest"
29+
required: false
30+
type: string
2631
permissions:
2732
contents: read
2833
id-token: write # This is required for requesting the JWT
@@ -38,7 +43,7 @@ jobs:
3843
run:
3944
working-directory: ${{ inputs.working_directory }}
4045
environment: ${{ inputs.environment }}
41-
name: "Hydrate and deploy Manifests"
46+
name: "Hydrate Manifests"
4247
runs-on: ubuntu-latest
4348
steps:
4449
- name: Checkout repo
@@ -75,7 +80,30 @@ jobs:
7580
--image ghcr.io/kptdev/krm-functions-catalog/set-image:v0.1.1 \
7681
-- name=${{ vars._LOCATION }}-docker.pkg.dev/bits-gke-clusters/bits/backstage:latest \
7782
newName=${{ vars._LOCATION }}-docker.pkg.dev/${{ vars._REGISTRY_PROJECT }}/${{ vars._REGISTRY_NAME }}/${{ vars._APP }} \
78-
newTag=${{ github.event.number }}
83+
newTag=${{ inputs.image_tag }}
84+
85+
- uses: actions/upload-artifact@v6
86+
with:
87+
name: Upload Deployment Directory
88+
path: ${{ env.DEPLOY_PATH }}/${{ vars._APP }}
89+
retention-days: 5
90+
deploy:
91+
defaults:
92+
run:
93+
working-directory: ${{ inputs.working_directory }}
94+
environment: ${{ inputs.environment }}
95+
name: "Deploy Manifests"
96+
runs-on: ubuntu-latest
97+
needs: hydrate
98+
steps:
99+
- name: Checkout repo
100+
uses: actions/checkout@v6
101+
- name: Download Deployment Directory
102+
uses: actions/download-artifact@v7
103+
with:
104+
name: Upload Deployment Directory
105+
path: ${{ env.DEPLOY_PATH }}/${{ vars._APP }}
106+
merge-multiple: true
79107

80108
- name: Authenticate to Workload Identity
81109
uses: google-github-actions/auth@v3
@@ -99,12 +127,21 @@ jobs:
99127
if: ${{ inputs.deploy == false }}
100128
run: |
101129
kubectl apply -f ${{ env.DEPLOY_PATH }}/${{ vars._APP }} --recursive --dry-run=${{ inputs.dry_run }}
102-
- name: GKE Deploy - Apply
103130
131+
- name: GKE Deploy - Apply
104132
if: ${{ inputs.deploy == true }}
105133
uses: docker://gcr.io/cloud-builders/gke-deploy:latest
106134
with:
107-
args:
108-
apply --recursive --filename=${{ env.DEPLOY_PATH }}/${{ vars._APP }} --location=${{
109-
vars._LOCATION }} --project=${{ vars._GKE_PROJECT }} --cluster=gke-autopilot-01-prod
110-
--timeout=10m
135+
args: run --recursive --filename=${{ env.DEPLOY_PATH }}/${{ vars._APP }} --location=${{ vars._LOCATION }} --project=${{ vars._GKE_PROJECT }} --cluster=gke-autopilot-01-prod --timeout=10m
136+
# This errors here, but might work with a new deployment
137+
# - name: "GKE Deploy using Action"
138+
# if: ${{ inputs.deploy == true }}
139+
# uses: "google-github-actions/deploy-gke@v0"
140+
# with:
141+
# image: "${{ vars._LOCATION }}-docker.pkg.dev/${{ vars._REGISTRY_PROJECT }}/${{ vars._REGISTRY_NAME }}/${{ vars._APP }}:${{ github.event.number }}"
142+
# app_name: "${{ vars._APP }}"
143+
# region: "${{ vars._LOCATION }}"
144+
# cluster_name: "gke-autopilot-01-prod"
145+
# project_id: "${{ vars._GKE_PROJECT }}"
146+
# k8s_manifests: "${{ env.DEPLOY_PATH }}/${{ vars._APP }}"
147+
# namespace: "${{ vars._NAMESPACE }}"

backstage/run.Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
FROM gcr.io/buildpacks/google-22/run@sha256:bb3748cfa4946ae4c1d827fff344ed4c83afa45fad446a4609a605322c2a8b96
22
USER root
33
RUN apt-get update && apt-get install -y --no-install-recommends \
4-
python3 python3-pip python3-venv g++ build-essential && \
5-
apt-get clean && \
6-
rm -rf /var/lib/apt/lists/*
4+
python3 python3-pip python3-venv g++ build-essential && \
5+
apt-get clean && \
6+
rm -rf /var/lib/apt/lists/*
77

88
# Install mkdocs-techdocs-core dependencies
99
ENV VIRTUAL_ENV=/opt/venv

deployment/backstage/README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,12 @@ Install and Configure Backstage on GKE Clusters
88

99
### Fetch the package
1010

11-
`kpt pkg get REPO_URI[.git]/PKG_PATH[@VERSION] backstage`
12-
Details: https://kpt.dev/reference/cli/pkg/get/
11+
`kpt pkg get REPO_URI[.git]/PKG_PATH[@VERSION] backstage` Details:
12+
https://kpt.dev/reference/cli/pkg/get/
1313

1414
### View package content
1515

16-
`kpt pkg tree backstage`
17-
Details: https://kpt.dev/reference/cli/pkg/tree/
16+
`kpt pkg tree backstage` Details: https://kpt.dev/reference/cli/pkg/tree/
1817

1918
### Apply the package
2019

deployment/dev/Kptfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ metadata:
55
annotations:
66
config.kubernetes.io/local-config: "true"
77
info:
8-
description: Broad Institute Engineering Portal is an Internal Developer Platform (Spotify Backstage by another name)
8+
description:
9+
Broad Institute Engineering Portal is an Internal Developer Platform
10+
(Spotify Backstage by another name)
911
keywords:
1012
- GKE
1113
- GCP

0 commit comments

Comments
 (0)