feat: gitea manifests
Some checks failed
/ deploy (push) Failing after 4s

This commit is contained in:
ange 2024-08-17 22:58:46 +07:00
parent e1abb674d0
commit c245e46383
Signed by: ange
GPG Key ID: 9E0C4157BB7BEB1D
9 changed files with 143 additions and 7 deletions

1
.env Normal file
View File

@ -0,0 +1 @@
PROD_URL=yw5n.com

View File

@ -0,0 +1,24 @@
on: push
jobs:
deploy:
runs-on: debian
steps:
- uses: actions/checkout@v1
- name: setup env
run: |
. ./.env || true
if [ "${{ gitea.ref_name }}" == prod ] && [ -n "$PROD_URL" ]; then
BASE_URL="$PROD_URL"
else
BASE_URL="${{ gitea.ref_name }}.$(tr / '\n' <<< "${{ gitea.repository }}" | tac | tr '\n' .)k8s.gmoker.com"
fi
cat <<EOF >> .env
BASE_URL="$BASE_URL"
REF_NAME="${{ gitea.ref_name }}"
EOF
cat .env
- uses: actions/k8sdeploy@v1
with:
kubeconfig: "${{ secrets.K8S }}"

View File

@ -3,27 +3,23 @@
<html>
<head>
<style>
/*
body {
background-color: #000;
color: #fff;
}
*/
table, th, td {
/*
border: 2px solid #fff;
*/
border: 2px solid #000;
border-collapse: collapse;
padding: 1ex;
}
</style>
<title>Ange DUHAYON</title>
</head>
<body>
<h1>⚠️ Site en construction! ⚠️</h1>
<table>
<tr>
<th>Plateforme</th>
<th>Plateforme (Par ordre de préférence)</th>
<th>Contact</th>
<th>Notes</th>
</tr>
@ -36,7 +32,7 @@
<td>@elrilio</td>
</tr>
<tr>
<td>Téléphone</td>
<td>Téléphone (France)</td>
<td><a href="tel:+33582951623">+33 5 82 95 16 23</a></td>
<td>⚠️ Numéro fixe, donc pas de SMS</td>
</tr>
@ -44,6 +40,11 @@
<td>Email</td>
<td><a href="mailto:ange@yw5n.com">ange@yw5n.com</a></td>
</tr>
<tr>
<td>Téléphone (Indonésie)</td>
<td><a href="tel:+6288231253958">+62 882-3125-3958</a></td>
<td>⚠️ Surcoût pour les appels depuis la France</td>
</tr>
</table>
</body>
</html>

36
manifests/bin/deploy.sh Executable file
View File

@ -0,0 +1,36 @@
#!/bin/bash -e
set -o pipefail
function kapply() {
for f in "$@"; do
kubectl apply -f \
<(envsubst "$(env | xargs printf '$%s ')" < "manifests/$f")
done
}
function kcreatesec() {
kubectl create secret generic --save-config --dry-run=client -oyaml "$@" | kubectl apply -f-
}
function kcreatecm() {
kubectl create configmap --dry-run=client -oyaml "$@" | kubectl apply -f-
}
function kgseckey() {
local sec="$1"; shift
local key="$1"; shift
kubectl get secret "$sec" -o jsonpath="{.data.$key}" | base64 -d
}
function kgcmkey() {
local cm="$1"; shift
local key="$1"; shift
kubectl get configmap "$cm" -o jsonpath="{.data.$key}"
}
kapply common/app.yaml
kubectl rollout restart deployment app

5
manifests/bin/devel.sh Executable file
View File

@ -0,0 +1,5 @@
#!/bin/bash -e
export NB_REPLICAS=1
. ./manifests/bin/deploy.sh

5
manifests/bin/prod.sh Executable file
View File

@ -0,0 +1,5 @@
#!/bin/bash -e
export NB_REPLICAS=3
. ./manifests/bin/deploy.sh

64
manifests/common/app.yaml Normal file
View File

@ -0,0 +1,64 @@
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: app
annotations:
cert-manager.io/cluster-issuer: letsencrypt-prod
spec:
ingressClassName: nginx
tls:
- secretName: tls-app
hosts:
- "$BASE_URL"
rules:
- host: "$BASE_URL"
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: app
port:
name: http
---
apiVersion: v1
kind: Service
metadata:
name: app
labels:
app: app
spec:
selector:
app: app
ports:
- name: http
port: 80
targetPort: http
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: app
labels:
app: app
spec:
replicas: $NB_REPLICAS
selector:
matchLabels:
app: app
template:
metadata:
labels:
app: app
spec:
imagePullSecrets:
- name: regcred
containers:
- name: app
image: "$IMAGEAPP"
imagePullPolicy: Always
ports:
- name: http
containerPort: 8000

0
manifests/devel/.gitkeep Normal file
View File

0
manifests/prod/.gitkeep Normal file
View File