ingress kubernetes zabbix error 404 not found

1. ingress kubernetes zabbix error 404 not found

R junior
R_junior

(usa Outra)

Enviado em 17/07/2024 - 14:26h

boa tarde

Estou com uma implantação no cluster kubernetes EKs da estrutura helm zabbix-server-psql, depois de configura-lo e usar o helm chart oficial do zabbix-postgres preciso configurar o acesso ao pod do zabbix-web através do ingress ele configura e compila sem erros porem quando acesso a pagina através da URL do ingress da 'erro 404 not found' o Ingress funciona na porta 80 e o container esta funcionando na porta 8080.
Erro
404 Not Found

Configuração do ingress deploy
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "zabbix.fullname" . -}}
{{- $svcPort := .Values.zabbixWeb.service.port -}}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ $fullName }}
labels:
{{- include "zabbix.labels" . | nindent 4 }}
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
ingressClassName: {{ .Values.ingress.className }}
{{- if .Values.ingress.tls }}
tls:
{{- range .Values.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
rules:
{{- range .Values.ingress.hosts }}
- host: {{ .host | quote }}
http:
paths:
{{- range .paths }}
- path: {{ .path }}
pathType: {{ .pathType }}
backend:
service:
name: {{ $fullName }}-zabbix-web
port:
number: {{ .servicePort | default $svcPort }}
{{- end }}
{{- end }}
{{- end }}


Configuração do zabbix-web-deploy.yaml
{{- if .Values.zabbixWeb.enabled }}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ template "zabbix.fullname" . }}-zabbix-web
labels:
app: {{ template "zabbix.fullname" . }}-zabbix-web
app.kubernetes.io/name: zabbix-web
helm.sh/chart: {{ include "zabbix.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}-zabbix-web
app.kubernetes.io/managed-by: {{ .Release.Service }}-zabbix-web
{{- if .Values.zabbixWeb.deploymentLabels }}
{{- toYaml .Values.zabbixWeb.deploymentLabels | nindent 4 }}
{{- end }}
annotations:
{{- range $key,$value := .Values.zabbixWeb.deploymentAnnotations }}
{{ $key }}: {{ $value | quote }}
{{- end }}
spec:
replicas: {{ .Values.zabbixWeb.replicaCount }}
selector:
matchLabels:
app: {{ template "zabbix.fullname" . }}-zabbix-web
template:
metadata:
annotations:
{{- range $key,$value := .Values.zabbixWeb.containerAnnotations }}
{{ $key }}: {{ $value | quote }}
{{- end }}
labels:
app: {{ template "zabbix.fullname" . }}-zabbix-web
app.kubernetes.io/name: zabbix-web
helm.sh/chart: {{ include "zabbix.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}-zabbix-web
app.kubernetes.io/managed-by: {{ .Release.Service }}-zabbix-web
{{- if .Values.zabbixWeb.containerLabels }}
{{- toYaml .Values.zabbixWeb.containerLabels | nindent 8 }}
{{- end }}
spec:
serviceAccountName: {{ template "zabbix.serviceAccountName" . }}
{{- with .Values.zabbixWeb.extraPodSpecs }}
{{- toYaml . | nindent 6 }}
{{- end }}
{{- with .Values.zabbixWeb.extraInitContainers }}
initContainers:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if .Values.karpenter.enabled }}
{{- with .Values.karpenter.labels }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- else }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
{{- if gt (len .Values.affinity) 0 }}
affinity:
{{- toYaml .Values.affinity | nindent 8 }}
{{- else if .Values.zabbixWeb.podAntiAffinity }}
affinity:
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 1
podAffinityTerm:
topologyKey: kubernetes.io/hostname
labelSelector:
matchLabels:
app.kubernetes.io/instance: {{ .Release.Name }}-zabbix-web
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: zabbix-web
resources:
{{- toYaml .Values.zabbixWeb.resources | nindent 10 }}
securityContext:
{{- toYaml .Values.zabbixWeb.securityContext | nindent 10 }}
{{- if .Values.zabbixWeb.image.tag }}
image: "{{ .Values.zabbixWeb.image.repository }}:{{ .Values.zabbixWeb.image.tag }}"
{{- else }}
image: "{{ .Values.zabbixWeb.image.repository }}:{{ .Values.zabbixImageTag }}"
{{- end }}
imagePullPolicy: {{ .Values.zabbixWeb.image.pullPolicy }}
env:
{{- include "zabbix.postgresAccess.variables" (list $ . "zabbix") | nindent 10 }}
{{- with .Values.zabbixWeb.extraEnv }}
{{- toYaml . | nindent 10 }}
{{- end }}
ports:
- name: zabbix-web
containerPort: 8080
protocol: TCP
volumeMounts:
{{- if .Values.zabbixWeb.samlCertsSecretName }}
- name: zabbix-web-samlcerts
mountPath: /etc/zabbix/web/certs
{{- end }}
{{- with .Values.zabbixWeb.extraVolumeMounts }}
{{- toYaml . | nindent 10 }}
{{- end }}
{{- with .Values.zabbixWeb.livenessProbe }}
livenessProbe:
{{- toYaml . | nindent 10 }}
{{- end }}
{{- with .Values.zabbixWeb.readinessProbe }}
readinessProbe:
{{- toYaml . | nindent 10 }}
{{- end }}
{{- with .Values.zabbixWeb.startupProbe }}
startupProbe:
{{- toYaml . | nindent 10 }}
{{- end }}
{{- with .Values.zabbixWeb.extraContainers }}
{{- toYaml . | nindent 6 }}
{{- end }}
imagePullSecrets:
{{- range .Values.zabbixWeb.image.pullSecrets }}
- name: {{ . | quote }}
{{- end }}
volumes:
{{- if .Values.zabbixWeb.samlCertsSecretName }}
- name: zabbix-web-samlcerts
secret:
secretName: {{ .Values.zabbixWeb.samlCertsSecretName }}
{{- end }}
{{- with .Values.zabbixWeb.extraVolumes }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}


configuração de ingress no values.yaml
# Ingress configurations
ingress:
# -- Enables Ingress
enabled: true
# -- Ingress annotations
annotations:
kubernetes.io/ingress.class: nginx
kubernetes.io/rewrite-target: /
# -- Ingress hosts
hosts:
- host: zabbix-zabbix-web.local
paths:
- path: /
pathType: ImplementationSpecific
backend:
serviceName: zabbix-zabbix-web
servicePort: 8080

Não esta habilitado o 'IngressRoute' e nem o 'route' para usar o openshift.

No kubernetes aparece o service e os pods sem erros
NAME                TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)   AGE
zabbix-zabbix-web ClusterIP ip_local <none> 80/TCP


kubernetes describe do ingress do zabbix
Name:             zabbix
Labels: app.kubernetes.io/instance=zabbix
app.kubernetes.io/managed-by=Helm
app.kubernetes.io/name=zabbix
app.kubernetes.io/version=7.0.1
helm.sh/chart=zabbix-5.0.0
Namespace: hml
Address: ingress-nginx-hml-8015.elb.us-east-1.amazonaws.com
Ingress Class: <none>
Default backend: <default>
Rules:
Host Path Backends
---- ---- --------
zabbix-zabbix-web.local
/ zabbix-zabbix-web:80 (ip_localB:8080)
Annotations: kubernetes.io/ingress.class: nginx
kubernetes.io/rewrite-target: /
Events: <none>

Quando faço o teste de acesso ao container do pod via o ip do pod na porta 8080 ele retorna as informações da pagina.

kubectl exec -it zabbix-zabbix-web-2p65s -n homolog  -- curl -v -H "Host: zabbix-zabbix-web IP_localA:8080

* Trying ip_interno:8080...
* Connected to ip_localA (ip_localB) port 8080
> GET / HTTP/1.1
> Host: zabbix-zabbix-web
> User-Agent: curl/8.5.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Server: nginx/1.24.0 (Ubuntu)
< Date: Tue, 16 Jul 2024 17:44:52 GMT
< Content-Type: text/html; charset=UTF-8
< Transfer-Encoding: chunked
< Connection: keep-alive
< Keep-Alive: timeout=20
< X-Powered-By: PHP/8.3.6
< Expires: Thu, 19 Nov 1981 08:52:00 GMT
< Cache-Control: no-store, no-cache, must-revalidate
< Pragma: no-cache
< X-Content-Type-Options: nosniff
< X-XSS-Protection: 1; mode=block
< X-Frame-Options: SAMEORIGIN
< Set-Cookie: zbx_session=eyJzZXNzaW9uaWQiOiIyNWQyNTczNzZlZjkyZGM5NzQ2NDRhYWQxNThkMjA0OSIsInNpZ24iOiJiYTg3ZjZhYTg0ZmEwNWNmNzE2YzgwMGY2M2QzYWE5MjVhN2RmNzRiMWEzYmNiN2NkYzNlNGY3NWFhNTRkZWY4In0%3D; HttpOnly
<
<!DOCTYPE html><html lang="en" theme="blue-theme" color-scheme="light"> <head>
<meta http-equiv="X-UA-Compatible" content="IE=Edge"/>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="Author" content="Zabbix SIA" /><title>Zabbix docker: Zabbix</title> <link rel="icon" href="favicon.ico">
<link rel="apple-touch-icon-precomposed" sizes="76x76" href="assets/img/apple-touch-icon-76x76-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="120x120" href="assets/img/apple-touch-icon-120x120-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="assets/img/apple-touch-icon-152x152-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="180x180" href="assets/img/apple-touch-icon-180x180-precomposed.png">
<link rel="icon" sizes="192x192" href="assets/img/touch-icon-192x192.png">
<meta name="msapplication-TileImage" content="assets/img/ms-tile-144x144.png">
<meta name="msapplication-TileColor" content="#d40000">
<meta name="msapplication-config" content="none"/><link rel="stylesheet" type="text/css" href="assets/styles/blue-theme.css?1717482144"><style>:root {
--severity-color-na-bg: #97AAB3;
--severity-color-info-bg: #7499FF;
--severity-color-warning-bg: #FFC859;
--severity-color-average-bg: #FFA059;
--severity-color-high-bg: #E97659;
--severity-color-disaster-bg: #E45959;

Quando acesso através da mesma URL do ingress retorna erro 404 not found
kubectl exec -it zabbix-zabbix-web-2p65s -n hml  -- curl -v -H "Host: zabbix-zabbix-web" ingress-nginx-hml-8015.elb.us-east-1.amazonaws.com

* Host ingress-nginx-hml-8015.elb.us-east-1.amazonaws.com:80 was resolved.
* IPv6: (none)
* IPv4: 40...38,
* Trying 40...38:80...
* Connected to ingress-nginx-hml-8015.elb.us-east-1.amazonaws.com (40...38) port 80
> GET / HTTP/1.1
> Host: zabbix-zabbix-web
> User-Agent: curl/8.5.0
> Accept: */*
>
< HTTP/1.1 404 Not Found
< Date: Tue, 16 Jul 2024 18:46:24 GMT
< Content-Type: text/html
< Content-Length: 146
< Connection: keep-alive

Configuração do SVC do zabbix-web
Name:              zabbix-zabbix-web
Namespace: homolog
Labels: app=zabbix-zabbix-web
app.kubernetes.io/instance=zabbix-zabbix-web
app.kubernetes.io/managed-by=Helm-zabbix-web
app.kubernetes.io/name=zabbix-web
argocd.argoproj.io/instance=zabbix
helm.sh/chart=zabbix-5.0.0
Annotations: <none>
Selector: app=zabbix-zabbix-web
Type: ClusterIP
IP Family Policy: SingleStack
IP Families: IPv4
IP: IP_local-A
IPs: IP_local-A
Port: zabbix-web 80/TCP
TargetPort: 8080/TCP
Endpoints: IP_local-B:8080
Session Affinity: None
Events: <none>

Eu ja habilitei as routes ja fiz testes de acesso pelo IP interno de dentro do cluster ja alterei alguma configurações de testes ainda utilizando a configurações oficial do zabbix no log do pod mostra o acesso da LiveProbe com 200 3 quando acesso via comando kubectl mostra o acesso com cod 200 também
OBS: eu não deployei o pod de postgressBD porque uso banco no RDS esta é a única diferença, porem parece que ingress não faz o targetport da 80 para a 8080 do container, mesmo eu adicionando já em outro teste 'targetport: 8080' no deploy alguém teria alguma ideia por favor?.





  






Patrocínio

Site hospedado pelo provedor RedeHost.
Linux banner

Destaques

Artigos

Dicas

Tópicos

Top 10 do mês

Scripts