diff --git a/charts/my-recipes-chart/templates/frontend-deployment.yaml b/charts/my-recipes-chart/templates/frontend-deployment.yaml index 52edc17..8973e53 100644 --- a/charts/my-recipes-chart/templates/frontend-deployment.yaml +++ b/charts/my-recipes-chart/templates/frontend-deployment.yaml @@ -25,26 +25,13 @@ spec: - containerPort: {{ .Values.frontend.service.targetPort }} name: http protocol: TCP - {{- /* compute API_BASE: prefer frontend.env.API_BASE, else use first ingress host */}} - {{- $apiBase := "" }} - {{- if .Values.frontend.env.API_BASE }} - {{- $apiBase = .Values.frontend.env.API_BASE }} - {{- else if .Values.ingress.hosts }} - {{- $firstHost := index .Values.ingress.hosts 0 }} - {{- $apiBase = printf "https://%s/api" $firstHost.host }} - {{- end }} + {{- with .Values.frontend.env }} env: - - name: API_BASE - value: {{ $apiBase | quote }} - {{- /* include any other env vars provided in values.frontend.env (skip API_BASE to avoid duplicate) */}} - {{- with .Values.frontend.env }} {{- range $key, $value := . }} - {{- if ne $key "API_BASE" }} - name: {{ $key }} value: {{ $value | quote }} {{- end }} - {{- end }} - {{- end }} + {{- end }} livenessProbe: httpGet: path: / diff --git a/charts/my-recipes-chart/templates/ingress.yaml b/charts/my-recipes-chart/templates/ingress.yaml index aeeea7a..d106c59 100644 --- a/charts/my-recipes-chart/templates/ingress.yaml +++ b/charts/my-recipes-chart/templates/ingress.yaml @@ -1,31 +1,22 @@ -{{- if .Values.ingress.enabled }} +{{- if .Values.frontend.ingress.enabled }} apiVersion: networking.k8s.io/v1 kind: Ingress metadata: - name: {{ .Release.Name }} + name: {{ .Release.Name }}-frontend namespace: {{ .Values.global.namespace }} labels: - app: {{ .Release.Name }} - {{- with .Values.ingress.annotations }} + app: {{ .Release.Name }}-frontend + component: frontend + {{- with .Values.frontend.ingress.annotations }} annotations: {{- toYaml . | nindent 4 }} {{- end }} spec: - {{- if .Values.ingress.className }} - ingressClassName: {{ .Values.ingress.className }} - {{- end }} - {{- if .Values.ingress.tls }} - tls: - {{- range .Values.ingress.tls }} - - hosts: - {{- range .hosts }} - - {{ . | quote }} - {{- end }} - secretName: {{ .secretName }} - {{- end }} + {{- if .Values.frontend.ingress.className }} + ingressClassName: {{ .Values.frontend.ingress.className }} {{- end }} rules: - {{- range .Values.ingress.hosts }} + {{- range .Values.frontend.ingress.hosts }} - host: {{ .host | quote }} http: paths: @@ -34,15 +25,65 @@ spec: pathType: {{ .pathType }} backend: service: - {{- if eq .backend "frontend" }} name: {{ $.Release.Name }}-{{ $.Values.frontend.name }} port: number: {{ $.Values.frontend.service.port }} - {{- else if eq .backend "backend" }} + {{- end }} + {{- end }} + {{- if .Values.frontend.ingress.tls }} + tls: + {{- range .Values.frontend.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} +{{- end }} + +--- + +{{- if .Values.backend.ingress.enabled }} +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ .Release.Name }}-backend + namespace: {{ .Values.global.namespace }} + labels: + app: {{ .Release.Name }}-backend + component: backend + {{- with .Values.backend.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if .Values.backend.ingress.className }} + ingressClassName: {{ .Values.backend.ingress.className }} + {{- end }} + rules: + {{- range .Values.backend.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ .path }} + pathType: {{ .pathType }} + backend: + service: name: {{ $.Release.Name }}-{{ $.Values.backend.name }} port: number: {{ $.Values.backend.service.port }} - {{- end }} {{- end }} {{- end }} + {{- if .Values.backend.ingress.tls }} + tls: + {{- range .Values.backend.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} {{- end }} diff --git a/charts/my-recipes-chart/values.yaml b/charts/my-recipes-chart/values.yaml index e326e2b..3720a8b 100644 --- a/charts/my-recipes-chart/values.yaml +++ b/charts/my-recipes-chart/values.yaml @@ -27,6 +27,17 @@ backend: env: PYTHONUNBUFFERED: "1" + ingress: + enabled: true + className: "nginx" + annotations: + cert-manager.io/cluster-issuer: "letsencrypt-prod" + hosts: + - host: api-my-recipes.dvirlabs.com + paths: + - path: / + pathType: Prefix + # Frontend configuration frontend: name: frontend @@ -38,11 +49,11 @@ frontend: service: type: ClusterIP - port: 3000 - targetPort: 3000 + port: 80 + targetPort: 80 env: - API_BASE: "https://my-recipes.dvirlabs.com/api" + API_BASE: "https://api-my-recipes.dvirlabs.com" resources: requests: @@ -52,6 +63,17 @@ frontend: cpu: 200m memory: 256Mi + ingress: + enabled: true + className: "nginx" + annotations: + cert-manager.io/cluster-issuer: "letsencrypt-prod" + hosts: + - host: my-recipes.dvirlabs.com + paths: + - path: / + pathType: Prefix + # PostgreSQL configuration postgres: name: db @@ -86,22 +108,16 @@ postgres: # Ingress configuration ingress: - enabled: true + enabled: false # Individual frontend/backend ingress resources handle routing instead className: "nginx" annotations: cert-manager.io/cluster-issuer: "letsencrypt-prod" - nginx.ingress.kubernetes.io/rewrite-target: "/$2" - nginx.ingress.kubernetes.io/use-regex: "true" hosts: - host: my-recipes.dvirlabs.com paths: - path: / pathType: Prefix backend: frontend - # use a regex to capture and rewrite /api/... to /... on the backend - - path: /api(/|$)(.*) - pathType: ImplementationSpecific - backend: backend tls: - secretName: recipes-tls hosts: diff --git a/manifests/my-recipes/values.yaml b/manifests/my-recipes/values.yaml index b8ed085..bd949eb 100644 --- a/manifests/my-recipes/values.yaml +++ b/manifests/my-recipes/values.yaml @@ -23,6 +23,16 @@ backend: env: PYTHONUNBUFFERED: "1" tag: master-895786b + ingress: + enabled: true + className: "nginx" + annotations: + cert-manager.io/cluster-issuer: "letsencrypt-prod" + hosts: + - host: api-my-recipes.dvirlabs.com + paths: + - path: / + pathType: Prefix # Frontend configuration frontend: name: frontend @@ -33,10 +43,10 @@ frontend: tag: "master-895786b" service: type: ClusterIP - port: 3000 - targetPort: 3000 + port: 80 + targetPort: 80 env: - API_BASE: "https://my-recipes.dvirlabs.com/api" + API_BASE: "https://api-my-recipes.dvirlabs.com" resources: requests: cpu: 50m @@ -44,7 +54,17 @@ frontend: limits: cpu: 200m memory: 256Mi - tag: master-88ec058 + tag: master-bd31ffb + ingress: + enabled: true + className: "nginx" + annotations: + cert-manager.io/cluster-issuer: "letsencrypt-prod" + hosts: + - host: my-recipes.dvirlabs.com + paths: + - path: / + pathType: Prefix # PostgreSQL configuration postgres: name: db @@ -72,24 +92,18 @@ postgres: limits: cpu: 1000m memory: 1Gi -# Ingress (top-level, maps frontend/backend paths) +# Ingress (top-level, disabled - use component-specific ingress instead) ingress: - enabled: true + enabled: false className: "nginx" annotations: cert-manager.io/cluster-issuer: "letsencrypt-prod" - nginx.ingress.kubernetes.io/rewrite-target: "/$2" - nginx.ingress.kubernetes.io/use-regex: "true" hosts: - host: my-recipes.dvirlabs.com paths: - path: / pathType: Prefix backend: frontend - # use a regex to capture and rewrite /api/... to /... on the backend - - path: /api(/|$)(.*) - pathType: ImplementationSpecific - backend: backend tls: - secretName: recipes-tls hosts: