• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

CATechnologiesTest/kubeiql: A GraphQL interface for Kubernetes.

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

CATechnologiesTest/kubeiql

开源软件地址(OpenSource Url):

https://github.com/CATechnologiesTest/kubeiql

开源编程语言(OpenSource Language):

Go 99.2%

开源软件介绍(OpenSource Introduction):

Repository Status

This repository exists here for historical purposes. The active repo is now hosted at: https://github.com/yipeeio/kubeiql

Kubeiql

A GraphQL interface for Kubernetes.

The goal of this project is to provide an alternative GraphQL interface to a Kubernetes cluster. It is not intended to entirely replace the ReST APIs as some of them (particularly the watch APIs) don't map well onto GraphQL.

Yipee.io is a CA, Inc. Accelerator project.

Current Status

pre-alpha

  • Queries are currently supported against Pods, Deployments, ReplicaSets, StatefulSets, and DaemonSets.
  • No mutations are yet implemented.
  • The retrieval of data from the cluster is accomplished via watchers on the kubernetes API. By default, we expect to access the API at localhost port 8080 (run "kubectl proxy --port=8080")
    • to access a kubernetes API without using the proxy, you can set environment variables:
      • API_HOST: host/port of API, e.g., https://kubernetes.default.svc from inside a cluster
      • API_SECRET_PATH: directory containing files 'ca.crt' and 'token', e.g. /var/run/secrets/kubernetes.io/serviceaccount from a pod inside a cluster
  • Tests are lacking
  • See https://hub.docker.com/r/yipeeio/kubeiql/ for a docker image

Getting Started

To experiment with the API:

  1. Download the code
  2. Type sh gobuild.sh
  3. Start a proxy for the kubernetes API on port 8080 (e.g., kubectl proxy --port=8080)
  4. Run ./kubeiql

The server runs at port 8128. You can use curl to play with it as shown in the examples below via the /query endpoint, or point your browser at 'localhost:8128/' and experiment with the GraphiQL tool (much more user-friendly).

Build an image

If you're running on a non-linux machine, use the elf-build.sh script to build an image suitable for use in a docker container. Then just build in the usual way:

docker build -t your-image-name .

Running inside a Kubernetes cluster

To run kubeiql inside a cluster, simply apply the k8sdeploy.yaml file:

kubectl apply -f k8sdeploy.yaml

Examples

The query:

{
  daemonSetByName(namespace: "kube-system", name: "kube-proxy") {
    metadata {name namespace labels {name value}}
  }
}
curl -X POST -H"Content-Type: application/json" http://localhost:8128/query -d '{ "query": "{daemonSetByName(namespace: \"kube-system\", name: \"kube-proxy\") { metadata {name namespace labels {name value}} pods {metadata {name}}}}"}'

returns:

{
  "data": {
    "daemonSetByName": {
      "metadata": {
        "name": "kube-proxy",
        "namespace": "kube-system",
        "labels": [
          {
            "name": "k8s-app",
            "value": "kube-proxy"
          }
        ]
      },
      "pods": [
        {
          "metadata": {
            "name": "kube-proxy-7vhx5"
          }
        }
      ]
    }
  }
}

and the query:

{
  allPods() {
    owner {kind metadata {name}}
    rootOwner { kind metadata { name namespace }
      ... on StatefulSet {
        metadata { name }
      }
      ... on Deployment {
        replicaSets {
            metadata { name }
          pods { metadata { name } } }
      }
    }
  }
}
curl -X POST -H"Content-Type: application/json" http://localhost:8128/query -d '{"query": "{allPods() {owner {kind metadata {name}} rootOwner { kind metadata { name namespace } ... on StatefulSet { metadata { name } } ... on Deployment { replicaSets { metadata { name } pods { metadata { name } } } } } } }" }'

returns:

{
  "data": {
    "allPods": [
      {
        "owner": {
          "kind": "ReplicaSet",
          "metadata": {
            "name": "backend-549447ccf"
          }
        },
        "rootOwner": {
          "kind": "Deployment",
          "metadata": {
            "name": "backend",
            "namespace": "default"
          },
          "replicaSets": [
            {
              "metadata": {
                "name": "backend-549447ccf"
              },
              "pods": [
                {
                  "metadata": {
                    "name": "backend-549447ccf-4zphf"
                  }
                },
                {
                  "metadata": {
                    "name": "clunky-sabertooth-joomla-5d4ddc985d-fpddz"
                  }
                },
                {
                  "metadata": {
                    "name": "clunky-sabertooth-mariadb-0"
                  }
                }
                // ...
              ]
            }
          ]
        }
      },
      {
        "owner": {
          "kind": "ReplicaSet",
          "metadata": {
            "name": "clunky-sabertooth-joomla-5d4ddc985d"
          }
        },
        "rootOwner": {
          "kind": "Deployment",
          "metadata": {
            "name": "clunky-sabertooth-joomla",
            "namespace": "default"
          },
          "replicaSets": [
            {
              "metadata": {
                "name": "backend-549447ccf"
              },
              "pods": [
                {
                  "metadata": {
                    "name": "backend-549447ccf-4zphf"
                  }
                },
                {
                  "metadata": {
                    "name": "clunky-sabertooth-joomla-5d4ddc985d-fpddz"
                  }
                }
                //...
              ]
            }
          ]
        }
      },
      {
        "owner": {
          "kind": "StatefulSet",
          "metadata": {
            "name": "clunky-sabertooth-mariadb"
          }
        },
        "rootOwner": {
          "kind": "StatefulSet",
          "metadata": {
            "name": "clunky-sabertooth-mariadb",
            "namespace": "default"
          }
        }
      },
      {
        "owner": {
          "kind": "ReplicaSet",
          "metadata": {
            "name": "ui-9c6c8d79"
          }
        },
        "rootOwner": {
          "kind": "Deployment",
          "metadata": {
            "name": "ui",
            "namespace": "default"
          },
          "replicaSets": [
            {
              "metadata": {
                "name": "backend-549447ccf"
              },
              "pods": [
                {
                  "metadata": {
                    "name": "backend-549447ccf-4zphf"
                  }
                },
                {
                  "metadata": {
                    "name": "clunky-sabertooth-joomla-5d4ddc985d-fpddz"
                  }
                }
                // ...
              ]
            }
          ]
        }
      },
      {
        "owner": {
          "kind": "ReplicaSet",
          "metadata": {
            "name": "ui-9c6c8d79"
          }
        },
        "rootOwner": {
          "kind": "Deployment",
          "metadata": {
            "name": "ui",
            "namespace": "default"
          },
          "replicaSets": [
            {
              "metadata": {
                "name": "backend-549447ccf"
              },
              "pods": [
                {
                  "metadata": {
                    "name": "backend-549447ccf-4zphf"
                  }
                },
                {
                  "metadata": {
                    "name": "clunky-sabertooth-joomla-5d4ddc985d-fpddz"
                  }
                }
                // ...
              ]
            }
          ]
        }
      },
      {
        "owner": {
          "kind": "Pod",
          "metadata": {
            "name": "etcd-minikube"
          }
        },
        "rootOwner": {
          "kind": "Pod",
          "metadata": {
            "name": "etcd-minikube",
            "namespace": "kube-system"
          }
        }
      },
      {
        "owner": {
          "kind": "Pod",
          "metadata": {
            "name": "kube-addon-manager-minikube"
          }
        },
        "rootOwner": {
          "kind": "Pod",
          "metadata": {
            "name": "kube-addon-manager-minikube",
            "namespace": "kube-system"
          }
        }
      },
      {
        "owner": {
          "kind": "Pod",
          "metadata": {
            "name": "kube-apiserver-minikube"
          }
        },
        "rootOwner": {
          "kind": "Pod",
          "metadata": {
            "name": "kube-apiserver-minikube",
            "namespace": "kube-system"
          }
        }
      },
      {
        "owner": {
          "kind": "Pod",
          "metadata": {
            "name": "kube-controller-manager-minikube"
          }
        },
        "rootOwner": {
          "kind": "Pod",
          "metadata": {
            "name": "kube-controller-manager-minikube",
            "namespace": "kube-system"
          }
        }
      },
      {
        "owner": {
          "kind": "ReplicaSet",
          "metadata": {
            "name": "kube-dns-86f4d74b45"
          }
        },
        "rootOwner": {
          "kind": "Deployment",
          "metadata": {
            "name": "kube-dns",
            "namespace": "kube-system"
          },
          "replicaSets": [
            {
              "metadata": {
                "name": "backend-549447ccf"
              },
              "pods": [
                {
                  "metadata": {
                    "name": "backend-549447ccf-4zphf"
                  }
                },
                {
                  "metadata": {
                    "name": "clunky-sabertooth-joomla-5d4ddc985d-fpddz"
                  }
                }
                // ...
              ]
            }
          ]
        }
      },
      {
        "owner": {
          "kind": "DaemonSet",
          "metadata": {
            "name": "kube-proxy"
          }
        },
        "rootOwner": {
          "kind": "DaemonSet",
          "metadata": {
            "name": "kube-proxy",
            "namespace": "kube-system"
          }
        }
      },
      {
        "owner": {
          "kind": "Pod",
          "metadata": {
            "name": "kube-scheduler-minikube"
          }
        },
        "rootOwner": {
          "kind": "Pod",
          "metadata": {
            "name": "kube-scheduler-minikube",
            "namespace": "kube-system"
          }
        }
      }
      // ...
    ]
  }
}

License

The work done has been licensed under Apache License 2.0. The license file can be found here. You can find out more about the license at www.apache.org/licenses/LICENSE-2.0.

Questions?

Feel free to contact us.




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap