Skip to content

Commit df78d6e

Browse files
committed
Set up automatic deployment to k8s
1 parent 6a5d4f7 commit df78d6e

File tree

4 files changed

+87
-3
lines changed

4 files changed

+87
-3
lines changed

.github/workflows/build-and-deploy.yml

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
name: CI
22
on: [push]
33
jobs:
4-
publish-hidora:
5-
name: Deploy to Docker Hub & Scaleway
4+
deploy:
5+
name: Publish container and deploy
66
if: github.event_name != 'pull_request'
77
runs-on: ubuntu-latest
88
permissions:
@@ -47,7 +47,26 @@ jobs:
4747
labels: ${{ steps.meta.outputs.labels }}
4848
build-args: VERSION=${{ github.sha }}
4949

50-
- name: Redeploy container
50+
- name: Configure Kubectl
51+
run: |
52+
kubectl config set-cluster scw-cluster \
53+
--server="${{ vars.K8S_SERVER_ADDRESS }}" \
54+
--certificate-authority=<(echo "${{ vars.K8S_CA_CERT }}" | base64 -d) \
55+
--embed-certs=true
56+
57+
kubectl config set-credentials deployer --token="${{ secrets.K8S_DEPLOY_TOKEN }}"
58+
59+
kubectl config set-context default --cluster=scw-cluster --user=deployer
60+
kubectl config use-context default
61+
62+
- name: Deploy to Kubernetes
63+
run: |
64+
sed "s|/anonymizing-reverse-proxy:latest|/anonymizing-reverse-proxy:sha-${GITHUB_SHA::7}|g" deploy/deployment.yaml | \
65+
kubectl apply -f - \
66+
-f deploy/service.yaml \
67+
-f deploy/routes.yaml
68+
69+
- name: Redeploy SCW container
5170
uses: httptoolkit/scaleway-serverless-container-deploy-action@v1
5271
with:
5372
container_id: ${{ vars.SCW_API_CONTAINER_ID }}

deploy/deployment.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: anonymizing-reverse-proxy
5+
namespace: anonymizing-reverse-proxy
6+
spec:
7+
replicas: 1
8+
selector:
9+
matchLabels:
10+
app: anonymizing-reverse-proxy
11+
template:
12+
metadata:
13+
labels:
14+
app: anonymizing-reverse-proxy
15+
spec:
16+
containers:
17+
- name: server
18+
image: ghcr.io/httptoolkit/anonymizing-reverse-proxy:latest # GHA replaces :latest on build
19+
ports:
20+
- containerPort: 4000
21+
env:
22+
- name: ports
23+
value: "4000"
24+
- name: ERRORS_DOMAIN
25+
value: "http://errors.httptoolkit.tech"
26+
- name: EVENTS_DOMAIN
27+
value: "http://events.httptoolkit.tech"
28+
- name: TRUSTED_PROXIES
29+
value: "172.16.4.0/22"

deploy/routes.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
apiVersion: gateway.networking.k8s.io/v1
2+
kind: HTTPRoute
3+
metadata:
4+
name: anonymizing-reverse-proxy-route
5+
namespace: anonymizing-reverse-proxy
6+
spec:
7+
parentRefs:
8+
- name: primary-gateway
9+
namespace: gateway
10+
sectionName: https-httptoolkit-tech
11+
- name: secondary-gateway
12+
namespace: gateway
13+
sectionName: https-httptoolkit-tech
14+
hostnames:
15+
- "anonymizing-reverse-proxy.httptoolkit.tech"
16+
rules:
17+
- matches:
18+
- path:
19+
type: PathPrefix
20+
value: /
21+
backendRefs:
22+
- name: anonymizing-reverse-proxy
23+
port: 4000

deploy/service.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: anonymizing-reverse-proxy
5+
namespace: anonymizing-reverse-proxy
6+
spec:
7+
selector:
8+
app: anonymizing-reverse-proxy
9+
ports:
10+
- name: http-port
11+
protocol: TCP
12+
port: 4000
13+
targetPort: 4000

0 commit comments

Comments
 (0)