Welcome to the Linux Foundation Forum!

Lesson 8.9: how to access service port by local proxy?

Options

The last line of this course is:

If the service port has a name, the path will be http://localhost:8001/api/v1/namespaces/default/services/ghost:

I am not sure I take this sentence right, I think we can access the service by the URL. The service available in my environment is:

$ curl 127.0.0.1:8001/api/v1/namespaces/default/services/nginx
{
  "kind": "Service",
  "apiVersion": "v1",
  "metadata": {
    "name": "nginx",
    "namespace": "default",
    "selfLink": "/api/v1/namespaces/default/services/nginx",
    "uid": "ac5a561e-fddb-11e8-bae0-42010af0000b",
    "resourceVersion": "143707",
    "creationTimestamp": "2018-12-12T07:00:56Z",
    "labels": {
      "app": "nginx"
    }
  },
  "spec": {
    "ports": [
      {
        "name": "http",
        "protocol": "TCP",
        "port": 80,
        "targetPort": 80
      }
    ],
    "selector": {
      "app": "nginx"
    },
    "clusterIP": "10.109.208.49",
    "type": "ClusterIP",
    "sessionAffinity": "None"
  },
  "status": {
    "loadBalancer": {

    }
  }
}

But I cannot access it like it shown in this lesson material, the error code is 404. Is my thought about this right, or I missed something?

$  curl 127.0.0.1:8001/api/v1/namespaces/default/services/nginx:http
{
  "kind": "Status",
  "apiVersion": "v1",
  "metadata": {

  },
  "status": "Failure",
  "message": "services \"nginx:http\" not found",
  "reason": "NotFound",
  "details": {
    "name": "nginx:http",
    "kind": "services"
  },
  "code": 404
}

Comments

  • chrispokorni
    Options

    @blackpiglet
    I am thinking that the field with key "name" and value "http" is used in cases when there are multiple ports defined with distinct names from each other (http for 80, https for 443, etc...) and when other objects need to reference these ports in the service via that distinct name. I'd need to dig thru the documentation for .../service-name:port-name usage.
    -Chris

Categories

Upcoming Training