deploy personal website with k3s
Build and Push Docker Image / Docker Build and Push (push) Successful in 20s

This commit is contained in:
2026-08-04 16:39:36 -05:00
parent 4db91d3ceb
commit 6e47a5186b
5 changed files with 141 additions and 0 deletions
+34
View File
@@ -31,6 +31,40 @@ jobs:
- name: 🚀 Push Docker image - name: 🚀 Push Docker image
run: docker push $IMAGE_REGISTRY/$IMAGE_NAME:$IMAGE_TAG 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 personal website
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/personal-website \
--namespace nicholas --timeout=180s; then
kubectl rollout undo deployment/personal-website --namespace nicholas
kubectl rollout status deployment/personal-website \
--namespace nicholas --timeout=180s
exit 1
fi
- name: 🧹 Prune images - name: 🧹 Prune images
if: always() if: always()
run: docker image prune -f run: docker image prune -f
+63
View File
@@ -0,0 +1,63 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: personal-website
labels:
app.kubernetes.io/name: personal-website
spec:
replicas: 2
revisionHistoryLimit: 5
progressDeadlineSeconds: 180
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 0
maxSurge: 1
selector:
matchLabels:
app.kubernetes.io/name: personal-website
template:
metadata:
labels:
app.kubernetes.io/name: personal-website
spec:
imagePullSecrets:
- name: gitea-registry
containers:
- name: personal-website
image: git.uuard.com/nicholas/personal-website
imagePullPolicy: IfNotPresent
ports:
- name: http
containerPort: 8080
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
runAsNonRoot: true
runAsUser: 101
runAsGroup: 101
seccompProfile:
type: RuntimeDefault
+19
View File
@@ -0,0 +1,19 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: personal-website
labels:
app.kubernetes.io/name: personal-website
spec:
ingressClassName: traefik
rules:
- host: nicholas.uuard.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: personal-website
port:
name: http
+10
View File
@@ -0,0 +1,10 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: nicholas
resources:
- deployment.yaml
- service.yaml
- ingress.yaml
images:
- name: git.uuard.com/nicholas/personal-website
newTag: 4db91d3ceb2b2378c805bf494701715e1c19d2ce
+15
View File
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: personal-website
labels:
app.kubernetes.io/name: personal-website
spec:
type: ClusterIP
selector:
app.kubernetes.io/name: personal-website
ports:
- name: http
port: 80
targetPort: http
protocol: TCP