From 95ae165232e10cad4ef20a920b2eb89709cf674a Mon Sep 17 00:00:00 2001 From: Nicholas Ward Date: Tue, 4 Aug 2026 16:39:50 -0500 Subject: [PATCH] deploy web log with k3s --- .gitea/workflows/build-and-push-image.yaml | 36 ++++++++++++ k8s/kustomization.yaml | 13 +++++ k8s/web-log-deployment.yaml | 60 ++++++++++++++++++++ k8s/web-log-files-deployment.yaml | 65 ++++++++++++++++++++++ k8s/web-log-files-ingress.yaml | 19 +++++++ k8s/web-log-files-service.yaml | 15 +++++ k8s/web-log-ingress.yaml | 19 +++++++ k8s/web-log-service.yaml | 15 +++++ 8 files changed, 242 insertions(+) create mode 100644 k8s/kustomization.yaml create mode 100644 k8s/web-log-deployment.yaml create mode 100644 k8s/web-log-files-deployment.yaml create mode 100644 k8s/web-log-files-ingress.yaml create mode 100644 k8s/web-log-files-service.yaml create mode 100644 k8s/web-log-ingress.yaml create mode 100644 k8s/web-log-service.yaml diff --git a/.gitea/workflows/build-and-push-image.yaml b/.gitea/workflows/build-and-push-image.yaml index 8b956de..4056d3a 100644 --- a/.gitea/workflows/build-and-push-image.yaml +++ b/.gitea/workflows/build-and-push-image.yaml @@ -43,6 +43,42 @@ jobs: - name: ๐Ÿš€ Push Docker image run: docker push $IMAGE_REGISTRY/$IMAGE_NAME:$IMAGE_TAG + + - name: Install kubectl + env: + KUBECTL_VERSION: v1.36.2 + run: | + set -euo pipefail + curl -fsSLO "https://dl.k8s.io/release/${KUBECTL_VERSION}/bin/linux/amd64/kubectl" + curl -fsSLO "https://dl.k8s.io/release/${KUBECTL_VERSION}/bin/linux/amd64/kubectl.sha256" + printf '%s %s\n' "$(cat kubectl.sha256)" kubectl | sha256sum --check + sudo install -m 0755 kubectl /usr/local/bin/kubectl + + - name: Configure Kubernetes access + env: + KUBE_CONFIG: ${{ secrets.KUBE_CONFIG }} + run: | + set -euo pipefail + mkdir -p ~/.kube + printf '%s' "$KUBE_CONFIG" | base64 --decode > ~/.kube/config + chmod 600 ~/.kube/config + kubectl auth can-i update deployments --namespace nicholas + + - name: Deploy web log and files service + run: | + set -euo pipefail + sed -E -i "s#newTag: [0-9a-f]+#newTag: ${IMAGE_TAG}#" k8s/kustomization.yaml + grep -q "newTag: ${IMAGE_TAG}$" k8s/kustomization.yaml + kubectl apply --kustomize k8s + if ! kubectl rollout status deployment/web-log \ + --namespace nicholas --timeout=180s; then + kubectl rollout undo deployment/web-log --namespace nicholas + kubectl rollout status deployment/web-log \ + --namespace nicholas --timeout=180s + exit 1 + fi + kubectl rollout status deployment/web-log-files \ + --namespace nicholas --timeout=180s - name: ๐Ÿงน Prune images if: always() diff --git a/k8s/kustomization.yaml b/k8s/kustomization.yaml new file mode 100644 index 0000000..958670d --- /dev/null +++ b/k8s/kustomization.yaml @@ -0,0 +1,13 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +namespace: nicholas +resources: + - web-log-deployment.yaml + - web-log-service.yaml + - web-log-ingress.yaml + - web-log-files-deployment.yaml + - web-log-files-service.yaml + - web-log-files-ingress.yaml +images: + - name: git.uuard.com/nicholas/web-log + newTag: 45b11ce88ad5a0e6854f9ba40710f56d66e6b955 diff --git a/k8s/web-log-deployment.yaml b/k8s/web-log-deployment.yaml new file mode 100644 index 0000000..3dddfd2 --- /dev/null +++ b/k8s/web-log-deployment.yaml @@ -0,0 +1,60 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: web-log + labels: + app.kubernetes.io/name: web-log +spec: + replicas: 2 + revisionHistoryLimit: 5 + progressDeadlineSeconds: 180 + strategy: + type: RollingUpdate + rollingUpdate: + maxUnavailable: 0 + maxSurge: 1 + selector: + matchLabels: + app.kubernetes.io/name: web-log + template: + metadata: + labels: + app.kubernetes.io/name: web-log + spec: + imagePullSecrets: + - name: gitea-registry + containers: + - name: web-log + image: git.uuard.com/nicholas/web-log + imagePullPolicy: IfNotPresent + ports: + - name: http + containerPort: 80 + protocol: TCP + readinessProbe: + httpGet: + path: / + port: http + initialDelaySeconds: 2 + periodSeconds: 5 + timeoutSeconds: 2 + failureThreshold: 6 + livenessProbe: + httpGet: + path: / + port: http + initialDelaySeconds: 10 + periodSeconds: 10 + timeoutSeconds: 2 + failureThreshold: 3 + resources: + requests: + cpu: 10m + memory: 32Mi + limits: + cpu: 100m + memory: 128Mi + securityContext: + allowPrivilegeEscalation: false + seccompProfile: + type: RuntimeDefault diff --git a/k8s/web-log-files-deployment.yaml b/k8s/web-log-files-deployment.yaml new file mode 100644 index 0000000..8ab39c2 --- /dev/null +++ b/k8s/web-log-files-deployment.yaml @@ -0,0 +1,65 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: web-log-files + labels: + app.kubernetes.io/name: web-log-files +spec: + replicas: 2 + revisionHistoryLimit: 5 + strategy: + type: RollingUpdate + rollingUpdate: + maxUnavailable: 0 + maxSurge: 1 + selector: + matchLabels: + app.kubernetes.io/name: web-log-files + template: + metadata: + labels: + app.kubernetes.io/name: web-log-files + spec: + containers: + - name: web-log-files + image: nginx:1.30.3-alpine + imagePullPolicy: IfNotPresent + ports: + - name: http + containerPort: 80 + protocol: TCP + readinessProbe: + tcpSocket: + port: http + initialDelaySeconds: 2 + periodSeconds: 5 + timeoutSeconds: 2 + failureThreshold: 6 + livenessProbe: + tcpSocket: + port: http + initialDelaySeconds: 10 + periodSeconds: 10 + timeoutSeconds: 2 + failureThreshold: 3 + resources: + requests: + cpu: 10m + memory: 32Mi + limits: + cpu: 100m + memory: 128Mi + securityContext: + allowPrivilegeEscalation: false + seccompProfile: + type: RuntimeDefault + volumeMounts: + - name: web-log-files + mountPath: /usr/share/nginx/html + readOnly: true + volumes: + - name: web-log-files + nfs: + server: nas.hosts.uuard.com + path: /mnt/data-pool/web-log-files + readOnly: true diff --git a/k8s/web-log-files-ingress.yaml b/k8s/web-log-files-ingress.yaml new file mode 100644 index 0000000..b4fec69 --- /dev/null +++ b/k8s/web-log-files-ingress.yaml @@ -0,0 +1,19 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: web-log-files + labels: + app.kubernetes.io/name: web-log-files +spec: + ingressClassName: traefik + rules: + - host: files.web-log.uuard.com + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: web-log-files + port: + name: http diff --git a/k8s/web-log-files-service.yaml b/k8s/web-log-files-service.yaml new file mode 100644 index 0000000..daacbea --- /dev/null +++ b/k8s/web-log-files-service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: web-log-files + labels: + app.kubernetes.io/name: web-log-files +spec: + type: ClusterIP + selector: + app.kubernetes.io/name: web-log-files + ports: + - name: http + port: 80 + targetPort: http + protocol: TCP diff --git a/k8s/web-log-ingress.yaml b/k8s/web-log-ingress.yaml new file mode 100644 index 0000000..3ffe204 --- /dev/null +++ b/k8s/web-log-ingress.yaml @@ -0,0 +1,19 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: web-log + labels: + app.kubernetes.io/name: web-log +spec: + ingressClassName: traefik + rules: + - host: web-log.uuard.com + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: web-log + port: + name: http diff --git a/k8s/web-log-service.yaml b/k8s/web-log-service.yaml new file mode 100644 index 0000000..b7a811b --- /dev/null +++ b/k8s/web-log-service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: web-log + labels: + app.kubernetes.io/name: web-log +spec: + type: ClusterIP + selector: + app.kubernetes.io/name: web-log + ports: + - name: http + port: 80 + targetPort: http + protocol: TCP