Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ingress GCE is not working due to health check being failed for backend service #2770

Open
yugandharreddy1 opened this issue Dec 13, 2024 · 0 comments

Comments

@yugandharreddy1
Copy link

We see than when we install with NIGINX everything is working fine but then changing to ingress GCE with below annotations its creating 2 services one is healthy and other is unhealthy.

ingress:
  annotations:
    - kubernetes.io/ingress.class: gce
    - kubernetes.io/ingress.allow-http: "true"
    - gcp.ingress.kubernetes.io/target-type: ip

below are the services which are being created
image
image (1)

by default the health check is checking on HTTP 80 and when i change it to TCP 3128 its becoming healthy and i was able to access the ingress URL.

image

i dont know from which service readiness probe i am getting the healthcheck created as below i didnt mention anywhere HTTP 80

Squid-svc.yaml

kind: Service
apiVersion: v1
metadata:
  name: {{ .Chart.Name }}-service
  namespace: {{ .Values.namespace}}
  labels:
spec:
  type: ClusterIP
  selector:
    app: {{ .Release.Name }}-{{ .Chart.Name }}
  ports:
    - protocol: TCP
      port: {{ .Values.svc.port }}
      targetPort: {{.Values.svc.targetPort}}
      name: http
      nodePort: null

app-ingress.yaml

{{- if .Values.ingress.enabled -}}
{{- if .Capabilities.APIVersions.Has "networking.k8s.io/v1/Ingress" }}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: app-ingress
  labels:
{{ include "app.labels" . | indent 4 }}
  annotations:
    {{- range $annotation := .Values.ingress.annotations }}
    {{- range $key, $value := $annotation }}
    {{ $key }}: {{ $value | quote }}
    {{- end }}
    {{- end }}
spec:
{{- if .Values.ingress.tls.enabled }}
  tls:
    - hosts:
        - {{ .Values.ingress.host }}
      secretName: {{ .Values.ingress.tls.secretName | default "app-tls-secrets" }}
{{- end }}
  rules:
  - host: {{ .Values.ingress.host }}
    http:
      paths:
      - pathType: ImplementationSpecific 
        backend:
          service:
            {{- if and (.Values.squid) (.Values.squid.enabled) }}
            name: {{ .Values.squid.serviceName | default "squid-service" }}
            port: 
              number: {{ .Values.squid.port | default 3128 }}
            {{- else}}
            name: app-ext
            port: 
              number: {{ .Values.app.port | default 8080 }}
            {{- end }}
            
{{- else if .Capabilities.APIVersions.Has "extensions/v1beta1/Ingress" }}
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: app-ingress
  labels:
{{ include "app.labels" . | indent 4 }}
  annotations:
    {{- range $annotation := .Values.ingress.annotations }}
    {{- range $key, $value := $annotation }}
    {{ $key }}: {{ $value | quote }}
    {{- end }}
    {{- end }}
spec:
{{- if .Values.ingress.tls.enabled }}
  tls:
    - hosts:
        - {{ .Values.ingress.host }}
      secretName: {{ .Values.ingress.tls.secretName | default "app-tls-secrets" }}
{{- end }}
  rules:
  - host: {{ .Values.ingress.host }}
    http:
      paths:
      - backend:
        {{- if and (.Values.squid) (.Values.squid.enabled) }}
          serviceName: {{ .Values.squid.serviceName | default "squid-service" }}
          servicePort: {{ .Values.squid.port | default 3128 }}
        {{- else}}
          serviceName: app-ext
          servicePort: {{ .Values.app.port | default 8080 }}
        {{- end }}
{{- end }}
{{- end }}

squid.yaml

{{- $appLabelValue := printf "%s-%s" .Release.Name .Chart.Name -}}
{{- $engineTimeoutMillis := default 12000 .Values.engineTimeoutMillis -}}
{{- $terminationGracePeriodSeconds := div (add $engineTimeoutMillis 2000 ) 1000 -}}
{{- $containerName := "squid" -}}

apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ $containerName }}
  namespace: {{ .Values.namespace}}
spec:
  replicas: {{ .Values.replicaCount }}
  strategy:
    {{- include "deployment.strategy" . | nindent 4 }}
  selector:
    matchLabels:
      app: {{ $appLabelValue }}
  template:
    metadata:
      labels:
        app: {{ $appLabelValue }}
      annotations:
        checksum/config: {{ include (print $.Chart.Name "/templates/squid-config.yaml") . | sha256sum }}
    spec:
      {{- if .Values.image.pullSecret }}
      imagePullSecrets:
        - name: {{ .Values.image.pullSecret }}
      {{- end }}
      terminationGracePeriodSeconds: {{ $terminationGracePeriodSeconds }}
      containers:
        - name: {{ $containerName }}
          image: {{ template "squid.image" .Values }}
          imagePullPolicy: {{ .Values.image.pullPolicy }}
          securityContext:
            {{- include "getDefaultSecurityContextProperties" . | nindent 12 }}
{{- if eq .Values.resources.enabled true }}
          resources:
            {{ .Values.resources | toYaml | indent 12 | trim }}
{{- end }}
          terminationMessagePolicy: FallbackToLogsOnError
          ports:
            - containerPort: 3128
          volumeMounts:
            - mountPath: /var/opt/{{ .Chart.Name }}
              name: {{ .Chart.Name }}-volume
          readinessProbe:
            tcpSocket:              
              port: 3128
            initialDelaySeconds: 30
{{- if not .Values.debugger }}
          livenessProbe:
            tcpSocket:
              port: 3128
            initialDelaySeconds: 30
{{- end }}
      volumes:
        - name: {{ .Chart.Name }}-volume
          configMap:
            name: {{.Release.Name}}-{{ .Chart.Name }}-config

app-service.yml

apiVersion: v1
kind: Service
metadata:
  name: {{ .Values.container.name }}
  labels:
{{ include "app.labels" . | indent 4 }}
spec:
  # This is needed so that DNS resolves between containers in a statefulset 
  # before they are marked "Ready", as containers are only marked "Ready" after
  # they are running.  Our containers need to talk to each other during start-up.
  publishNotReadyAddresses: true
  clusterIP: None
  ports:
    - name: http
      port: {{ .Values.app.port | default 8080 }}
      targetPort: 8080
  {{- if .Values.app.portRange }}
  {{- $ports := split "-" .Values.app.portRange -}}
  {{- range untilStep ($ports._0|int) ($ports._1|int) 1 }}
    - name: tcp-{{ . }}
      port: {{ . }}
      protocol: TCP
      targetPort: {{ . }}
  {{- end }}
  {{- end }}
  selector:
    app: {{ template "app.name" . }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant