first commit
Some checks failed
/ deploy (push) Failing after 5s

This commit is contained in:
ange 2025-05-23 04:19:21 +00:00
commit ae95b80af9
Signed by: ange
GPG Key ID: 9E0C4157BB7BEB1D
10 changed files with 158 additions and 0 deletions

1
.env Normal file
View File

@ -0,0 +1 @@
BASE_URL=cocoonlovina.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"
EOF
cat .env
- uses: actions/k8sdeploy@v1
with:
kubeconfig: "${{ secrets.K8S }}"
registry_password: "${{ secrets.PKGRW }}"

1
README.md Normal file
View File

@ -0,0 +1 @@
# cocoon.com

9
default.conf Normal file
View File

@ -0,0 +1,9 @@
server {
listen 80;
listen [::]:80;
server_name $BASE_URL;
location / {
proxy_pass https://contact978194.wixsite.com/cocoon-lovina-ok;
}
}

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

@ -0,0 +1,40 @@
#!/bin/bash -e
set -o pipefail
function kapply() {
for f in "$@"; do
kubectl apply --server-side \
-f<(envsubst "$(env | sed 's/^/$/')" < "manifests/$f")
done
}; export -f kapply
function kcreatesec() {
kubectl apply --server-side \
-f<(kubectl create secret generic --dry-run=client -oyaml "$@")
}; export -f kcreatesec
function kcreatecm() {
kubectl apply --server-side \
-f<(kubectl create configmap --dry-run=client -oyaml "$@")
}; export -f kcreatecm
function kgseckey() {
local sec="$1"; shift
local key="$1"; shift
kubectl get secret "$sec" -ojson | jq -re ".data.\"$key\"" | base64 -d
}; export -f kgseckey
function kgcmkey() {
local cm="$1"; shift
local key="$1"; shift
kubectl get configmap "$cm" -ojson | jq -re ".data.\"$key\""
}; export -f kgcmkey
kcreatecm conf --from-file=default.conf
kapply common/app.yaml
kubectl rollout restart deployment app

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

@ -0,0 +1,6 @@
#!/bin/bash -e
set -o pipefail
export NB_REPLICAS=1
. ./manifests/bin/deploy.sh

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

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

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

@ -0,0 +1,71 @@
---
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: docker.io/nginx:latest
imagePullPolicy: Always
ports:
- name: http
containerPort: 3000
volumeMounts:
- name: conf
mountPath: /etc/nginx/conf.d/
volumes:
- name: config
configMap:
name: conf

0
manifests/devel/.gitkeep Normal file
View File

0
manifests/prod/.gitkeep Normal file
View File