2 Commits
Author SHA1 Message Date
Georgi Manchev 81772adc59 Add Kubernetes and Argo CD deployment manifests 2026-09-29 02:02:14 +03:00
Georgi Manchev 9eee55162d Use runner-local Gitea registry endpoint
Publish container image / publish (push) Successful in 18s
2026-09-29 01:36:22 +03:00
8 changed files with 161 additions and 10 deletions
+17 -8
View File
@@ -6,7 +6,7 @@ on:
- "v*.*.*" - "v*.*.*"
env: env:
REGISTRY: git.mancheff.com REGISTRY: 192.168.0.86:3000
IMAGE_NAME: hiyv-demo/hiyv-nginx IMAGE_NAME: hiyv-demo/hiyv-nginx
jobs: jobs:
@@ -38,15 +38,23 @@ jobs:
echo "tags=${image}:${version},${image}:${major_minor},${image}:${major},${image}:${GITHUB_SHA},${image}:latest" echo "tags=${image}:${version},${image}:${major_minor},${image}:${major},${image}:${GITHUB_SHA},${image}:latest"
} >> "${GITHUB_OUTPUT}" } >> "${GITHUB_OUTPUT}"
- name: Log in to the Gitea registry - name: Configure Gitea registry credentials
uses: docker/login-action@v3 shell: bash
with: env:
registry: ${{ env.REGISTRY }} REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
username: ${{ secrets.REGISTRY_USERNAME }} REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
password: ${{ secrets.REGISTRY_TOKEN }} run: |
mkdir -p "${HOME}/.docker"
auth="$(printf '%s:%s' "${REGISTRY_USERNAME}" "${REGISTRY_TOKEN}" | base64 | tr -d '\n')"
printf '{"auths":{"%s":{"auth":"%s"}}}\n' "${REGISTRY}" "${auth}" > "${HOME}/.docker/config.json"
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
with:
buildkitd-config-inline: |
[registry."192.168.0.86:3000"]
http = true
insecure = true
- name: Build and publish - name: Build and publish
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
@@ -55,9 +63,10 @@ jobs:
push: true push: true
build-args: | build-args: |
COMMIT_ID=${{ github.sha }} COMMIT_ID=${{ github.sha }}
NGINX_BASE=${{ env.REGISTRY }}/hiyv-demo/nginx-base:1.28-alpine-amd64
tags: ${{ steps.tags.outputs.tags }} tags: ${{ steps.tags.outputs.tags }}
labels: | labels: |
org.opencontainers.image.version=${{ steps.tags.outputs.version }} org.opencontainers.image.version=${{ steps.tags.outputs.version }}
org.opencontainers.image.revision=${{ github.sha }} org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }} org.opencontainers.image.source=https://git.mancheff.com/${{ github.repository }}
platforms: linux/amd64 platforms: linux/amd64
+2 -1
View File
@@ -1,4 +1,5 @@
FROM git.mancheff.com/hiyv-demo/nginx-base:1.28-alpine-amd64 ARG NGINX_BASE=git.mancheff.com/hiyv-demo/nginx-base:1.28-alpine-amd64
FROM ${NGINX_BASE}
ARG COMMIT_ID=unknown ARG COMMIT_ID=unknown
+29 -1
View File
@@ -6,7 +6,7 @@ Git commit used to build the published container.
## Run it ## Run it
```sh ```sh
docker run --rm -p 8080:80 git.mancheff.com/hiyv-demo/hiyv-nginx:1.0.2 docker run --rm -p 8080:80 git.mancheff.com/hiyv-demo/hiyv-nginx:1.0.3
``` ```
Open <http://localhost:8080>. The health endpoint is available at Open <http://localhost:8080>. The health endpoint is available at
@@ -46,3 +46,31 @@ packages.
```sh ```sh
docker build --build-arg COMMIT_ID="$(git rev-parse HEAD)" -t hiyv-nginx:local . docker build --build-arg COMMIT_ID="$(git rev-parse HEAD)" -t hiyv-nginx:local .
``` ```
## Deploy with Argo CD
The Kubernetes manifests in `k8s/` deploy two HIYV replicas and expose them
through a cluster-internal Service. They use the public Gitea image directly;
no `imagePullSecrets` are required.
The repository URL is deliberately not hard-coded. Set `HIYV_GIT_REPO` to the
public Git repository that contains these manifests, make sure the Argo CD CLI
is authenticated, and run:
```sh
export HIYV_GIT_REPO='<public Git repository URL>'
./scripts/create-argocd-application.sh
```
If `HIYV_GIT_REPO` is unset, the script explains what is missing and exits
without changing Argo CD. When it is set, the script creates or updates the
`hiyv` Application with automated sync, pruning, self-healing, and namespace
creation enabled.
Optional configuration:
- `HIYV_GIT_REVISION` (default: `main`)
- `HIYV_MANIFEST_PATH` (default: `k8s`)
- `HIYV_ARGOCD_APP_NAME` (default: `hiyv`)
- `HIYV_DESTINATION_SERVER` (default: in-cluster Kubernetes API)
- `HIYV_DESTINATION_NAMESPACE` (default: `hiyv`)
+44
View File
@@ -0,0 +1,44 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: hiyv
namespace: hiyv
labels:
app.kubernetes.io/name: hiyv
spec:
replicas: 2
selector:
matchLabels:
app.kubernetes.io/name: hiyv
template:
metadata:
labels:
app.kubernetes.io/name: hiyv
spec:
containers:
- name: hiyv
image: git.mancheff.com/hiyv-demo/hiyv-nginx:1.0.3
imagePullPolicy: IfNotPresent
ports:
- name: http
containerPort: 80
protocol: TCP
readinessProbe:
httpGet:
path: /healthz
port: http
initialDelaySeconds: 2
periodSeconds: 10
livenessProbe:
httpGet:
path: /healthz
port: http
initialDelaySeconds: 5
periodSeconds: 30
resources:
requests:
cpu: 25m
memory: 32Mi
limits:
cpu: 250m
memory: 128Mi
+6
View File
@@ -0,0 +1,6 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- namespace.yaml
- deployment.yaml
- service.yaml
+6
View File
@@ -0,0 +1,6 @@
apiVersion: v1
kind: Namespace
metadata:
name: hiyv
labels:
app.kubernetes.io/name: hiyv
+16
View File
@@ -0,0 +1,16 @@
apiVersion: v1
kind: Service
metadata:
name: hiyv
namespace: hiyv
labels:
app.kubernetes.io/name: hiyv
spec:
type: ClusterIP
selector:
app.kubernetes.io/name: hiyv
ports:
- name: http
port: 80
targetPort: http
protocol: TCP
+41
View File
@@ -0,0 +1,41 @@
#!/usr/bin/env bash
set -euo pipefail
if [[ -z "${HIYV_GIT_REPO:-}" ]]; then
cat <<'EOF'
HIYV_GIT_REPO is not set, so no Argo CD Application was created.
Set it to the public Git repository containing the Kubernetes manifests, then
run this script again. For example:
export HIYV_GIT_REPO='<public Git repository URL>'
./scripts/create-argocd-application.sh
EOF
exit 0
fi
if ! command -v argocd >/dev/null 2>&1; then
echo "The argocd CLI is required and must be available in PATH." >&2
exit 1
fi
app_name="${HIYV_ARGOCD_APP_NAME:-hiyv}"
revision="${HIYV_GIT_REVISION:-main}"
manifest_path="${HIYV_MANIFEST_PATH:-k8s}"
destination_server="${HIYV_DESTINATION_SERVER:-https://kubernetes.default.svc}"
destination_namespace="${HIYV_DESTINATION_NAMESPACE:-hiyv}"
argocd app create "${app_name}" \
--upsert \
--repo "${HIYV_GIT_REPO}" \
--revision "${revision}" \
--path "${manifest_path}" \
--dest-server "${destination_server}" \
--dest-namespace "${destination_namespace}" \
--sync-policy automated \
--auto-prune \
--self-heal \
--sync-option CreateNamespace=true
echo "Argo CD Application '${app_name}' now tracks ${HIYV_GIT_REPO}@${revision}:${manifest_path}."