Health probe for custom nginx image returning "not ready"

Asking for help? Comment out what you need so we can get more information to help you!

Cluster information:

Kubernetes version:
Client Version: version.Info{Major:“1”, Minor:“22”, GitVersion:“v1.22.0”, GitCommit:“c2b5237ccd9c0f1d600d3072634ca66cefdf272f”, GitTreeState:“clean”, BuildDate:“2021-08-04T18:03:20Z”, GoVersion:“go1.16.6”, Compiler:“gc”, Platform:“linux/amd64”}
Server Version: version.Info{Major:“1”, Minor:“21”, GitVersion:“v1.21.1”, GitCommit:“5e58841cce77d4bc13713ad2b91fa0d961e69192”, GitTreeState:“clean”, BuildDate:“2021-05-21T23:01:33Z”, GoVersion:“go1.16.4”, Compiler:“gc”, Platform:“linux/amd64”}

Cloud being used: DigitalOcean droplet
Installation method: kind
Host OS: ubuntu v21
CNI and version:
CRI and version:

You can format your yaml by highlighting it and pressing Ctrl-Shift-C, it will make your output easier to read.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: frontend-deployment-v2
  namespace: ingress-nginx
spec:
  replicas: 1
  selector:
    matchLabels:
      app: frontend-app
  template:
    metadata:
      name: frontend-pod
      labels:
        app: frontend-app
    spec:
      imagePullSecrets:
      - name: ghcr-secret
      containers:
      - name: frontend-container-v2
        image: ghcr.io/...
        imagePullPolicy: IfNotPresent
        env:
        - name: REACT_APP_ENV
          value: "production"
         ports:
          - containerPort: 3000
            name: frontend-p-port
        readinessProbe:
          httpGet:
            path: /
            port: 3000
          initialDelaySeconds: 3
          periodSeconds: 4

The docker image is pulled from a private ghcr.io hosted package. The docker file ends with

ENTRYPOINT ["nginx", "-g", "daemon off;"]

The image works as expected using docker. The image also runs in the cluster. However, the health-check seems to indicate failure.

NAME                                     READY   STATUS    RESTARTS   AGE
frontend-deployment-v2-699bb477c-5c8hc   0/1     Running   0          50m

Does anyone know why this might be?

Thank you in advance.

I suspect the answer lies in the fact that the port entry for the deployment

  1. is not actually used to set the port, but is used to “document”
  2. is not the port used by the image (in this case 80)

In that case, the readiness probe will always indicate false. When I change the entries to 80 (instead of 3000), the pod reflects the expected ready state.

Can anyone provide some guidance on when to know whether a setting is used to “align” the value with the “already” fixed value, versus actually setting the port value?

The readiness probe you set is used by kubernetes to test the container running inside the Pod. process inside the Pod is configured to listen on a different port, usually what you want to do is set the port the process is listening on using an environment variable from the deployment itself and align the containerPort with the port the application is actually using.

I think the failure lies in the fact that Kubernetes is not configuring the application itself (i.e. the process running inside the container), you can do that in numerous ways (environment variables, config file mounted as a configmap or even hard coded).
Kubernetes is in charge of how the application behaves , hence tests (such as startup, readiness, liveness), and other configurations do not impact the way the process itself behaves but how the environment reacts to it (in the case described above - readiness probe failed - no traffic being sent to the Pod through the service).

1 Like

Thank you for the response. It would be great to have a snippet for how to ensure the docker and kube configurations should be set.