Skip to content
Merged
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
7 changes: 4 additions & 3 deletions .github/workflows/docker-k8s.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,11 @@ jobs:
- name: Lint k8s
run: (cd Resources/k8s/kustomize && yamllint .)
- name: Create k8s Kind Cluster
uses: helm/kind-action@v1.12.0
uses: helm/kind-action@v1.13.0
with:
cluster_name: pokeapi
version: v0.21.0
config: Resources/kind/config-ga.yaml
version: v0.31.0
- name: Create deployment configuration
run: |
cp Resources/k8s/kustomize/base/secrets/postgres.env.sample Resources/k8s/kustomize/base/secrets/postgres.env
Expand All @@ -79,7 +80,7 @@ jobs:
run: kind load docker-image pokeapi/pokeapi:local --name pokeapi
- name: K8s Apply
run: |
make kustomize-local-apply
make kustomize-ga-apply
kubectl proxy &
sleep 1
bash Resources/scripts/wait.sh http://localhost:8001/api/v1/namespaces/pokeapi/services/pokeapi/proxy/api/v2/
Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ kustomize-staging-apply: # (Kustomize) Run kubectl apply -k on the connected k8
kustomize-local-apply: # (Kustomize) Run kubectl apply -k on the connected k8s cluster using the locally available pokeapi/pokeapi:local
kubectl apply -k Resources/k8s/kustomize/local/

kustomize-ga-apply: # (Kustomize) Run kubectl apply -k on the connected k8s cluster using the Github Actions config (share host data with the cluster)
kubectl apply -k Resources/k8s/kustomize/ga/

k8s-migrate: # (k8s) Run any pending migrations
kubectl exec --namespace pokeapi deployment/pokeapi -- python manage.py migrate ${docker_config}

Expand Down
28 changes: 7 additions & 21 deletions Resources/k8s/kustomize/base/deployments/pokeapi-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ metadata:
labels:
component: pokeapi
spec:
replicas: 2
replicas: 1
selector:
matchLabels:
component: pokeapi
Expand All @@ -29,17 +29,11 @@ spec:
args:
- apk add --update git &&
git clone --depth=1 --single-branch --branch=master --recurse-submodules --shallow-submodules https://github.com/PokeAPI/pokeapi.git &&
mv /code/pokeapi/data/v2/cries/* /tmp/cries/ &&
mv /code/pokeapi/data/v2/csv/* /tmp/csv/ &&
mv /code/pokeapi/data/v2/sprites/* /tmp/sprites/
mv /code/pokeapi/data/v2/* /tmp/
workingDir: /code
volumeMounts:
- mountPath: /tmp/cries
name: cries-data-share
- mountPath: /tmp/csv
name: csv-data-share
- mountPath: /tmp/sprites
name: sprites-data-share
- mountPath: /tmp/
name: data-share
containers:
- name: pokeapi
image: pokeapi/pokeapi:master
Expand Down Expand Up @@ -69,12 +63,8 @@ spec:
- configMapRef:
name: pokeapi-configmap
volumeMounts:
- mountPath: /code/data/v2/cries
name: cries-data-share
- mountPath: /code/data/v2/csv
name: csv-data-share
- mountPath: /code/data/v2/sprites
name: sprites-data-share
- mountPath: /code/data/v2/
name: data-share
resources: {}
readinessProbe:
periodSeconds: 5
Expand All @@ -89,9 +79,5 @@ spec:
path: /api/v2/
port: 8080
volumes:
- name: cries-data-share
emptyDir: {}
- name: csv-data-share
emptyDir: {}
- name: sprites-data-share
- name: data-share
emptyDir: {}
11 changes: 11 additions & 0 deletions Resources/k8s/kustomize/ga/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- ../local

patches:
- path: pokeapi-deployment-patch.yaml
target:
kind: Deployment
labelSelector: component=pokeapi
23 changes: 23 additions & 0 deletions Resources/k8s/kustomize/ga/pokeapi-deployment-patch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: pokeapi
spec:
template:
spec:
initContainers:
- name: data-download
image: alpine:3.21.2
command: ['ls']
args: ['/tmp/csv']
containers:
- name: pokeapi
volumeMounts:
- mountPath: /code/data/v2/
name: data-share
volumes:
- name: data-share
hostPath:
path: /code/pokeapi/data/v2/
emptyDir:
$patch: delete
7 changes: 7 additions & 0 deletions Resources/kind/config-ga.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: kind.x-k8s.io/v1alpha4
kind: Cluster
nodes:
- role: control-plane
extraMounts:
- hostPath: /home/runner/work/pokeapi/pokeapi/data/v2/
containerPath: /code/pokeapi/data/v2/