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

                    Thal And Out Agency railway station See also References External links Navigation menuOfficial Web Site of Pakistan RailwaysArchivedOfficial Web Site of Pakistan Railwayseeexpanding ite

                    Posting a File and Associated Data to a RESTful WebService preferably as JSON2019 Community Moderator ElectionREST URI convention - Singular or plural name of resource while creating itUploading both data and files in one form using Ajax?How do I upload a file with metadata using a REST web service?REST API - file (ie images) processing - best practicesSpring: JSON data and file in the same requestREST API Put large dataPosting a file and JSON data to Spring rest serviceRESTful Web Service Upload/Download Large Data With JSONREST API Design sending JSON data and a file to the api in same requestPost JSONArray to REST servicePUT vs. POST in RESTParsing values from a JSON file?JavaScript/jQuery to download file via POST with JSON dataHow do I upload a file with metadata using a REST web service?How to POST JSON data with Curl from Terminal/Commandline to Test Spring REST?Separate REST JSON API server and client?what's the correct way to send a file from REST web service to client?How do I write JSON data to a file?What is “406-Not Acceptable Response” in HTTP?REST API - file (ie images) processing - best practices

                    How can I change the color of pagination dots of UIPageControl?How to change UIPageControl dotsIs there a way to change page indicator dots colorCustomize dot with image of UIPageControl at index 0 of UIPageControlNo visible @interface for 'NSObject<PageControlDelegate>' declares the selector 'pageControlPageDidChange:'How to change the color of pagination dots in UIPageControl with a different color per pagepagecontrol indicator custom image instead of DefaultChanging the colour of UIPageControl dots in MonoTouchpagecontrol selectable page visibility color?Alternative way to load ViewControllers on a UIPageControlHow to set only layer.border-color for UIpage control dots in swiftHow can I develop for iPhone using a Windows development machine?How to change the name of an iOS app?UITableView - change section header coloruipagecontrol indicator(dot)issueCustom UIPageControl dots color not changingchange the interspace between UIPageControl dotsHow to change Status Bar text color in iOSHow can I change image tintColor in iOS and WatchKitUIPageControl dots with larger space in between each dotsHow to change the color of pagination dots in UIPageControl with a different color per page