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

Feature: add fetch service list and get service detail from k8s cluster api to backend #170

Merged
merged 9 commits into from
Dec 28, 2018

Conversation

HZ89
Copy link
Contributor

@HZ89 HZ89 commented Dec 20, 2018

What type of PR is this?

/kind feature

What this PR does / why we need it:
api add:

/api/v1/kubernetes/apps/:appId/services/namespaces/:namespace/clusters/:cluster
/api/v1/kubernetes/apps/:appId/services/:service/detail/namespaces/:namespace/clusters/:cluster

test result:

curl --location --request GET "http://127.0.0.1:8080/api/v1//kubernetes/apps/0/services/namespaces/default/clusters/minikube"
{
  "data": {
    "pageNo": 1,
    "pageSize": 10,
    "totalPage": 1,
    "totalCount": 2,
    "list": [
      {
        "objectMeta": {
          "name": "kubernetes",
          "namespace": "default",
          "labels": {
            "component": "apiserver",
            "provider": "kubernetes"
          },
          "creationTimestamp": "2018-12-20T08:35:42Z"
        },
        "typeMeta": {
          "kind": "service"
        },
        "internalEndpoint": {
          "host": "kubernetes",
          "ports": [
            {
              "port": 443,
              "protocol": "TCP",
              "nodePort": 0
            }
          ]
        },
        "externalEndpoints": null,
        "selector": null,
        "type": "ClusterIP",
        "clusterIP": "10.96.0.1"
      },
      {
        "objectMeta": {
          "name": "my-nginx",
          "namespace": "default",
          "labels": {
            "run": "my-nginx"
          },
          "annotations": {
            "kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"v1\",\"kind\":\"Service\",\"metadata\":{\"annotations\":{},\"labels\":{\"run\":\"my-nginx\"},\"name\":\"my-nginx\",\"namespace\":\"default\"},\"spec\":{\"ports\":[{\"port\":80,\"protocol\":\"TCP\"}],\"selector\":{\"run\":\"my-nginx\"}}}\n"
          },
          "creationTimestamp": "2018-12-20T09:13:35Z"
        },
        "typeMeta": {
          "kind": "service"
        },
        "internalEndpoint": {
          "host": "my-nginx",
          "ports": [
            {
              "port": 80,
              "protocol": "TCP",
              "nodePort": 0
            }
          ]
        },
        "externalEndpoints": null,
        "selector": {
          "run": "my-nginx"
        },
        "type": "ClusterIP",
        "clusterIP": "10.101.60.195"
      }
    ]
  }
}
curl --location --request GET "http://127.0.0.1:8080/api/v1//kubernetes/apps/0/services/my-nginx/detail/namespaces/default/clusters/minikube"
{
  "data": {
    "objectMeta": {
      "name": "my-nginx",
      "namespace": "default",
      "labels": {
        "run": "my-nginx"
      },
      "annotations": {
        "kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"v1\",\"kind\":\"Service\",\"metadata\":{\"annotations\":{},\"labels\":{\"run\":\"my-nginx\"},\"name\":\"my-nginx\",\"namespace\":\"default\"},\"spec\":{\"ports\":[{\"port\":80,\"protocol\":\"TCP\"}],\"selector\":{\"run\":\"my-nginx\"}}}\n"
      },
      "creationTimestamp": "2018-12-20T09:13:35Z"
    },
    "typeMeta": {
      "kind": "service"
    },
    "internalEndpoint": {
      "host": "my-nginx",
      "ports": [
        {
          "port": 80,
          "protocol": "TCP",
          "nodePort": 0
        }
      ]
    },
    "externalEndpoints": null,
    "endpointList": [
      {
        "objectMeta": {
          "creationTimestamp": null
        },
        "typeMeta": {
          "kind": "endpoint"
        },
        "host": "172.17.0.2",
        "nodeName": "minikube",
        "ready": true,
        "ports": [
          {
            "port": 80,
            "protocol": "TCP"
          }
        ]
      },
      {
        "objectMeta": {
          "creationTimestamp": null
        },
        "typeMeta": {
          "kind": "endpoint"
        },
        "host": "172.17.0.5",
        "nodeName": "minikube",
        "ready": true,
        "ports": [
          {
            "port": 80,
            "protocol": "TCP"
          }
        ]
      }
    ],
    "selector": {
      "run": "my-nginx"
    },
    "type": "ClusterIP",
    "clusterIP": "10.101.60.195",
    "eventList": [],
    "podList": null,
    "sessionAffinity": "None"
  }
}

@HZ89 HZ89 changed the title add api support fetch service list and detail from k8s cluster backend: add api support fetch service list and detail from k8s cluster Dec 21, 2018
@wilhelmguo wilhelmguo added kind/feature Categorizes issue or PR as related to a new feature. sig/backend Categorizes an issue or PR as relevant to sig-backend. labels Dec 21, 2018
@HZ89 HZ89 changed the title backend: add api support fetch service list and detail from k8s cluster Feature: add fetch service list and get service detail from k8s cluster api to backend Dec 21, 2018
src/backend/controllers/ingress/ingress.go Outdated Show resolved Hide resolved
src/backend/resources/common/endpoint.go Outdated Show resolved Hide resolved
src/backend/resources/common/endpoint.go Show resolved Hide resolved
src/backend/resources/service/detail.go Show resolved Hide resolved
@wilhelmguo
Copy link
Collaborator

wilhelmguo commented Dec 24, 2018

LGTM @chengyumeng Please review the PR.

Copy link
Collaborator

@chengyumeng chengyumeng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个文件不应该放在这个目录下面

@chengyumeng chengyumeng added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Dec 24, 2018
@wilhelmguo
Copy link
Collaborator

@chengyumeng @HZ89 还有其他问题吗

@HZ89
Copy link
Contributor Author

HZ89 commented Dec 26, 2018

我没啥问题

@chengyumeng
Copy link
Collaborator

之前 review 提出的问题有一些还没回复呀 @HZ89 @wilhelmguo

@wilhelmguo wilhelmguo removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Dec 28, 2018
@wilhelmguo wilhelmguo merged commit 5239e41 into Qihoo360:master Dec 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature. sig/backend Categorizes an issue or PR as relevant to sig-backend.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants