Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

Rename Docker images in kubernetes #433

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
uses: bots-house/[email protected]
with:
owner: noaa-gsl
name: unified-graphics/api
name: unified-graphics/app
token: ${{ secrets.GHCR_CLEANUP_PAT }}
tag: ${{ github.head_ref }}
- name: Cleanup images
Expand All @@ -43,7 +43,7 @@ jobs:
- name: Cleanup image
run: |
aws ecr batch-delete-image \
--repository-name rtma-vis/api \
--repository-name rtma-vis/app \
--image-ids imageTag=${{ github.head_ref }}
- name: Cleanup image
run: |
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/api.yaml → .github/workflows/app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ jobs:
- name: Code Coverage Report
uses: irongut/[email protected]
with:
header: API Coverage
header: App Coverage
filename: coverage.xml
badge: true
fail_below_min: true
Expand All @@ -128,7 +128,7 @@ jobs:
run: python3 ./.github/scripts/extract_git_ref.py # Provides env.BRANCH
- name: Build & tag image
run: |
docker build -t ${{ env.REGISTRY }}/api:${{ env.BRANCH }} -f docker/app/Dockerfile .
docker build -t ${{ env.REGISTRY }}/app:${{ env.BRANCH }} -f docker/app/Dockerfile .
- name: Login to GHCR
uses: docker/login-action@v3
with:
Expand All @@ -137,7 +137,7 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push image
run: |
docker push ${{ env.REGISTRY }}/api:${{ env.BRANCH }}
docker push ${{ env.REGISTRY }}/app:${{ env.BRANCH }}
build_diag_etl:
runs-on: ubuntu-latest
needs: [lint, type-check, test]
Expand Down Expand Up @@ -169,7 +169,7 @@ jobs:
- name: Scan image with Trivy
uses: aquasecurity/trivy-action@master
with:
image-ref: "${{ env.REGISTRY }}/api:${{ env.BRANCH }}"
image-ref: "${{ env.REGISTRY }}/app:${{ env.BRANCH }}"
format: "sarif"
output: "trivy-results.sarif"
ignore-unfixed: true
Expand Down Expand Up @@ -233,9 +233,9 @@ jobs:
uses: aws-actions/amazon-ecr-login@v2
- name: retag image and push
run: |
docker pull ${{ env.REGISTRY }}/api:${{ env.BRANCH }}
docker tag ${{ env.REGISTRY }}/api:${{ env.BRANCH }} ${{ secrets.AWS_REGISTRY }}/api:${{ env.BRANCH }}
docker push ${{ secrets.AWS_REGISTRY }}/api:${{ env.BRANCH }}
docker pull ${{ env.REGISTRY }}/app:${{ env.BRANCH }}
docker tag ${{ env.REGISTRY }}/app:${{ env.BRANCH }} ${{ secrets.AWS_REGISTRY }}/app:${{ env.BRANCH }}
docker push ${{ secrets.AWS_REGISTRY }}/app:${{ env.BRANCH }}
docker pull ${{ env.REGISTRY }}/data:${{ env.BRANCH }}
docker tag ${{ env.REGISTRY }}/data:${{ env.BRANCH }} ${{ secrets.AWS_REGISTRY }}/data:${{ env.BRANCH }}
docker push ${{ secrets.AWS_REGISTRY }}/data:${{ env.BRANCH }}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
uses: bots-house/[email protected]
with:
owner: noaa-gsl
name: unified-graphics/ui
name: unified-graphics/webserver
token: ${{ secrets.GHCR_CLEANUP_PAT }}
tag: ${{ github.head_ref }}
purge-ecr-images:
Expand All @@ -38,5 +38,5 @@ jobs:
- name: Cleanup image
run: |
aws ecr batch-delete-image \
--repository-name rtma-vis/ui \
--repository-name rtma-vis/webserver \
--image-ids imageTag=${{ github.head_ref }}
47 changes: 4 additions & 43 deletions .github/workflows/ui.yaml → .github/workflows/webserver.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "UI Service Build"
name: "Webserver Service Build"
on:
push:
tags:
Expand All @@ -25,7 +25,7 @@ on:
- "docker/webserver/**"
workflow_dispatch: # Manually
env:
REGISTRY: ghcr.io/noaa-gsl/unified-graphics/ui
REGISTRY: ghcr.io/noaa-gsl/unified-graphics/webserver

jobs:
lint:
Expand All @@ -41,45 +41,6 @@ jobs:
run: npm ci
- name: Lint
run: npm run lint:code
# test:
# runs-on: ubuntu-latest
# permissions:
# pull-requests: write
# steps:
# - uses: actions/checkout@v4
# - uses: actions/setup-node@v4
# with:
# node-version-file: ".nvmrc"
# cache: "npm"
# cache-dependency-path: "services/api/package-lock.json"
# - name: Install dependencies
# working-directory: services/api
# run: npm ci
# - name: Test
# working-directory: services/api
# run: |
# npx playwright install-deps
# npx playwright install
# npm test
# - name: Code Coverage Report
# uses: irongut/[email protected]
# with:
# filename: services/api/src/coverage/cobertura-coverage.xml
# badge: true
# fail_below_min: true
# format: markdown
# hide_branch_rate: false
# hide_complexity: true
# indicators: true
# output: both
# thresholds: "0 80"
# - name: Add Coverage PR Comment
# uses: marocchino/sticky-pull-request-comment@v2
# if: github.event_name == 'pull_request'
# with:
# header: UI Coverage
# recreate: true
# path: code-coverage-results.md
build:
runs-on: ubuntu-latest
needs: [lint]
Expand Down Expand Up @@ -152,5 +113,5 @@ jobs:
- name: retag image and push
run: |
docker pull ${{ env.REGISTRY }}:${{ env.BRANCH }}
docker tag ${{ env.REGISTRY }}:${{ env.BRANCH }} ${{ secrets.AWS_REGISTRY }}/ui:${{ env.BRANCH }}
docker push ${{ secrets.AWS_REGISTRY }}/ui:${{ env.BRANCH }}
docker tag ${{ env.REGISTRY }}:${{ env.BRANCH }} ${{ secrets.AWS_REGISTRY }}/webserver:${{ env.BRANCH }}
docker push ${{ secrets.AWS_REGISTRY }}/webserver:${{ env.BRANCH }}
2 changes: 1 addition & 1 deletion kubernetes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ We're using a Kustomize-style layout. `base` contains the default k8s manifests,

### Start app via CLI

Currently, you will need to create a `kuberenetes/overlays/dev/api/.env` file with the required AWS keys to pass in to the container. That file should look like so:
Currently, you will need to create a `kuberenetes/overlays/dev/app/.env` file with the required AWS keys to pass in to the container. That file should look like so:

```shell
AWS_ACCESS_KEY_ID=<aws access key value>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,27 @@ apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app.kubernetes.io/name: api
app.kubernetes.io/name: app
# app.kubernetes.io/instance:
app.kubernetes.io/part-of: unified-graphics
app.kubernetes.io/component: backend
app: unified-graphics-api
app: unified-graphics-app
tier: backend
name: unified-graphics-api
name: unified-graphics-app
spec:
replicas: 1
selector:
matchLabels:
app: unified-graphics-api
app: unified-graphics-app
template:
metadata:
labels:
app: unified-graphics-api
app: unified-graphics-app
spec:
containers:
- image: unified-graphics/api
- image: unified-graphics/app
imagePullPolicy: Always # Since we're tracking a long-lived tag, we'll want to always check for updated images
name: unified-graphics-api
name: unified-graphics-app
ports:
- containerPort: 80
protocol: TCP
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ spec:
app: migrations
spec:
containers:
- image: unified-graphics/api
- image: unified-graphics/app
name: migrations
imagePullPolicy: Always
command: ["alembic", "upgrade", "head"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ apiVersion: v1
kind: Service
metadata:
labels:
app: unified-graphics-api
name: unified-graphics-api
app: unified-graphics-app
name: unified-graphics-app
spec:
ports:
- port: 80
targetPort: 80 # Port to forward to in the pod
protocol: TCP
name: http
selector:
app: unified-graphics-api
app: unified-graphics-app
type: ClusterIP
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,27 @@ apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app.kubernetes.io/name: ui
app.kubernetes.io/name: webserver
# app.kubernetes.io/instance:
app.kubernetes.io/part-of: unified-graphics
app.kubernetes.io/component: frontend
app: unified-graphics-ui
app: unified-graphics-webserver
tier: frontend
name: unified-graphics-ui
name: unified-graphics-webserver
spec:
replicas: 1
selector:
matchLabels:
app: unified-graphics-ui
app: unified-graphics-webserver
template:
metadata:
labels:
app: unified-graphics-ui
app: unified-graphics-webserver
spec:
containers:
- image: unified-graphics/ui
- image: unified-graphics/webserver
imagePullPolicy: Always # Since we're tracking a long-lived tag, we'll want to always check for updated images
name: unified-graphics-ui
name: unified-graphics-webserver
ports:
- containerPort: 80
protocol: TCP
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ apiVersion: v1
kind: Service
metadata:
labels:
app: unified-graphics-ui
name: unified-graphics-ui
app: unified-graphics-webserver
name: unified-graphics-webserver
spec:
ports:
- port: 80
targetPort: 80 # Port to forward to in the pod
protocol: TCP
name: http
selector:
app: unified-graphics-ui
app: unified-graphics-webserver
type: ClusterIP
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: unified-graphics-api
name: unified-graphics-app
spec:
template:
spec:
containers:
- name: unified-graphics-api
- name: unified-graphics-app
envFrom:
- secretRef:
name: unified-graphics-api-secret
name: unified-graphics-app-secret
- configMapRef:
name: unified-graphics-api-config
name: unified-graphics-app-config
# FIXME - we should explore dissallowing privilege escalation
securityContext:
allowPrivilegeEscalation: true # Default behavior
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
bases:
- ../../../base/api
- ../../../base/app

resources:
- "rbac.yaml"

images:
- name: unified-graphics/api
newName: ghcr.io/noaa-gsl/unified-graphics/api
- name: unified-graphics/app
newName: ghcr.io/noaa-gsl/unified-graphics/app
newTag: main

patchesStrategicMerge:
- "deployment.yaml"
- "job.yaml"

configMapGenerator:
- name: unified-graphics-api-config
- name: unified-graphics-app-config
envs:
- dev.api.env
- dev.app.env

secretGenerator:
- name: unified-graphics-api-secret
- name: unified-graphics-app-secret
envs:
- .env # Should contain AWS_ACCESS_KEY, AWS_SECRET_ACCESS_KEY, AWS_SECRET_TOKEN, FLASK_SQLALCHEMY_DATABASE_URI
- name: unified-graphics-migrations-secret
Expand Down
4 changes: 2 additions & 2 deletions kubernetes/overlays/dev/ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: unified-graphics-ui
name: unified-graphics-webserver
annotations:
traefik.ingress.kubernetes.io/router.entrypoints: web
spec:
Expand All @@ -13,6 +13,6 @@ spec:
pathType: Prefix
backend:
service:
name: unified-graphics-ui
name: unified-graphics-webserver
port:
number: 80
4 changes: 2 additions & 2 deletions kubernetes/overlays/dev/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
resources:
- api
- ui
- app
- webserver
- db
- ingress.yaml
commonLabels:
Expand Down
1 change: 0 additions & 1 deletion kubernetes/overlays/dev/ui/dev.ui.env

This file was deleted.

14 changes: 0 additions & 14 deletions kubernetes/overlays/dev/ui/kustomization.yaml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: unified-graphics-ui
name: unified-graphics-webserver
spec:
template:
spec:
containers:
- name: unified-graphics-ui
- name: unified-graphics-webserver
envFrom:
- configMapRef:
name: unified-graphics-ui-config
name: unified-graphics-webserver-config
# FIXME - we should explore dissallowing privilege escalation
securityContext:
allowPrivilegeEscalation: true # Default behavior
Expand Down
1 change: 1 addition & 0 deletions kubernetes/overlays/dev/webserver/dev.webserver.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
UG_DIAG_API_HOST=http://unified-graphics-app/
Loading
Loading