Update manifests

This commit is contained in:
dvirlabs 2026-04-21 19:54:20 +03:00
parent e013edb4ee
commit 6a6ff1dfb3
4 changed files with 42 additions and 157 deletions

View File

@ -1,6 +1,7 @@
{{/* {{/*
Deployment for the gitops-status-server Deployment for the gitops-status-server
Runs nginx-unprivileged to serve the status.json file Runs a simple Flask API for status updates
Uses the gitops-status-api Docker image
*/}} */}}
apiVersion: apps/v1 apiVersion: apps/v1
kind: Deployment kind: Deployment
@ -19,12 +20,10 @@ spec:
{{- include "gitops-status-server.selectorLabels" . | nindent 6 }} {{- include "gitops-status-server.selectorLabels" . | nindent 6 }}
template: template:
metadata: metadata:
{{- with .Values.podAnnotations }}
annotations: annotations:
# Automatically roll deployment when ConfigMap changes
checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
{{- with .Values.podAnnotations }}
{{- toYaml . | nindent 8 }} {{- toYaml . | nindent 8 }}
{{- end }} {{- end }}
labels: labels:
{{- include "gitops-status-server.selectorLabels" . | nindent 8 }} {{- include "gitops-status-server.selectorLabels" . | nindent 8 }}
spec: spec:
@ -36,29 +35,12 @@ spec:
securityContext: securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }} {{- toYaml .Values.podSecurityContext | nindent 8 }}
# Init container to set up initial status.json from ConfigMap
initContainers:
- name: init-status
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
command:
- sh
- -c
- |
if [ ! -f /usr/share/nginx/html/status.json ]; then
cat > /usr/share/nginx/html/status.json <<'EOF'
{{- .Values.statusJson | toJson | nindent 10 }}
EOF
fi
volumeMounts:
- name: shared-data
mountPath: /usr/share/nginx/html
containers: containers:
- name: api - name: api
image: "{{ .Values.api.image.repository }}:{{ .Values.api.image.tag }}" image: "{{ .Values.api.image.repository }}:{{ .Values.api.image.tag }}"
imagePullPolicy: {{ .Values.api.image.pullPolicy }} imagePullPolicy: {{ .Values.api.image.pullPolicy }}
ports: ports:
- name: api - name: http
containerPort: 5000 containerPort: 5000
protocol: TCP protocol: TCP
env: env:
@ -68,10 +50,12 @@ spec:
value: "5000" value: "5000"
- name: FLASK_ENV - name: FLASK_ENV
value: "production" value: "production"
- name: STATUS_FILE
value: "/data/status.json"
livenessProbe: livenessProbe:
httpGet: httpGet:
path: /health path: /health
port: api port: http
initialDelaySeconds: 20 initialDelaySeconds: 20
periodSeconds: 10 periodSeconds: 10
timeoutSeconds: 5 timeoutSeconds: 5
@ -79,97 +63,23 @@ spec:
readinessProbe: readinessProbe:
httpGet: httpGet:
path: /ready path: /ready
port: api port: http
initialDelaySeconds: 20 initialDelaySeconds: 20
periodSeconds: 5 periodSeconds: 5
timeoutSeconds: 5 timeoutSeconds: 5
failureThreshold: 2 failureThreshold: 2
resources:
limits:
cpu: 100m
memory: 128Mi
requests:
cpu: 50m
memory: 64Mi
volumeMounts:
- name: shared-data
mountPath: /usr/share/nginx/html
- name: api-code
mountPath: /app
readOnly: true
- name: nginx
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
securityContext:
{{- toYaml .Values.securityContext | nindent 10 }}
ports:
- name: http
containerPort: {{ .Values.service.targetPort }}
protocol: TCP
# Health checks
livenessProbe:
httpGet:
path: /status.json
port: http
initialDelaySeconds: 5
periodSeconds: 10
timeoutSeconds: 3
failureThreshold: 3
readinessProbe:
httpGet:
path: /status.json
port: http
initialDelaySeconds: 2
periodSeconds: 5
timeoutSeconds: 2
failureThreshold: 2
resources: resources:
{{- toYaml .Values.resources | nindent 10 }} {{- toYaml .Values.resources | nindent 10 }}
volumeMounts: volumeMounts:
# Mount the nginx config - name: data
- name: nginx-config mountPath: /data
mountPath: /etc/nginx/nginx.conf
subPath: nginx.conf
readOnly: true
# Mount the shared data directory (status.json is writable here)
- name: shared-data
mountPath: /usr/share/nginx/html
# nginx-unprivileged needs writable directories for cache and run
- name: cache
mountPath: /var/cache/nginx
- name: run
mountPath: /var/run
# nginx needs writable /tmp for proxy buffers
- name: tmp
mountPath: /tmp
volumes: volumes:
# ConfigMap volume containing the nginx configuration # Data volume for status.json (writable emptyDir)
- name: nginx-config - name: data
configMap:
name: {{ include "gitops-status-server.fullname" . }}-nginx-config
items:
- key: nginx.conf
path: nginx.conf
# ConfigMap volume containing the API application code
- name: api-code
configMap:
name: {{ include "gitops-status-server.fullname" . }}-api
defaultMode: 0755
items:
- key: app.py
path: app.py
# Shared data volume for status.json (writable emptyDir)
- name: shared-data
emptyDir: emptyDir:
sizeLimit: 1Mi sizeLimit: 1Mi
# Empty directories for nginx runtime
- name: cache
emptyDir: {}
- name: run
emptyDir: {}
- name: tmp
emptyDir: {}
{{- with .Values.nodeSelector }} {{- with .Values.nodeSelector }}
nodeSelector: nodeSelector:
{{- toYaml . | nindent 8 }} {{- toYaml . | nindent 8 }}

View File

@ -1,7 +1,7 @@
{{/* {{/*
Service for the gitops-status-server Service for the gitops-status-server
Exposes the nginx server inside the cluster (ClusterIP) Exposes the Flask API inside the cluster (ClusterIP)
This allows Grafana to query the status.json endpoint This allows rsyslog pipeline and Grafana to query the API endpoints
*/}} */}}
apiVersion: v1 apiVersion: v1
kind: Service kind: Service
@ -17,7 +17,7 @@ spec:
type: {{ .Values.service.type }} type: {{ .Values.service.type }}
ports: ports:
- port: {{ .Values.service.port }} - port: {{ .Values.service.port }}
targetPort: {{ .Values.service.targetPort }} targetPort: http
protocol: TCP protocol: TCP
name: http name: http
selector: selector:

View File

@ -5,23 +5,16 @@
# Number of replicas for the deployment # Number of replicas for the deployment
replicaCount: 1 replicaCount: 1
# Container image configuration # API backend container configuration
image:
# Use nginx-unprivileged for better security (runs as non-root)
repository: nginxinc/nginx-unprivileged
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion
tag: "1.25-alpine"
# API backend container configuration (handles POST requests)
api: api:
image: image:
# Python Flask API for handling status updates # Use the gitops-status-api image (Python Flask API)
repository: python # Build from: gitops-status-api/Dockerfile
# Tag with: docker build -t gitops-status-api:latest gitops-status-api/
# Can be from Harbor registry or built locally
repository: gitops-status-api
pullPolicy: IfNotPresent pullPolicy: IfNotPresent
tag: "3.11-alpine" tag: "latest"
# Pre-install Flask via pip before running the app
pip_packages: "Flask==2.3.2"
# Image pull secrets for private registries # Image pull secrets for private registries
imagePullSecrets: [] imagePullSecrets: []
@ -36,8 +29,6 @@ service:
type: ClusterIP type: ClusterIP
# Port where the service will be exposed # Port where the service will be exposed
port: 80 port: 80
# Target port on the container (nginx default)
targetPort: 8080
# Annotations to add to the service # Annotations to add to the service
annotations: {} annotations: {}
@ -45,10 +36,10 @@ service:
resources: resources:
limits: limits:
cpu: 100m cpu: 100m
memory: 64Mi memory: 128Mi
requests: requests:
cpu: 50m cpu: 50m
memory: 32Mi memory: 64Mi
# Node selector for pod assignment # Node selector for pod assignment
nodeSelector: {} nodeSelector: {}
@ -62,8 +53,8 @@ affinity: {}
# Security context for the pod # Security context for the pod
podSecurityContext: podSecurityContext:
runAsNonRoot: true runAsNonRoot: true
runAsUser: 101 runAsUser: 1000
fsGroup: 101 fsGroup: 1000
# Security context for the container # Security context for the container
securityContext: securityContext:
@ -71,17 +62,7 @@ securityContext:
capabilities: capabilities:
drop: drop:
- ALL - ALL
readOnlyRootFilesystem: true readOnlyRootFilesystem: false
# Status JSON content
# This can be overridden in your values to customize the status information
statusJson:
repo: "rsyslog"
server: "rsyslog-lab"
sync_status: "UNKNOWN"
drift_count: 0
files: []
last_check: ""
# Labels to add to all resources # Labels to add to all resources
labels: {} labels: {}

View File

@ -1,5 +1,5 @@
# Values for gitops-status-server Helm chart # Values for gitops-status-server Helm chart
# Serves a static status.json file via nginx with an optional API for dynamic updates # Deploys a simple Flask API for storing and retrieving GitOps status JSON
# Number of replicas # Number of replicas
replicaCount: 1 replicaCount: 1
@ -8,32 +8,26 @@ replicaCount: 1
imagePullSecrets: imagePullSecrets:
- name: harbor-regcred - name: harbor-regcred
# Container image configuration
image:
repository: nginxinc/nginx-unprivileged
tag: "1.25-alpine"
pullPolicy: IfNotPresent
# API backend configuration (Flask server for status updates) # API backend configuration (Flask server for status updates)
api: api:
image: image:
repository: harbor.dvirlabs.com/my-apps/status-api # Use the gitops-status-api image from gitops-status-api repo
# Built and pushed to Harbor or use local image
repository: harbor.dvirlabs.com/dvirlabs/gitops-status-api
tag: "latest" tag: "latest"
pullPolicy: Always pullPolicy: Always
pip_packages: "Flask==2.3.2"
# Service configuration # Service configuration
service: service:
type: ClusterIP type: ClusterIP
port: 80 port: 80
targetPort: 8080
annotations: {} annotations: {}
# Status JSON content - customize with your actual GitOps status information # Resource limits
statusJson: resources:
repo: "observability-stack" limits:
server: "rsyslog-lab" cpu: 100m
sync_status: "UNKNOWN" memory: 128Mi
drift_count: 0 requests:
files: [] cpu: 50m
last_check: "" memory: 64Mi