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

Connect a Frontend to a Backend Using Services #45965

Open
assafseif opened this issue Apr 22, 2024 · 13 comments
Open

Connect a Frontend to a Backend Using Services #45965

assafseif opened this issue Apr 22, 2024 · 13 comments
Labels
language/en Issues or PRs related to English language needs-kind Indicates a PR lacks a `kind/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. triage/needs-information Indicates an issue needs more information in order to work on it.

Comments

@assafseif
Copy link

assafseif commented Apr 22, 2024

Why i cant server frontend deployment

i got

2024/04/22 11:20:02 [emerg] 1#1: host not found in upstream "hello" in /etc/nginx/conf.d/frontend.conf:2
nginx: [emerg] host not found in upstream "hello" in /etc/nginx/conf.d/frontend.conf:2
@k8s-ci-robot k8s-ci-robot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Apr 22, 2024
@k8s-ci-robot
Copy link
Contributor

This issue is currently awaiting triage.

SIG Docs takes a lead on issue triage for this website, but any Kubernetes member can accept issues by applying the triage/accepted label.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@tamilselvan1102
Copy link
Contributor

/kind support

@k8s-ci-robot k8s-ci-robot added the kind/support Categorizes issue or PR as a support question. label Apr 22, 2024
@assafseif
Copy link
Author

/kind support

what should i do?

@tamilselvan1102
Copy link
Contributor

you can deploy front-end/back-end app in k8s containers. Please check your app and its configurations

@assafseif
Copy link
Author

thats what i did exactly like this
https://kubernetes.io/docs/tasks/access-application-cluster/connecting-frontend-backend/

and i got this

2024/04/22 11:20:02 [emerg] 1#1: host not found in upstream "hello" in /etc/nginx/conf.d/frontend.conf:2
nginx: [emerg] host not found in upstream "hello" in /etc/nginx/conf.d/frontend.conf:2

@tamilselvan1102
Copy link
Contributor

which step did you get the error

@assafseif
Copy link
Author

i got crashloopbackoff when deploying frontend
what i showed you is the log of frontend deployment pod

@tamilselvan1102
Copy link
Contributor

crashloopbackoff may occur because of Resource Overload or Insufficient Memory, Misconfigurations. ...
please investigate your pod logs and resolve the issue

@tamilselvan1102
Copy link
Contributor

@assafseif
GitHub is not the right place for support requests.

If you're looking for help, check Server Fault.

You can also post your question on the Kubernetes Slack or the Discuss Kubernetes forum.

@sftim
Copy link
Contributor

sftim commented Apr 22, 2024

If you'd like to explain more about how to replicate the issue, @assafseif, we may be able to fix the documentation (we can't advise on specifics for your cluster).

/remove-kind support
/triage needs-information
/language en

@k8s-ci-robot k8s-ci-robot added triage/needs-information Indicates an issue needs more information in order to work on it. language/en Issues or PRs related to English language needs-kind Indicates a PR lacks a `kind/foo` label and requires one. and removed kind/support Categorizes issue or PR as a support question. labels Apr 22, 2024
@assafseif
Copy link
Author

If you'd like to explain more about how to replicate the issue, @assafseif, we may be able to fix the documentation (we can't advise on specifics for your cluster).

/remove-kind support /triage needs-information /language en
hello ,

What i tried to do is deploying frontend,
Check this one
https://kubernetes.io/docs/tasks/access-application-cluster/connecting-frontend-backend/#creating-the-frontend

kubectl apply -f https://k8s.io/examples/service/access/frontend-deployment.yaml
kubectl apply -f https://k8s.io/examples/service/access/frontend-service.yaml

crashloopbackoff occured inbside frontend-deployment pods,
when describing i got
host not found in upstream "hello" in /etc/nginx/conf.d/frontend.conf:2
nginx: [emerg] host not found in upstream "hello" in /etc/nginx/conf.d/frontend.conf:2

all files applied are from kubernetes docs

Regards

@stmcginnis
Copy link
Contributor

OK, looking in to this a little closer, it looks like there is an issue with the gcr.io/google-samples/hello-frontend:1.0 image used by frontend-deploy.yaml.

To clarify some of the description here, this is following the Connect a Frontend to a Backend Using Services tutorial. One of the steps there is to apply a manifest to create a new frontend deployment named frontend.

That deployment defines 1 replica, with the pod using the gcr.io/google-samples/hello-frontend:1.0 image.

The pod gets created, but ends up in a CrashLoopBackoff state. Describe the pod shows there is a problem in the events:

Events:
  Type     Reason     Age                From               Message
  ----     ------     ----               ----               -------
  Normal   Scheduled  31s                default-scheduler  Successfully assigned default/frontend-758994b889-tfd68 to kind-control-plane
  Normal   Pulling    31s                kubelet            Pulling image "gcr.io/google-samples/hello-frontend:1.0"
  Normal   Pulled     28s                kubelet            Successfully pulled image "gcr.io/google-samples/hello-frontend:1.0" in 3.247s (3.247s including waiting)
  Normal   Created    10s (x3 over 28s)  kubelet            Created container nginx
  Normal   Started    10s (x3 over 28s)  kubelet            Started container nginx
  Normal   Pulled     10s (x2 over 27s)  kubelet            Container image "gcr.io/google-samples/hello-frontend:1.0" already present on machine
  Warning  BackOff    10s (x3 over 26s)  kubelet            Back-off restarting failed container nginx in pod frontend-758994b889-tfd68_default(eae930af-0164-48a7-bc59-6022b8db560f)

In this case the pod name is frontend-758994b889-tfd68_default. If I get the logs we see the error mentioned above:

$ kubectl logs pod/frontend-758994b889-tfd68_default
2024/04/23 13:53:15 [emerg] 1#1: host not found in upstream "hello" in /etc/nginx/conf.d/frontend.conf:2
nginx: [emerg] host not found in upstream "hello" in /etc/nginx/conf.d/frontend.conf:2

This is after skipping the first half of the tutorial where the backend is created. Since this frontend proxies to the backend service, and the backend service defines a service named "hello", it appears the frontend will try to start, not find what it needs from the backend, and fail.

To check that, I then went back to the beginning and followed all steps up to the frontend deployment. After creating the backend as documented, the frontend was able to start and everything appears happy:

k get all
NAME                            READY   STATUS    RESTARTS        AGE
pod/backend-7f5b7998b9-2fcl2    1/1     Running   0               87s
pod/backend-7f5b7998b9-rv4mz    1/1     Running   0               87s
pod/backend-7f5b7998b9-snn5c    1/1     Running   0               87s
pod/frontend-758994b889-tfd68   1/1     Running   7 (5m21s ago)   11m

NAME                 TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)   AGE
service/hello        ClusterIP   10.96.88.204   <none>        80/TCP    56s
service/kubernetes   ClusterIP   10.96.0.1      <none>        443/TCP   44m

NAME                       READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/backend    3/3     3            3           87s
deployment.apps/frontend   1/1     1            1           11m

NAME                                  DESIRED   CURRENT   READY   AGE
replicaset.apps/backend-7f5b7998b9    3         3         3       87s
replicaset.apps/frontend-758994b889   1         1         1       11m

@tienhuynh17
Copy link

Hmm, I face the same issue. And I have followed all steps of the tutorial.
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
language/en Issues or PRs related to English language needs-kind Indicates a PR lacks a `kind/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. triage/needs-information Indicates an issue needs more information in order to work on it.
Projects
None yet
Development

No branches or pull requests

6 participants