Kubernetes - Unable to access apache Pod from proxy The Next CEO of Stack OverflowKubernetes equivalent of env-file in Dockerrequests.get(url) return error code 404 from kubernetes api while the response could be get via curl/GETKubernetes Pod fails with CrashLoopBackOffHow to start a pod in command line without deployment in kubernetes?How to map one single file into kubernetes pod using hostPath?unable to access kubernetes dashboard via tokenHow to mount a volume with a windows container in kubernetes?Share nfs volume between kubernetes clustersAccess stateful headless kubernetes externally?Kubernetes - How to acces to service from a web server in pod with a rest request

Audio Conversion With ADS1243

What connection does MS Office have to Netscape Navigator?

Can someone explain this formula for calculating Manhattan distance?

Is there such a thing as a proper verb, like a proper noun?

What would be the main consequences for a country leaving the WTO?

Is dried pee considered dirt?

What steps are necessary to read a Modern SSD in Medieval Europe?

Expectation in a stochastic differential equation

Is French Guiana a (hard) EU border?

Is fine stranded wire ok for main supply line?

what's the use of '% to gdp' type of variables?

TikZ: How to fill area with a special pattern?

Decide between Polyglossia and Babel for LuaLaTeX in 2019

What is the process for cleansing a very negative action

Calculate the Mean mean of two numbers

Is it okay to majorly distort historical facts while writing a fiction story?

From jafe to El-Guest

Spaces in which all closed sets are regular closed

What day is it again?

How did Beeri the Hittite come up with naming his daughter Yehudit?

Is there a difference between "Fahrstuhl" and "Aufzug"?

Is there an equivalent of cd - for cp or mv

Touchpad not working on Debian 9

Easy to read palindrome checker



Kubernetes - Unable to access apache Pod from proxy



The Next CEO of Stack OverflowKubernetes equivalent of env-file in Dockerrequests.get(url) return error code 404 from kubernetes api while the response could be get via curl/GETKubernetes Pod fails with CrashLoopBackOffHow to start a pod in command line without deployment in kubernetes?How to map one single file into kubernetes pod using hostPath?unable to access kubernetes dashboard via tokenHow to mount a volume with a windows container in kubernetes?Share nfs volume between kubernetes clustersAccess stateful headless kubernetes externally?Kubernetes - How to acces to service from a web server in pod with a rest request










0















I have PHP app+Apache on a Kubernetes POD. The PHP app, access Elasticsearch API on port 9200, and show a simple website, to the users, on port 5000.



I run proxy, using kubectl proxy --address='0.0.0.0' --port=8001 --accept-hosts='.*'.



When I enter to "http://localhost:8001/api/v1/namespaces/default/pods/website/proxy/", I see the following error:



Error: 'dial tcp 172.17.0.6:5000: connect: connection refused'
Trying to reach: 'http://172.17.0.6:5000/'


*172.17.0.6 is the POD ip address.



This is the website POD yaml:



apiVersion: v1
kind: Pod
metadata:
name: website
labels:
app: website
spec:
containers:
- name: website
image: website_k8s:latest
ports:
- containerPort: 5000
- containerPort: 80


This is the dockerfile of website_k8s:latest:



FROM php:7.0-apache
RUN echo "ServerName 0.0.0.0" >> /etc/apache2/apache2.conf
COPY ./index.php /var/www/html/
EXPOSE 5000



I also tried to run service:



apiVersion: v1
kind: Service
metadata:
name: website-service
spec:
ports:
- port: 5000
targetPort: 80
protocol: TCP
name: serving
- port: 80
targetPort: 9200
protocol: TCP
name: readfromelasticsearch
selector:
app: website


And when I enter to http://localhost:8001/api/v1/namespaces/default/services/website-service/proxy/, I see:




"kind": "Status",
"apiVersion": "v1",
"metadata":

,
"status": "Failure",
"message": "no endpoints available for service "website-service"",
"reason": "ServiceUnavailable",
"code": 503



Even though, when I run $kubectl get endpoints website-service, I see:



NAME ENDPOINTS AGE
website-service 172.17.0.6:80,172.17.0.6:9200 59m


I see the service's POD endpoint.



How could I access my website via proxy?










share|improve this question




























    0















    I have PHP app+Apache on a Kubernetes POD. The PHP app, access Elasticsearch API on port 9200, and show a simple website, to the users, on port 5000.



    I run proxy, using kubectl proxy --address='0.0.0.0' --port=8001 --accept-hosts='.*'.



    When I enter to "http://localhost:8001/api/v1/namespaces/default/pods/website/proxy/", I see the following error:



    Error: 'dial tcp 172.17.0.6:5000: connect: connection refused'
    Trying to reach: 'http://172.17.0.6:5000/'


    *172.17.0.6 is the POD ip address.



    This is the website POD yaml:



    apiVersion: v1
    kind: Pod
    metadata:
    name: website
    labels:
    app: website
    spec:
    containers:
    - name: website
    image: website_k8s:latest
    ports:
    - containerPort: 5000
    - containerPort: 80


    This is the dockerfile of website_k8s:latest:



    FROM php:7.0-apache
    RUN echo "ServerName 0.0.0.0" >> /etc/apache2/apache2.conf
    COPY ./index.php /var/www/html/
    EXPOSE 5000



    I also tried to run service:



    apiVersion: v1
    kind: Service
    metadata:
    name: website-service
    spec:
    ports:
    - port: 5000
    targetPort: 80
    protocol: TCP
    name: serving
    - port: 80
    targetPort: 9200
    protocol: TCP
    name: readfromelasticsearch
    selector:
    app: website


    And when I enter to http://localhost:8001/api/v1/namespaces/default/services/website-service/proxy/, I see:




    "kind": "Status",
    "apiVersion": "v1",
    "metadata":

    ,
    "status": "Failure",
    "message": "no endpoints available for service "website-service"",
    "reason": "ServiceUnavailable",
    "code": 503



    Even though, when I run $kubectl get endpoints website-service, I see:



    NAME ENDPOINTS AGE
    website-service 172.17.0.6:80,172.17.0.6:9200 59m


    I see the service's POD endpoint.



    How could I access my website via proxy?










    share|improve this question


























      0












      0








      0








      I have PHP app+Apache on a Kubernetes POD. The PHP app, access Elasticsearch API on port 9200, and show a simple website, to the users, on port 5000.



      I run proxy, using kubectl proxy --address='0.0.0.0' --port=8001 --accept-hosts='.*'.



      When I enter to "http://localhost:8001/api/v1/namespaces/default/pods/website/proxy/", I see the following error:



      Error: 'dial tcp 172.17.0.6:5000: connect: connection refused'
      Trying to reach: 'http://172.17.0.6:5000/'


      *172.17.0.6 is the POD ip address.



      This is the website POD yaml:



      apiVersion: v1
      kind: Pod
      metadata:
      name: website
      labels:
      app: website
      spec:
      containers:
      - name: website
      image: website_k8s:latest
      ports:
      - containerPort: 5000
      - containerPort: 80


      This is the dockerfile of website_k8s:latest:



      FROM php:7.0-apache
      RUN echo "ServerName 0.0.0.0" >> /etc/apache2/apache2.conf
      COPY ./index.php /var/www/html/
      EXPOSE 5000



      I also tried to run service:



      apiVersion: v1
      kind: Service
      metadata:
      name: website-service
      spec:
      ports:
      - port: 5000
      targetPort: 80
      protocol: TCP
      name: serving
      - port: 80
      targetPort: 9200
      protocol: TCP
      name: readfromelasticsearch
      selector:
      app: website


      And when I enter to http://localhost:8001/api/v1/namespaces/default/services/website-service/proxy/, I see:




      "kind": "Status",
      "apiVersion": "v1",
      "metadata":

      ,
      "status": "Failure",
      "message": "no endpoints available for service "website-service"",
      "reason": "ServiceUnavailable",
      "code": 503



      Even though, when I run $kubectl get endpoints website-service, I see:



      NAME ENDPOINTS AGE
      website-service 172.17.0.6:80,172.17.0.6:9200 59m


      I see the service's POD endpoint.



      How could I access my website via proxy?










      share|improve this question
















      I have PHP app+Apache on a Kubernetes POD. The PHP app, access Elasticsearch API on port 9200, and show a simple website, to the users, on port 5000.



      I run proxy, using kubectl proxy --address='0.0.0.0' --port=8001 --accept-hosts='.*'.



      When I enter to "http://localhost:8001/api/v1/namespaces/default/pods/website/proxy/", I see the following error:



      Error: 'dial tcp 172.17.0.6:5000: connect: connection refused'
      Trying to reach: 'http://172.17.0.6:5000/'


      *172.17.0.6 is the POD ip address.



      This is the website POD yaml:



      apiVersion: v1
      kind: Pod
      metadata:
      name: website
      labels:
      app: website
      spec:
      containers:
      - name: website
      image: website_k8s:latest
      ports:
      - containerPort: 5000
      - containerPort: 80


      This is the dockerfile of website_k8s:latest:



      FROM php:7.0-apache
      RUN echo "ServerName 0.0.0.0" >> /etc/apache2/apache2.conf
      COPY ./index.php /var/www/html/
      EXPOSE 5000



      I also tried to run service:



      apiVersion: v1
      kind: Service
      metadata:
      name: website-service
      spec:
      ports:
      - port: 5000
      targetPort: 80
      protocol: TCP
      name: serving
      - port: 80
      targetPort: 9200
      protocol: TCP
      name: readfromelasticsearch
      selector:
      app: website


      And when I enter to http://localhost:8001/api/v1/namespaces/default/services/website-service/proxy/, I see:




      "kind": "Status",
      "apiVersion": "v1",
      "metadata":

      ,
      "status": "Failure",
      "message": "no endpoints available for service "website-service"",
      "reason": "ServiceUnavailable",
      "code": 503



      Even though, when I run $kubectl get endpoints website-service, I see:



      NAME ENDPOINTS AGE
      website-service 172.17.0.6:80,172.17.0.6:9200 59m


      I see the service's POD endpoint.



      How could I access my website via proxy?







      apache docker kubernetes






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 9 at 20:10







      aronot

















      asked Mar 8 at 17:23









      aronotaronot

      507




      507






















          1 Answer
          1






          active

          oldest

          votes


















          2














          The problem is that Apache is listening on port 80, not 5000.



          If you remove containerPort: 5000 then you can access the website via http://localhost:8001/api/v1/namespaces/default/pods/website/proxy/.



          Secondly, the endpoints you see for the service are internal to the cluster.
          So, you can access the service through those IP endpoints from within a pod: kubectl exec website -- curl 172.17.0.6/.
          If you want to expose your service externally, the service should be of type NodePort or LoadBalancer.



          Finally, the problem you have when querying the service through the proxy is that, when you give a name to a port, you have to include it in the proxy call: curl localhost:8001/api/v1/namespaces/default/services/website-service:serving/proxy/.






          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55068115%2fkubernetes-unable-to-access-apache-pod-from-proxy%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            2














            The problem is that Apache is listening on port 80, not 5000.



            If you remove containerPort: 5000 then you can access the website via http://localhost:8001/api/v1/namespaces/default/pods/website/proxy/.



            Secondly, the endpoints you see for the service are internal to the cluster.
            So, you can access the service through those IP endpoints from within a pod: kubectl exec website -- curl 172.17.0.6/.
            If you want to expose your service externally, the service should be of type NodePort or LoadBalancer.



            Finally, the problem you have when querying the service through the proxy is that, when you give a name to a port, you have to include it in the proxy call: curl localhost:8001/api/v1/namespaces/default/services/website-service:serving/proxy/.






            share|improve this answer



























              2














              The problem is that Apache is listening on port 80, not 5000.



              If you remove containerPort: 5000 then you can access the website via http://localhost:8001/api/v1/namespaces/default/pods/website/proxy/.



              Secondly, the endpoints you see for the service are internal to the cluster.
              So, you can access the service through those IP endpoints from within a pod: kubectl exec website -- curl 172.17.0.6/.
              If you want to expose your service externally, the service should be of type NodePort or LoadBalancer.



              Finally, the problem you have when querying the service through the proxy is that, when you give a name to a port, you have to include it in the proxy call: curl localhost:8001/api/v1/namespaces/default/services/website-service:serving/proxy/.






              share|improve this answer

























                2












                2








                2







                The problem is that Apache is listening on port 80, not 5000.



                If you remove containerPort: 5000 then you can access the website via http://localhost:8001/api/v1/namespaces/default/pods/website/proxy/.



                Secondly, the endpoints you see for the service are internal to the cluster.
                So, you can access the service through those IP endpoints from within a pod: kubectl exec website -- curl 172.17.0.6/.
                If you want to expose your service externally, the service should be of type NodePort or LoadBalancer.



                Finally, the problem you have when querying the service through the proxy is that, when you give a name to a port, you have to include it in the proxy call: curl localhost:8001/api/v1/namespaces/default/services/website-service:serving/proxy/.






                share|improve this answer













                The problem is that Apache is listening on port 80, not 5000.



                If you remove containerPort: 5000 then you can access the website via http://localhost:8001/api/v1/namespaces/default/pods/website/proxy/.



                Secondly, the endpoints you see for the service are internal to the cluster.
                So, you can access the service through those IP endpoints from within a pod: kubectl exec website -- curl 172.17.0.6/.
                If you want to expose your service externally, the service should be of type NodePort or LoadBalancer.



                Finally, the problem you have when querying the service through the proxy is that, when you give a name to a port, you have to include it in the proxy call: curl localhost:8001/api/v1/namespaces/default/services/website-service:serving/proxy/.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 9 at 0:25









                metaphorimetaphori

                1,52311127




                1,52311127





























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55068115%2fkubernetes-unable-to-access-apache-pod-from-proxy%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Identity Server 4 is not redirecting to Angular app after login2019 Community Moderator ElectionIdentity Server 4 and dockerIdentityserver implicit flow unauthorized_clientIdentityServer Hybrid Flow - Access Token is null after user successful loginIdentity Server to MVC client : Page Redirect After loginLogin with Steam OpenId(oidc-client-js)Identity Server 4+.NET Core 2.0 + IdentityIdentityServer4 post-login redirect not working in Edge browserCall to IdentityServer4 generates System.NullReferenceException: Object reference not set to an instance of an objectIdentityServer4 without HTTPS not workingHow to get Authorization code from identity server without login form

                    2005 Ahvaz unrest Contents Background Causes Casualties Aftermath See also References Navigation menue"At Least 10 Are Killed by Bombs in Iran""Iran"Archived"Arab-Iranians in Iran to make April 15 'Day of Fury'"State of Mind, State of Order: Reactions to Ethnic Unrest in the Islamic Republic of Iran.10.1111/j.1754-9469.2008.00028.x"Iran hangs Arab separatists"Iran Overview from ArchivedConstitution of the Islamic Republic of Iran"Tehran puzzled by forged 'riots' letter""Iran and its minorities: Down in the second class""Iran: Handling Of Ahvaz Unrest Could End With Televised Confessions""Bombings Rock Iran Ahead of Election""Five die in Iran ethnic clashes""Iran: Need for restraint as anniversary of unrest in Khuzestan approaches"Archived"Iranian Sunni protesters killed in clashes with security forces"Archived

                    Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme