Add Kubernetes and Argo CD deployment manifests
This commit is contained in:
@@ -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`)
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
|
kind: Kustomization
|
||||||
|
resources:
|
||||||
|
- namespace.yaml
|
||||||
|
- deployment.yaml
|
||||||
|
- service.yaml
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: Namespace
|
||||||
|
metadata:
|
||||||
|
name: hiyv
|
||||||
|
labels:
|
||||||
|
app.kubernetes.io/name: hiyv
|
||||||
@@ -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
|
||||||
Executable
+41
@@ -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}."
|
||||||
Reference in New Issue
Block a user