QLoo graphql engine 学习二 基本试用(kubernetes)
已经测试过docker&& docker-compose 的运行模式,下面测试下kubernetes的运行模式
kubernetes 我使用docker for mac
qloo 安装
- 下载
https://github.com/solo-io/qloo/releases
https://github.com/solo-io/gloo/releases
- 配置环境变量
mac
cat ~/.bash_profile
export PATH=$PATH:/Users/dalong/Downloads/qloo
部署gloo&&qloo
使用命令行工具,有一个问题,需要先创建 gloo-system namespace,好像是一个bug
qlooctl install kube
部署petsotre 服务
kubectl apply \
-f https://raw.githubusercontent.com/solo-io/gloo/master/example/petstore/petstore.yaml
查看函数(glooctl)
glooctl upstream get
创建schema (与docker-compose 是一样的)
# The query type, represents all of the entry points into our object graph
type Query {
pets: [Pet]
pet(id: Int!): Pet
}
type Mutation {
addPet(pet: InputPet!): Pet
}
type Pet{
id: ID!
name: String!
status: Status!
}
input InputPet{
id: ID!
name: String!
tag: String
}
enum Status {
pending
available
}
qlooctl schema create petstore -f petstore.graphql
注册resolver
# register findPetById for Query.pets (specifying no arguments)
qlooctl resolvermap register -u default-petstore-8080 -f findPetById Query pets
# register a resolver for Query.pet
qlooctl resolvermap register -u default-petstore-8080 -f findPetById Query pet
# register a resolver for Mutation.addPet
# the request template tells QLoo to use the Variable "pet" as an argument
qlooctl resolvermap register -u default-petstore-8080 -f addPet Mutation addPet --request-template '{{ marshal (index .Args "pet") }}'
访问方式
查询操作
{
pet(id:1 ) {
name
}
}
参考资料
https://github.com/solo-io/qloo/blob/master/docs/getting_started/kubernetes/1.md