Skip to content

docs: about apisix discovery for kubernetes #7199

Description

@liangyawang

Current State

Hello team members, I had the following problems when I made automatic discovery based on apifix and kubernetes according to the official documents

  1. use the token file as the interactive voucher between apifix and kuberentes. The missing field in the error header cannot be connected normally, and then replace it with a token string to complete the link
    In my token file at that time, only the token string was pasted without any other fields
  2. when I call the API to automatically discover the route of type kubernetes, I use curl to request and give an error prompt for the non optional upstream
    When I help with troubleshooting through team members, the troubleshooting process is as follows:
  3. service_ The name field is incorrectly filled in. For example: /test/test app
  4. not in service_ Add the corresponding service port in the name field
  5. we mistakenly think that we need to add a service port directly. After troubleshooting, we mapped it through the port name corresponding to the port in the endpoints
    The team is expected to automatically find kubernetes in the official document
  6. for token_ File problem
  7. add a corresponding example in this discovery type document to create an automatic discovery route with kubernetes type through API
  8. the example should give an example and explain the detailed configuration format of each field. For example, today's port will be checked for a while
  9. the detailed information of the corresponding namespace service port shall be displayed during the example for reference
  10. the log should be printed for each environment and adjusted according to the level of the configuration file, because today I want to see if he really gets the data, but I don't know where to add the log to print for users who are unfamiliar with Lua

Desired State

  • Display service information
[root@ ~]# kubectl get pods -n test |grep test-app
test-app-6f57f6fffb-gfblz                   1/1     Running            0          6d23h

[root@ ~]# kubectl get endpoints -n test test-app
NAME          ENDPOINTS             AGE
test-app   10.223.216.201:8080   1d

[root@ ~]# kubectl describe endpoints -n test test-app
Name:         test-app
Namespace:    test
Labels:       app=test-app
Annotations:  endpoints.kubernetes.io/last-change-trigger-time: 2022-06-02T19:07:21+08:00
Subsets:
  Addresses:          10.223.216.201
  NotReadyAddresses:  <none>
  Ports:
    Name     Port  Protocol
    ----     ----  --------
    8080tcp  8080  TCP                        #Note the port name here

Events:  <none>
  • Show the route creation method of the corresponding service
    Since the dashboard does not support routes of kubernetes type, it is created by calling API
curl http://127.0.0.1:80/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f8sdfcx7ad84b625c8f1sdfagw32' -X PUT -i -d '
{
    "uri": "/*",                                                         # location path
    "name": "test-test-app-for-kubernetes",     #Name a free reason
    "priority": 100,
    "host": "test.xxxx.cn",                    #Fill in according to your own domain name
    "methods": ["PUT", "GET", "POST", "DELETE", "PATCH", "HEAD", "OPTIONS","CONNECT", "TRACE"],
    "upstream": {
        "timeout": {
          "connect": 6,
          "send": 6,
          "read": 6
        },
        "service_name": "test/test-app:tcp8080",  #Configuration format: namespace/deploy_name:port_name
        "type": "roundrobin",
        "discovery_type": "kubernetes"                   #type use kubernetes
    }
}'

In addition, I hope to add log configuration. For example, I want to check whether he has obtained the configuration access and reported an error. Why not end without an optional node? This is very difficult to troubleshoot
Or you can tell people what logs they want to view and in which file the corresponding command can be added to the function

Metadata

Metadata

Assignees

No one assigned

    Labels

    docDocumentation thingsstale

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions