├── .gitignore ├── LICENSE ├── README.md ├── docker ├── Dockerfile ├── Dockerfile-all ├── Dockerfile-all-alpine ├── Dockerfile-alpine ├── Makefile ├── docker-compose.yaml └── work │ ├── .meshrc.yaml │ └── package.json ├── helm-chart ├── build.sh ├── graphql-mesh-0.1.0.tgz ├── graphql-mesh-0.1.1.tgz ├── graphql-mesh-configmap.yaml ├── graphql-mesh-init-sh.yaml ├── index.sh ├── index.yaml └── sample-values.yaml ├── helm-src ├── .helmignore ├── Chart.yaml ├── templates │ ├── NOTES.txt │ ├── _helpers.tpl │ ├── deployment.yaml │ ├── hpa.yaml │ ├── ingress.yaml │ ├── raw-files-configmap.yaml │ ├── service.yaml │ ├── serviceaccount.yaml │ └── tests │ │ └── test-connection.yaml └── values.yaml ├── img ├── 2020-04-26-19-07-16.png ├── 2020-05-25-13-35-39.png ├── 2021-05-21-17-14-46.png ├── docker.png ├── helm.png ├── kubernetes.png └── mesh.png ├── k8s ├── basic │ ├── meshrc-cm.yaml │ ├── pod.yaml │ └── service.yaml └── jsonschema-covid19 │ ├── meshrc-cm.yaml │ ├── meshrc │ └── .meshrc.yaml │ ├── pod.yaml │ ├── service.yaml │ ├── src-cm.yaml │ └── src │ ├── case-additional-resolvers.js │ ├── query-additional-resolvers.js │ └── worldPop.json ├── kind-config.yaml └── update.sh /.gitignore: -------------------------------------------------------------------------------- 1 | /docker/work/node_modules 2 | /docker/work/yarn.lock 3 | /docker/work/example-queries 4 | /examples -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2020 Hiroyuki Osaki 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # GraphQL Mesh Docker (supports Kubernetes/Helm) 2 | 3 | on or / 4 | 5 | Simple docker image to run just a [GraphQL Mesh](https://github.com/Urigo/graphql-mesh) (Thank you [Urigo](https://github.com/Urigo) and Mesh community for developing nice tool!) 6 | 7 | Please prepare only Docker environment or Kubernetes and run the command. No need to understand Node.js. 8 | 9 | - [GraphQL Mesh Docker (supports Kubernetes/Helm)](#graphql-mesh-docker-supports-kuberneteshelm) 10 | - [TL;DR](#tldr) 11 | - [Architecture](#architecture) 12 | - [Docker Images for GraphQL Mesh](#docker-images-for-graphql-mesh) 13 | - [Run](#run) 14 | - [1. On Docker](#1-on-docker) 15 | - [2. On Kubernetes](#2-on-kubernetes) 16 | - [2.1 Use `kubectl`](#21-use-kubectl) 17 | - [2.2 Use `helm`](#22-use-helm) 18 | - [Parameters](#parameters) 19 | - [Customize](#customize) 20 | - [Customize .meshrc](#customize-meshrc) 21 | - [On Docker](#on-docker) 22 | - [On Kubernetes (not using Helm)](#on-kubernetes-not-using-helm) 23 | - [With Helm](#with-helm) 24 | - [Clone another existing example and run in Docker](#clone-another-existing-example-and-run-in-docker) 25 | - [Example](#example) 26 | - [GraphQL Mesh with MySQL](#graphql-mesh-with-mysql) 27 | - [Build on your own](#build-on-your-own) 28 | 29 | 30 | # TL;DR 31 | 32 | ```sh 33 | # Run on Docker 34 | docker run --name mesh -p 4000:4000 -it --volume ${PWD}/docker/work/.meshrc.yaml:/work/.meshrc.yaml --rm hiroyukiosaki/graphql-mesh:latest-all-alpine 35 | # or run with docker-compose 36 | cd docker && docker-compose up -d mesh-all-alpine 37 | # or run on Kubernetes with helm 38 | helm repo add graphql-mesh https://onelittlenightmusic.github.io/graphql-mesh-docker/helm-chart 39 | helm repo up 40 | helm install my-graphql-mesh graphql-mesh/graphql-mesh 41 | ``` 42 | 43 | And access to `http://localhost:4000`. 44 | 45 | Run a query. 46 | 47 | ```graphql 48 | { 49 | cases { 50 | active 51 | countryRegion 52 | } 53 | } 54 | ``` 55 | 56 | ![](img/2021-05-21-17-14-46.png) 57 | 58 | # Architecture 59 | 60 | 61 | 62 | Data sources are databases like MySQL or PostgreSQL. 63 | 64 | [GraphQL Mesh](https://github.com/Urigo/graphql-mesh) can convert these data sources to GraphQL API. 65 | 66 | GraphQL Mesh Docker runs GraphQL Mesh in Docker container. You can customize GraphQL Mesh settings by changing `.meshrc.yaml` and mounting the file in Docker container ([see Customize](#customize)) 67 | 68 | # Docker Images for GraphQL Mesh 69 | 70 | - [`graphql-mesh` on Dockerhub](https://hub.docker.com/repository/docker/hiroyukiosaki/graphql-mesh) 71 | 72 | | Tag | Description | 73 | |---|---| 74 | | `latest` ([Dockerfile](./docker/Dockerfile)) | Includes minimum CLI and handler ([`@graphql-mesh/openapi`](https://graphql-mesh.com/docs/handlers/openapi)) | 75 | | `latest-alpine` ([Dockerfile](./docker/Dockerfile-alpine)) | Alpine version for minimum footprint which includes minimum CLI and handler ([`@graphql-mesh/openapi`](https://graphql-mesh.com/docs/handlers/openapi)) | 76 | | `latest-all` ([Dockerfile-all](./docker/Dockerfile-all)) | Includes [all handlers](https://graphql-mesh.com/docs/handlers/available-handlers/) | 77 | | `latest-all-alpine` ([Dockerfile-all](./docker/Dockerfile-all-alpine)) | Alpine version for minimum footprint which includes [all handlers](https://graphql-mesh.com/docs/handlers/available-handlers/) | 78 | 79 | # Run 80 | 81 | You can choose step for your envionment (Docker or Kubernetes) 82 | 83 | ## 1. On Docker 84 | 85 | Simply run this command. 86 | 87 | ```sh 88 | # Just docker run (choose tag version) 89 | docker run --name mesh -p 4000:4000 -it --rm hiroyukiosaki/graphql-mesh:latest 90 | docker run --name mesh -p 4000:4000 -it --rm hiroyukiosaki/graphql-mesh:latest-all 91 | ``` 92 | 93 | Alternatives 94 | 95 | ```sh 96 | # docker-compose 97 | docker-compose up -d mesh 98 | # or to run vX.X.X-all 99 | docker-compose up -d mesh-all 100 | ``` 101 | 102 | After running docker image, you can access to GraphQL Mesh service at `http://localhost:4000` and you will see this screen. 103 | 104 | ## 2. On Kubernetes 105 | 106 | There are two methods. 107 | 108 | - `kubectl` 109 | - `helm` 110 | 111 | You need Kubernetes cluster. 112 | 113 | If you don't have Kubernetes cluster, you can create Kubernetes on Docker with [KinD](https://github.com/kubernetes-sigs/kind) 114 | 115 | ```sh 116 | kind create cluster --name graphql --config kind-config.yaml 117 | ``` 118 | 119 | #### 2.1 Use `kubectl` 120 | 121 | ```sh 122 | # If you want to change image, please edit k8s/pod.yaml 123 | kubectl apply -f k8s/basic 124 | # or 125 | kubectl apply -f k8s/jsonschema-covid19 126 | ``` 127 | 128 | After the pod running, we can forward the kubernetes service port to local machine with this command and access to GraphQL Mesh at `http://localhost:4000`. 129 | 130 | ``` 131 | kubectl port-forward svc/mesh-svc 4000:4000 & 132 | ``` 133 | 134 | #### 2.2 Use `helm` 135 | 136 | ```sh 137 | # Add repository 138 | helm repo add graphql-mesh https://onelittlenightmusic.github.io/graphql-mesh-docker/helm-chart 139 | # Refresh repository 140 | helm repo up 141 | # Install helm chart into Kubernetes 142 | helm install my-graphql-mesh graphql-mesh/graphql-mesh 143 | # or install with parameter file 144 | helm install my-graphql-mesh graphql-mesh/graphql-mesh -f 145 | ``` 146 | 147 | ##### Parameters 148 | 149 | | Name | Description | Default | 150 | |-|-|-| 151 | | `mountConfigMap.".meshrc.yaml"` | ConfigMap name containing `.meshrc.yaml` file | `None` | 152 | | `mountConfigMap."example-query.graphql"` | ConfigMap name containing `example-query.graphql` file | `None` | 153 | | `mountConfigMap."init.sh"` | ConfigMap name containing `init.sh` file. If it exists, container runs GraphQL Mesh after it runs `init.sh` | `None` | 154 | | `mount.".meshrc.yaml"` | inlined `.meshrc.yaml` file | `None` | 155 | | `mount."example-query.graphql"` | inlined `example-query.graphql` file | `None` | 156 | | `mount."init.sh"` | inlined `init.sh` file. If it exists, container runs GraphQL Mesh after it runs `init.sh` | `None` | 157 | | `replicaCount` | Count of replica pods | `1` | 158 | | `image.repository` | Image repository | `hiroyukiosaki/graphql-mesh` | 159 | | `image.tag` | Image tag | `latest` | 160 | | `image.pullPolicy` | `imagePullPolicy` | `IfNotPresent`| 161 | | `imagePullSecrets` | Array of secret name | `[]` | 162 | | `serviceAccount.create` | Create a ServiceAccount for GraphQL Mesh | `true` | 163 | | `serviceAccount.name` | ServiceAccount name | `""` | 164 | | `serviceAccount.annotations` | Annotation structure for ServiceAccount | `{}` | 165 | | `service.type` | Service type | `ClusterIP` | 166 | | `service.port` | Service port | `80` | 167 | | `service.annotations` | Annotation structure for Service | `{}`| 168 | | `ingress.enabled` | Enable an Ingress | `false` | 169 | | `ingress.annotations` | Annotation structure for Ingress | `{}` | 170 | | `ingress.hosts.host` | Host name for Ingress | `graphql-mesh.127.0.0.1.xip.io` | 171 | | `ingress.hosts.path` | Host path array for Ingress | `[]` | 172 | | `resources` | Resource limits and requests (e.g. `limits: { cpu: 100m, memory: 128Mi }`) | `{}` | 173 | 174 | > Please refer to [sample parameter values file](helm-chart/sample-values.yaml) for details. 175 | 176 | # Customize 177 | 178 | There are two ways to customize GraphQL Mesh Docker. 179 | 180 | - Customize `.meshrc.yaml` 181 | - Clone an existing example and run in Docker 182 | 183 | ## Customize .meshrc 184 | 185 | > [GraphQL Mesh Basic Usage (official document)](https://graphql-mesh.com/docs/getting-started/basic-example/) 186 | 187 | - Create your `.meshrc.yaml`. Please follow the guidance of the official document above. 188 | - Place `.meshrc.yaml` in the current directory. 189 | 190 | #### On Docker 191 | 192 | - Go to `docker` directory. 193 | - Edit `docker-compose.yaml` file in order to point your `.meshrc.yaml` and mount it to `/work/.meshrc.yaml` 194 | 195 | ```yaml 196 | volumes: 197 | - ./.meshrc.yaml:/work/.meshrc.yaml # <- comment out and point to your .meshrc.yaml 198 | ``` 199 | - Run `docker-compose up -d mesh` 200 | 201 | #### On Kubernetes (not using Helm) 202 | - **Overwrite** new ConfigMap resource file with this command. 203 | 204 | ```sh 205 | kubectl create cm meshrc-cm --from-file .meshrc.yaml --dry-run -o yaml> k8s/basic/meshrc-cm.yaml 206 | ``` 207 | - Run `kubectl apply -f k8s/basic` 208 | 209 | #### With Helm 210 | 211 | Download [sample values.yaml file](helm-chart/sample-values.yaml) and edit it to include your `.meshrc.yaml` 212 | 213 | ```yaml 214 | mount: 215 | .meshrc.yaml: |- 216 | sources: 217 | - name: Ghibli 218 | handler: 219 | openapi: 220 | source: https://ghibliapi.herokuapp.com/swagger.yaml 221 | ``` 222 | 223 | ## Clone another existing example and run in Docker 224 | 225 | ```sh 226 | # This clones example and creates a directory "covid-mesh" 227 | git clone https://github.com/jycouet/covid-mesh 228 | 229 | # Mount this directory into container and run. 230 | docker run --name mesh -p 4000:4000 -v `pwd`/covid-mesh:/work -it --rm hiroyukiosaki/graphql-mesh:v0.1.17 /bin/bash -c 'yarn install && yarn start' 231 | ``` 232 | 233 | # Example 234 | 235 | ## GraphQL Mesh with MySQL 236 | 237 | ![](img/2020-04-26-19-07-16.png) 238 | 239 | The following use [mysql-employee](https://github.com/Urigo/graphql-mesh/tree/master/examples/mysql-employees) example. 240 | 241 | Simpler docker-compose setup is [here](https://github.com/onelittlenightmusic/graphql-mesh-docker-mysql-example). 242 | 243 | ```sh 244 | git clone https://github.com/datacharmer/test_db.git 245 | 246 | # Run MySQL and restore employee db 247 | docker run --name mysql -v `pwd`/test_db/:/test_db -e MYSQL_ROOT_PASSWORD=passwd -d -p 3306:3306 mysql --default-authentication-plugin=mysql_native_password 248 | docker exec -it mysql /bin/bash 249 | $ cd /test_db 250 | $ mysql < employees.sql -p 251 | # enter "passwd" 252 | 253 | # This clones example 254 | git clone https://github.com/Urigo/graphql-mesh.git 255 | 256 | # Mount this directory into container and run. 257 | docker run --name mesh -v `pwd`/graphql-mesh/examples/mysql-employees:/work -p 4000:4000 -d hiroyukiosaki/graphql-mesh:v0.1.17 /bin/bash -c 'sleep 3600' 258 | 259 | # Edit .meshrc.yaml 260 | # Point host address like this (in Mac) 261 | # host: host.docker.internal 262 | 263 | docker exec -it mesh /bin/bash 264 | $ yarn install 265 | $ yarn start 266 | ``` 267 | 268 | Access `http://localhost:4000` 269 | 270 | 271 | 272 | 291 | 292 | # Build on your own 293 | 294 | Modify Dockerfile and utilize `docker-compose` command to build with Dockerfile. 295 | 296 | ```sh 297 | docker-compose build 298 | ``` 299 | 300 | -------------------------------------------------------------------------------- /docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:15.14 2 | COPY work /work 3 | WORKDIR /work 4 | RUN yarn add graphql @graphql-mesh/runtime @graphql-mesh/cli @graphql-mesh/openapi @graphql-mesh/graphql 5 | CMD if [ -f "init.sh" ]; then sh init.sh; fi && yarn start -------------------------------------------------------------------------------- /docker/Dockerfile-all: -------------------------------------------------------------------------------- 1 | ARG tag=latest 2 | FROM hiroyukiosaki/graphql-mesh:${tag} 3 | RUN yarn add \ 4 | @graphql-mesh/openapi \ 5 | @graphql-mesh/json-schema \ 6 | @graphql-mesh/postgraphile \ 7 | @graphql-mesh/grpc \ 8 | @graphql-mesh/graphql \ 9 | @graphql-mesh/soap \ 10 | @graphql-mesh/mongoose \ 11 | @graphql-mesh/odata \ 12 | @graphql-mesh/thrift \ 13 | @graphql-mesh/tuql \ 14 | @graphql-mesh/mysql \ 15 | @graphql-mesh/neo4j \ 16 | @graphql-mesh/transform-federation \ 17 | @graphql-mesh/transform-rename \ 18 | @graphql-mesh/transform-prefix \ 19 | @graphql-mesh/transform-cache \ 20 | @graphql-mesh/transform-snapshot \ 21 | @graphql-mesh/transform-mock \ 22 | @graphql-mesh/transform-resolvers-composition \ 23 | @graphql-mesh/transform-federation \ 24 | @graphql-mesh/transform-filter-schema \ 25 | @graphql-mesh/transform-naming-convention \ 26 | @graphql-mesh/merger-federation \ 27 | @apollo/gateway \ 28 | apollo-server -------------------------------------------------------------------------------- /docker/Dockerfile-all-alpine: -------------------------------------------------------------------------------- 1 | FROM node:15-alpine 2 | COPY --from=hiroyukiosaki/graphql-mesh:latest-all /work/ /work/ 3 | WORKDIR /work 4 | CMD if [ -f "init.sh" ]; then sh init.sh; fi && yarn start -------------------------------------------------------------------------------- /docker/Dockerfile-alpine: -------------------------------------------------------------------------------- 1 | FROM node:15-alpine 2 | COPY --from=hiroyukiosaki/graphql-mesh:latest /work/ /work/ 3 | WORKDIR /work 4 | CMD if [ -f "init.sh" ]; then sh init.sh; fi && yarn start -------------------------------------------------------------------------------- /docker/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: build 2 | build: 3 | cd docker && docker-compose mesh 4 | cd docker && docker-compose mesh-all 5 | cd docker && docker-compose mesh-alpine 6 | cd docker && docker-compose mesh-all-alpine 7 | cd docker && docker-compose push -------------------------------------------------------------------------------- /docker/docker-compose.yaml: -------------------------------------------------------------------------------- 1 | version: "3.7" 2 | services: 3 | mesh: 4 | build: 5 | context: ./ 6 | dockerfile: Dockerfile 7 | volumes: 8 | - ./work/.meshrc.yaml:/work/.meshrc.yaml 9 | image: hiroyukiosaki/graphql-mesh:latest 10 | ports: 11 | - "4000:4000" 12 | stdin_open: true 13 | tty: true 14 | mesh-all: 15 | build: 16 | context: ./ 17 | dockerfile: Dockerfile-all 18 | args: 19 | tag: latest 20 | volumes: 21 | - ./work/.meshrc.yaml:/work/.meshrc.yaml 22 | image: hiroyukiosaki/graphql-mesh:latest-all 23 | ports: 24 | - "4000:4000" 25 | stdin_open: true 26 | tty: true 27 | mesh-alpine: 28 | build: 29 | context: ./ 30 | dockerfile: Dockerfile-alpine 31 | volumes: 32 | - ./work/.meshrc.yaml:/work/.meshrc.yaml 33 | image: hiroyukiosaki/graphql-mesh:latest-alpine 34 | ports: 35 | - "4000:4000" 36 | stdin_open: true 37 | tty: true 38 | mesh-all-alpine: 39 | build: 40 | context: ./ 41 | dockerfile: Dockerfile-all-alpine 42 | volumes: 43 | - ./work/.meshrc.yaml:/work/.meshrc.yaml 44 | image: hiroyukiosaki/graphql-mesh:latest-all-alpine 45 | ports: 46 | - "4000:4000" 47 | stdin_open: true 48 | tty: true 49 | # command: 50 | # - sh 51 | # - -c 52 | # - sleep 3600 -------------------------------------------------------------------------------- /docker/work/.meshrc.yaml: -------------------------------------------------------------------------------- 1 | # sources: 2 | # - name: Wiki 3 | # handler: 4 | # openapi: 5 | # source: https://api.apis.guru/v2/specs/wikimedia.org/1.0.0/swagger.yaml 6 | 7 | sources: 8 | - name: Covid 9 | handler: 10 | graphql: 11 | endpoint: https://covid-19-two-rust.vercel.app/api/graphql 12 | serve: 13 | hostname: 0.0.0.0 -------------------------------------------------------------------------------- /docker/work/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "test", 3 | "version": "0.1.9", 4 | "main": "index.js", 5 | "scripts": { 6 | "start": "mesh dev" 7 | }, 8 | "license": "Apache-2.0", 9 | "licenses": [ 10 | { 11 | "type": "Apache-2.0", 12 | "url": "http://www.apache.org/licenses/LICENSE-2.0" 13 | } 14 | ], 15 | "dependencies": { 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /helm-chart/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | helm package ../helm-src -------------------------------------------------------------------------------- /helm-chart/graphql-mesh-0.1.0.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onelittlenightmusic/graphql-mesh-docker/bbd09884d6688588c955adc531ebb9dda2036ebd/helm-chart/graphql-mesh-0.1.0.tgz -------------------------------------------------------------------------------- /helm-chart/graphql-mesh-0.1.1.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onelittlenightmusic/graphql-mesh-docker/bbd09884d6688588c955adc531ebb9dda2036ebd/helm-chart/graphql-mesh-0.1.1.tgz -------------------------------------------------------------------------------- /helm-chart/graphql-mesh-configmap.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | data: 3 | .meshrc.yaml: |- 4 | sources: 5 | - name: Wiki 6 | handler: 7 | openapi: 8 | source: https://api.apis.guru/v2/specs/wikimedia.org/1.0.0/swagger.yaml 9 | example-query.graphql: |- 10 | query wikipediaMetricsSample { 11 | getMetricsPageviewsAggregateProjectAccessAgentGranularityStartEnd( 12 | access: ALL_ACCESS 13 | agent: USER 14 | start: "20200101" 15 | end: "20200225" 16 | project: "en.wikipedia.org" 17 | granularity: DAILY 18 | ) { 19 | items { 20 | views 21 | } 22 | } 23 | } 24 | kind: ConfigMap 25 | metadata: 26 | creationTimestamp: null 27 | name: graphql-mesh-meshrc 28 | -------------------------------------------------------------------------------- /helm-chart/graphql-mesh-init-sh.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | data: 3 | init.sh: |- 4 | #!/bin/bash 5 | echo "test" 6 | kind: ConfigMap 7 | metadata: 8 | creationTimestamp: null 9 | name: graphql-mesh-init-sh 10 | -------------------------------------------------------------------------------- /helm-chart/index.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | helm repo index --url https://onelittlenightmusic.github.io/graphql-mesh-docker/helm-chart . -------------------------------------------------------------------------------- /helm-chart/index.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | entries: 3 | graphql-mesh: 4 | - apiVersion: v2 5 | appVersion: 0.11.13 6 | created: "2020-11-29T16:40:44.010105-08:00" 7 | description: A Helm chart for GraphQL Mesh 8 | digest: df939ddcb5310871e76b7bafdccb79ea017e1c3f80ffe9fd23c4c46b83cf9bd9 9 | home: https://onelittlenightmusic.github.io/graphql-mesh-docker/helm-chart 10 | name: graphql-mesh 11 | sources: 12 | - https://github.com/onelittlenightmusic/graphql-mesh-docker 13 | type: application 14 | urls: 15 | - https://onelittlenightmusic.github.io/graphql-mesh-docker/helm-chart/graphql-mesh-0.1.1.tgz 16 | version: 0.1.1 17 | - apiVersion: v2 18 | appVersion: 0.1.15 19 | created: "2020-11-29T16:40:44.009609-08:00" 20 | description: A Helm chart for GraphQL Mesh 21 | digest: 70d6cc46d6789352d5721cde920fae0c5aba12f6900721403cafd04e89d5657a 22 | home: https://onelittlenightmusic.github.io/graphql-mesh-docker/helm-chart 23 | name: graphql-mesh 24 | sources: 25 | - https://github.com/onelittlenightmusic/graphql-mesh-docker 26 | type: application 27 | urls: 28 | - https://onelittlenightmusic.github.io/graphql-mesh-docker/helm-chart/graphql-mesh-0.1.0.tgz 29 | version: 0.1.0 30 | generated: "2020-11-29T16:40:44.00909-08:00" 31 | -------------------------------------------------------------------------------- /helm-chart/sample-values.yaml: -------------------------------------------------------------------------------- 1 | # mountConfigMap: 2 | # # mount and mountConfigMap cannot include the same file name. 3 | # .meshrc.yaml: graphql-mesh-meshrc 4 | # example-query.graphql: graphql-mesh-meshrc 5 | # init.sh: graphql-mesh-init-sh 6 | 7 | mount: 8 | # mount and mountConfigMap cannot include the same file name. 9 | .meshrc.yaml: |- 10 | sources: 11 | - name: Wiki 12 | handler: 13 | openapi: 14 | source: https://ghibliapi.herokuapp.com/swagger.yaml 15 | example-query.graphql: |- 16 | query { 17 | getFilms(limit: 30) { 18 | title 19 | description 20 | } 21 | } 22 | init.sh: |- 23 | #!/bin/bash 24 | echo "test" 25 | 26 | ingress: 27 | enabled: true 28 | annotations: 29 | kubernetes.io/ingress.class: nginx 30 | # kubernetes.io/tls-acme: "true" 31 | hosts: 32 | - host: graphql-mesh.127.0.0.1.xip.io 33 | paths: ["/"] -------------------------------------------------------------------------------- /helm-src/.helmignore: -------------------------------------------------------------------------------- 1 | # Patterns to ignore when building packages. 2 | # This supports shell glob matching, relative path matching, and 3 | # negation (prefixed with !). Only one pattern per line. 4 | .DS_Store 5 | # Common VCS dirs 6 | .git/ 7 | .gitignore 8 | .bzr/ 9 | .bzrignore 10 | .hg/ 11 | .hgignore 12 | .svn/ 13 | # Common backup files 14 | *.swp 15 | *.bak 16 | *.tmp 17 | *.orig 18 | *~ 19 | # Various IDEs 20 | .project 21 | .idea/ 22 | *.tmproj 23 | .vscode/ 24 | -------------------------------------------------------------------------------- /helm-src/Chart.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v2 2 | name: graphql-mesh 3 | description: A Helm chart for GraphQL Mesh 4 | 5 | # A chart can be either an 'application' or a 'library' chart. 6 | # 7 | # Application charts are a collection of templates that can be packaged into versioned archives 8 | # to be deployed. 9 | # 10 | # Library charts provide useful utilities or functions for the chart developer. They're included as 11 | # a dependency of application charts to inject those utilities and functions into the rendering 12 | # pipeline. Library charts do not define any templates and therefore cannot be deployed. 13 | type: application 14 | 15 | # This is the chart version. This version number should be incremented each time you make changes 16 | # to the chart and its templates, including the app version. 17 | # Versions are expected to follow Semantic Versioning (https://semver.org/) 18 | version: 0.1.1 19 | 20 | # This is the version number of the application being deployed. This version number should be 21 | # incremented each time you make changes to the application. Versions are not expected to 22 | # follow Semantic Versioning. They should reflect the version the application is using. 23 | appVersion: 0.11.13 24 | home: https://onelittlenightmusic.github.io/graphql-mesh-docker/helm-chart 25 | sources: 26 | - https://github.com/onelittlenightmusic/graphql-mesh-docker 27 | -------------------------------------------------------------------------------- /helm-src/templates/NOTES.txt: -------------------------------------------------------------------------------- 1 | 1. Get the application URL by running these commands: 2 | {{- if .Values.ingress.enabled }} 3 | {{- range $host := .Values.ingress.hosts }} 4 | {{- range .paths }} 5 | http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ . }} 6 | {{- end }} 7 | {{- end }} 8 | {{- else if contains "NodePort" .Values.service.type }} 9 | export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "graphql-mesh.fullname" . }}) 10 | export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") 11 | echo http://$NODE_IP:$NODE_PORT 12 | {{- else if contains "LoadBalancer" .Values.service.type }} 13 | NOTE: It may take a few minutes for the LoadBalancer IP to be available. 14 | You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "graphql-mesh.fullname" . }}' 15 | export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "graphql-mesh.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") 16 | echo http://$SERVICE_IP:{{ .Values.service.port }} 17 | {{- else if contains "ClusterIP" .Values.service.type }} 18 | export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "graphql-mesh.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") 19 | echo "Visit http://127.0.0.1:8080 to use your application" 20 | kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:80 21 | {{- end }} 22 | -------------------------------------------------------------------------------- /helm-src/templates/_helpers.tpl: -------------------------------------------------------------------------------- 1 | {{/* vim: set filetype=mustache: */}} 2 | {{/* 3 | Expand the name of the chart. 4 | */}} 5 | {{- define "graphql-mesh.name" -}} 6 | {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} 7 | {{- end }} 8 | 9 | {{/* 10 | Create a default fully qualified app name. 11 | We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). 12 | If release name contains chart name it will be used as a full name. 13 | */}} 14 | {{- define "graphql-mesh.fullname" -}} 15 | {{- if .Values.fullnameOverride }} 16 | {{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} 17 | {{- else }} 18 | {{- $name := default .Chart.Name .Values.nameOverride }} 19 | {{- if contains $name .Release.Name }} 20 | {{- .Release.Name | trunc 63 | trimSuffix "-" }} 21 | {{- else }} 22 | {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} 23 | {{- end }} 24 | {{- end }} 25 | {{- end }} 26 | 27 | {{/* 28 | Create chart name and version as used by the chart label. 29 | */}} 30 | {{- define "graphql-mesh.chart" -}} 31 | {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} 32 | {{- end }} 33 | 34 | {{/* 35 | Common labels 36 | */}} 37 | {{- define "graphql-mesh.labels" -}} 38 | helm.sh/chart: {{ include "graphql-mesh.chart" . }} 39 | {{ include "graphql-mesh.selectorLabels" . }} 40 | {{- if .Chart.AppVersion }} 41 | app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} 42 | {{- end }} 43 | app.kubernetes.io/managed-by: {{ .Release.Service }} 44 | {{- end }} 45 | 46 | {{/* 47 | Selector labels 48 | */}} 49 | {{- define "graphql-mesh.selectorLabels" -}} 50 | app.kubernetes.io/name: {{ include "graphql-mesh.name" . }} 51 | app.kubernetes.io/instance: {{ .Release.Name }} 52 | {{- end }} 53 | 54 | {{/* 55 | Create the name of the service account to use 56 | */}} 57 | {{- define "graphql-mesh.serviceAccountName" -}} 58 | {{- if .Values.serviceAccount.create }} 59 | {{- default (include "graphql-mesh.fullname" .) .Values.serviceAccount.name }} 60 | {{- else }} 61 | {{- default "default" .Values.serviceAccount.name }} 62 | {{- end }} 63 | {{- end }} 64 | -------------------------------------------------------------------------------- /helm-src/templates/deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: {{ include "graphql-mesh.fullname" . }} 5 | labels: 6 | {{- include "graphql-mesh.labels" . | nindent 4 }} 7 | spec: 8 | {{- if not .Values.autoscaling.enabled }} 9 | replicas: {{ .Values.replicaCount }} 10 | {{- end }} 11 | selector: 12 | matchLabels: 13 | {{- include "graphql-mesh.selectorLabels" . | nindent 6 }} 14 | template: 15 | metadata: 16 | {{- with .Values.podAnnotations }} 17 | annotations: 18 | {{- toYaml . | nindent 8 }} 19 | {{- end }} 20 | labels: 21 | {{- include "graphql-mesh.selectorLabels" . | nindent 8 }} 22 | spec: 23 | {{- with .Values.imagePullSecrets }} 24 | imagePullSecrets: 25 | {{- toYaml . | nindent 8 }} 26 | {{- end }} 27 | serviceAccountName: {{ include "graphql-mesh.serviceAccountName" . }} 28 | securityContext: 29 | {{- toYaml .Values.podSecurityContext | nindent 8 }} 30 | containers: 31 | - name: {{ .Chart.Name }} 32 | securityContext: 33 | {{- toYaml .Values.securityContext | nindent 12 }} 34 | image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" 35 | imagePullPolicy: {{ .Values.image.pullPolicy }} 36 | ports: 37 | - name: http 38 | containerPort: 4000 39 | protocol: TCP 40 | livenessProbe: 41 | httpGet: 42 | path: / 43 | port: http 44 | initialDelaySeconds: {{ .Values.initialDelaySeconds }} 45 | readinessProbe: 46 | httpGet: 47 | path: / 48 | port: http 49 | initialDelaySeconds: {{ .Values.initialDelaySeconds }} 50 | resources: 51 | {{- toYaml .Values.resources | nindent 12 }} 52 | volumeMounts: 53 | {{- with .Values.mountConfigMap }} 54 | {{- range $file, $configMap := . }} 55 | - mountPath: "/work/{{ $file }}" 56 | name: {{ $configMap }} 57 | subPath: {{ $file }} 58 | {{- end }} 59 | {{- end }} 60 | {{- with .Values.mount }} 61 | {{- range $file := keys . }} 62 | - mountPath: "/work/{{ $file }}" 63 | name: raw-files 64 | subPath: {{ $file }} 65 | {{- end }} 66 | {{- end }} 67 | {{- with .Values.command }} 68 | command: 69 | {{- toYaml . | nindent 12}} 70 | {{- end}} 71 | {{- with .Values.nodeSelector }} 72 | nodeSelector: 73 | {{- toYaml . | nindent 8 }} 74 | {{- end }} 75 | {{- with .Values.affinity }} 76 | affinity: 77 | {{- toYaml . | nindent 8 }} 78 | {{- end }} 79 | {{- with .Values.tolerations }} 80 | tolerations: 81 | {{- toYaml . | nindent 8 }} 82 | {{- end }} 83 | volumes: 84 | {{- with .Values.mountConfigMap }} 85 | {{- range $configMap := values . | uniq }} 86 | - name: {{ $configMap }} 87 | configMap: 88 | name: {{ $configMap }} 89 | {{- end }} 90 | {{- end }} 91 | {{- if .Values.mount }} 92 | - name: raw-files 93 | configMap: 94 | name: {{ include "graphql-mesh.fullname" . }}-raw-files 95 | {{- end }} -------------------------------------------------------------------------------- /helm-src/templates/hpa.yaml: -------------------------------------------------------------------------------- 1 | {{- if .Values.autoscaling.enabled }} 2 | apiVersion: autoscaling/v2beta1 3 | kind: HorizontalPodAutoscaler 4 | metadata: 5 | name: {{ include "graphql-mesh.fullname" . }} 6 | labels: 7 | {{- include "graphql-mesh.labels" . | nindent 4 }} 8 | spec: 9 | scaleTargetRef: 10 | apiVersion: apps/v1 11 | kind: Deployment 12 | name: {{ include "graphql-mesh.fullname" . }} 13 | minReplicas: {{ .Values.autoscaling.minReplicas }} 14 | maxReplicas: {{ .Values.autoscaling.maxReplicas }} 15 | metrics: 16 | {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} 17 | - type: Resource 18 | resource: 19 | name: cpu 20 | targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} 21 | {{- end }} 22 | {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} 23 | - type: Resource 24 | resource: 25 | name: memory 26 | targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} 27 | {{- end }} 28 | {{- end }} 29 | -------------------------------------------------------------------------------- /helm-src/templates/ingress.yaml: -------------------------------------------------------------------------------- 1 | {{- if .Values.ingress.enabled -}} 2 | {{- $fullName := include "graphql-mesh.fullname" . -}} 3 | {{- $svcPort := .Values.service.port -}} 4 | {{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} 5 | apiVersion: networking.k8s.io/v1 6 | kind: Ingress 7 | metadata: 8 | name: {{ $fullName }} 9 | labels: 10 | {{- include "graphql-mesh.labels" . | nindent 4 }} 11 | {{- with .Values.ingress.annotations }} 12 | annotations: 13 | {{- toYaml . | nindent 4 }} 14 | {{- end }} 15 | spec: 16 | {{- if .Values.ingress.tls }} 17 | tls: 18 | {{- range .Values.ingress.tls }} 19 | - hosts: 20 | {{- range .hosts }} 21 | - {{ . | quote }} 22 | {{- end }} 23 | secretName: {{ .secretName }} 24 | {{- end }} 25 | {{- end }} 26 | rules: 27 | {{- range .Values.ingress.hosts }} 28 | - host: {{ .host | quote }} 29 | http: 30 | paths: 31 | {{- range .paths }} 32 | - path: {{ . }} 33 | pathType: Prefix 34 | backend: 35 | service: 36 | name: {{ $fullName }} 37 | port: 38 | number: {{ $svcPort }} 39 | {{- end }} 40 | {{- end }} 41 | {{- else -}} 42 | apiVersion: extensions/v1beta1 43 | kind: Ingress 44 | metadata: 45 | name: {{ $fullName }} 46 | labels: 47 | {{- include "graphql-mesh.labels" . | nindent 4 }} 48 | {{- with .Values.ingress.annotations }} 49 | annotations: 50 | {{- toYaml . | nindent 4 }} 51 | {{- end }} 52 | spec: 53 | {{- if .Values.ingress.tls }} 54 | tls: 55 | {{- range .Values.ingress.tls }} 56 | - hosts: 57 | {{- range .hosts }} 58 | - {{ . | quote }} 59 | {{- end }} 60 | secretName: {{ .secretName }} 61 | {{- end }} 62 | {{- end }} 63 | rules: 64 | {{- range .Values.ingress.hosts }} 65 | - host: {{ .host | quote }} 66 | http: 67 | paths: 68 | {{- range .paths }} 69 | - path: {{ . }} 70 | backend: 71 | serviceName: {{ $fullName }} 72 | servicePort: {{ $svcPort }} 73 | {{- end }} 74 | {{- end }} 75 | {{- end }} 76 | {{- end }} 77 | -------------------------------------------------------------------------------- /helm-src/templates/raw-files-configmap.yaml: -------------------------------------------------------------------------------- 1 | {{- if .Values.mount -}} 2 | {{- $fullName := include "graphql-mesh.fullname" . -}} 3 | apiVersion: v1 4 | kind: ConfigMap 5 | metadata: 6 | name: {{ $fullName }}-raw-files 7 | labels: 8 | {{- include "graphql-mesh.labels" . | nindent 4 }} 9 | data: 10 | {{- range $file, $content := .Values.mount}} 11 | {{ $file }}: | 12 | {{- $content | nindent 4 }} 13 | {{- end }} 14 | {{- end }} -------------------------------------------------------------------------------- /helm-src/templates/service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: {{ include "graphql-mesh.fullname" . }} 5 | labels: 6 | {{- include "graphql-mesh.labels" . | nindent 4 }} 7 | {{- with .Values.service.annotations }} 8 | annotations: 9 | {{- toYaml . | nindent 4 }} 10 | {{- end }} 11 | spec: 12 | type: {{ .Values.service.type }} 13 | ports: 14 | - port: {{ .Values.service.port }} 15 | targetPort: http 16 | protocol: TCP 17 | name: http 18 | selector: 19 | {{- include "graphql-mesh.selectorLabels" . | nindent 4 }} 20 | -------------------------------------------------------------------------------- /helm-src/templates/serviceaccount.yaml: -------------------------------------------------------------------------------- 1 | {{- if .Values.serviceAccount.create -}} 2 | apiVersion: v1 3 | kind: ServiceAccount 4 | metadata: 5 | name: {{ include "graphql-mesh.serviceAccountName" . }} 6 | labels: 7 | {{- include "graphql-mesh.labels" . | nindent 4 }} 8 | {{- with .Values.serviceAccount.annotations }} 9 | annotations: 10 | {{- toYaml . | nindent 4 }} 11 | {{- end }} 12 | {{- end }} 13 | -------------------------------------------------------------------------------- /helm-src/templates/tests/test-connection.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Pod 3 | metadata: 4 | name: "{{ include "graphql-mesh.fullname" . }}-test-connection" 5 | labels: 6 | {{- include "graphql-mesh.labels" . | nindent 4 }} 7 | annotations: 8 | "helm.sh/hook": test-success 9 | spec: 10 | containers: 11 | - name: wget 12 | image: busybox 13 | command: ['wget'] 14 | args: ['{{ include "graphql-mesh.fullname" . }}:{{ .Values.service.port }}'] 15 | restartPolicy: Never 16 | -------------------------------------------------------------------------------- /helm-src/values.yaml: -------------------------------------------------------------------------------- 1 | # Default values for graphql-mesh. 2 | # This is a YAML-formatted file. 3 | # Declare variables to be passed into your templates. 4 | 5 | # mountConfigMap: 6 | # # mount and mountConfigMap cannot include the same file name. 7 | # .meshrc.yaml: graphql-mesh-meshrc 8 | # example-query.graphql: graphql-mesh-meshrc 9 | # init.sh: graphql-mesh-init-sh 10 | 11 | # mount: 12 | # # mount and mountConfigMap cannot include the same file name. 13 | # .meshrc.yaml: |- 14 | # sources: 15 | # - name: Wiki 16 | # handler: 17 | # openapi: 18 | # source: https://ghibliapi.herokuapp.com/swagger.yaml 19 | # example-query.graphql: |- 20 | # query { 21 | # getFilms(limit: 30) { 22 | # title 23 | # description 24 | # } 25 | # } 26 | # init.sh: |- 27 | # #!/bin/bash 28 | # echo "test" 29 | 30 | replicaCount: 1 31 | 32 | image: 33 | repository: hiroyukiosaki/graphql-mesh 34 | pullPolicy: IfNotPresent 35 | tag: "latest-all-alpine" 36 | # tag: "latest" # to simple image 37 | 38 | imagePullSecrets: [] 39 | nameOverride: "" 40 | fullnameOverride: "" 41 | 42 | serviceAccount: 43 | # Specifies whether a service account should be created 44 | create: true 45 | # Annotations to add to the service account 46 | annotations: {} 47 | # The name of the service account to use. 48 | # If not set and create is true, a name is generated using the fullname template 49 | name: "" 50 | 51 | service: 52 | type: ClusterIP 53 | port: 80 54 | annotations: {} 55 | # sidecar.istio.io/inject: "false" 56 | 57 | ingress: 58 | enabled: true 59 | annotations: {} 60 | # kubernetes.io/ingress.class: nginx 61 | # kubernetes.io/tls-acme: "true" 62 | hosts: 63 | - host: graphql-mesh.127.0.0.1.xip.io 64 | paths: ["/"] 65 | tls: [] 66 | # - secretName: graphql-mesh-tls 67 | # hosts: 68 | # - graphql-mesh.local 69 | 70 | # # For debugging, change startup command here. 71 | # command: 72 | # - /bin/bash 73 | # - -c 74 | # - sleep 3600 75 | 76 | resources: {} 77 | # limits: 78 | # cpu: 100m 79 | # memory: 128Mi 80 | # requests: 81 | # cpu: 100m 82 | # memory: 128Mi 83 | 84 | podAnnotations: {} 85 | 86 | podSecurityContext: {} 87 | # fsGroup: 2000 88 | 89 | securityContext: {} 90 | # capabilities: 91 | # drop: 92 | # - ALL 93 | # readOnlyRootFilesystem: true 94 | # runAsNonRoot: true 95 | # runAsUser: 1000 96 | 97 | autoscaling: 98 | enabled: false 99 | minReplicas: 1 100 | maxReplicas: 100 101 | targetCPUUtilizationPercentage: 80 102 | # targetMemoryUtilizationPercentage: 80 103 | 104 | nodeSelector: {} 105 | 106 | tolerations: [] 107 | 108 | affinity: {} 109 | 110 | initialDelaySeconds: 30 111 | -------------------------------------------------------------------------------- /img/2020-04-26-19-07-16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onelittlenightmusic/graphql-mesh-docker/bbd09884d6688588c955adc531ebb9dda2036ebd/img/2020-04-26-19-07-16.png -------------------------------------------------------------------------------- /img/2020-05-25-13-35-39.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onelittlenightmusic/graphql-mesh-docker/bbd09884d6688588c955adc531ebb9dda2036ebd/img/2020-05-25-13-35-39.png -------------------------------------------------------------------------------- /img/2021-05-21-17-14-46.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onelittlenightmusic/graphql-mesh-docker/bbd09884d6688588c955adc531ebb9dda2036ebd/img/2021-05-21-17-14-46.png -------------------------------------------------------------------------------- /img/docker.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onelittlenightmusic/graphql-mesh-docker/bbd09884d6688588c955adc531ebb9dda2036ebd/img/docker.png -------------------------------------------------------------------------------- /img/helm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onelittlenightmusic/graphql-mesh-docker/bbd09884d6688588c955adc531ebb9dda2036ebd/img/helm.png -------------------------------------------------------------------------------- /img/kubernetes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onelittlenightmusic/graphql-mesh-docker/bbd09884d6688588c955adc531ebb9dda2036ebd/img/kubernetes.png -------------------------------------------------------------------------------- /img/mesh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onelittlenightmusic/graphql-mesh-docker/bbd09884d6688588c955adc531ebb9dda2036ebd/img/mesh.png -------------------------------------------------------------------------------- /k8s/basic/meshrc-cm.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | data: 3 | .meshrc.yaml: |- 4 | sources: 5 | - name: Wiki 6 | handler: 7 | openapi: 8 | source: https://api.apis.guru/v2/specs/wikimedia.org/1.0.0/swagger.yaml 9 | kind: ConfigMap 10 | metadata: 11 | creationTimestamp: null 12 | name: meshrc-cm 13 | -------------------------------------------------------------------------------- /k8s/basic/pod.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Pod 3 | metadata: 4 | creationTimestamp: null 5 | labels: 6 | run: mesh 7 | name: mesh 8 | spec: 9 | containers: 10 | - # image: hiroyukiosaki/graphql-mesh:v0.1.9 11 | image: hiroyukiosaki/graphql-mesh:latest 12 | name: mesh 13 | resources: {} 14 | ports: 15 | - containerPort: 4000 16 | volumeMounts: 17 | - mountPath: /work/.meshrc.yaml 18 | name: meshrc-cm 19 | subPath: .meshrc.yaml 20 | volumes: 21 | - name: meshrc-cm 22 | configMap: 23 | name: meshrc-cm 24 | dnsPolicy: ClusterFirst 25 | restartPolicy: Always 26 | status: {} 27 | -------------------------------------------------------------------------------- /k8s/basic/service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: mesh-svc 5 | spec: 6 | selector: 7 | run: mesh 8 | ports: 9 | - protocol: TCP 10 | port: 4000 11 | targetPort: 4000 -------------------------------------------------------------------------------- /k8s/jsonschema-covid19/meshrc-cm.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | data: 3 | .meshrc.yaml: "sources:\n - name: Covid\n handler:\n graphql:\n endpoint: 4 | https://covid-19.dava.engineer/api/graphql\n - name: WorldPop\n handler:\n 5 | \ jsonSchema:\n baseUrl: https://datasource.kapsarc.org/api/records/1.0/search\n 6 | \ operations:\n - type: Query\n field: population\n 7 | \ path: /?dataset=world-population&q={args.country}&rows=1&sort=year&facet=year&facet=country_name\n 8 | \ method: GET \n responseSchema: ./src/worldPop.json\ntransforms:\n 9 | \ - extend: |\n extend type Case {\n population: ApiPopulation\n }\n 10 | \ extend type Query {\n stat(country: String!): Stat\n }\n type 11 | Stat {\n confirmedRatio: Float\n deathRatio: Float\n recoveredRatio: 12 | Float\n case: Case\n population: ApiPopulation\n }\nadditionalResolvers:\n 13 | \ - ./src/case-additional-resolvers.js\n - ./src/query-additional-resolvers.js" 14 | kind: ConfigMap 15 | metadata: 16 | creationTimestamp: null 17 | name: meshrc-cm 18 | -------------------------------------------------------------------------------- /k8s/jsonschema-covid19/meshrc/.meshrc.yaml: -------------------------------------------------------------------------------- 1 | sources: 2 | - name: Covid 3 | handler: 4 | graphql: 5 | endpoint: https://covid-19.dava.engineer/api/graphql 6 | - name: WorldPop 7 | handler: 8 | jsonSchema: 9 | baseUrl: https://datasource.kapsarc.org/api/records/1.0/search 10 | operations: 11 | - type: Query 12 | field: population 13 | path: /?dataset=world-population&q={args.country}&rows=1&sort=year&facet=year&facet=country_name 14 | method: GET 15 | responseSchema: ./src/worldPop.json 16 | transforms: 17 | - extend: | 18 | extend type Case { 19 | population: ApiPopulation 20 | } 21 | extend type Query { 22 | stat(country: String!): Stat 23 | } 24 | type Stat { 25 | confirmedRatio: Float 26 | deathRatio: Float 27 | recoveredRatio: Float 28 | case: Case 29 | population: ApiPopulation 30 | } 31 | additionalResolvers: 32 | - ./src/case-additional-resolvers.js 33 | - ./src/query-additional-resolvers.js -------------------------------------------------------------------------------- /k8s/jsonschema-covid19/pod.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Pod 3 | metadata: 4 | creationTimestamp: null 5 | labels: 6 | run: mesh 7 | name: mesh 8 | spec: 9 | containers: 10 | - # image: hiroyukiosaki/graphql-mesh:v0.1.9 11 | image: hiroyukiosaki/graphql-mesh:v0.1.10-all 12 | name: mesh 13 | resources: {} 14 | ports: 15 | - containerPort: 4000 16 | volumeMounts: 17 | - mountPath: /work/.meshrc.yaml 18 | name: meshrc-cm 19 | subPath: .meshrc.yaml 20 | - mountPath: /work/src 21 | name: src-cm 22 | # # for test 23 | # command: 24 | # - sh 25 | # - -c 26 | # - sleep 3600 27 | volumes: 28 | - name: meshrc-cm 29 | configMap: 30 | name: meshrc-cm 31 | - name: src-cm 32 | configMap: 33 | name: src-cm 34 | dnsPolicy: ClusterFirst 35 | restartPolicy: Always 36 | status: {} 37 | -------------------------------------------------------------------------------- /k8s/jsonschema-covid19/service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: mesh-svc 5 | spec: 6 | selector: 7 | run: mesh 8 | ports: 9 | - protocol: TCP 10 | port: 4000 11 | targetPort: 4000 -------------------------------------------------------------------------------- /k8s/jsonschema-covid19/src-cm.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | data: 3 | case-additional-resolvers.js: | 4 | const resolvers = { 5 | Case: { 6 | population: async ({ countryRegion }, args, { WorldPop }) => { 7 | if (countryRegion) { 8 | return await WorldPop.api.population({ 9 | country: countryRegion, 10 | }); 11 | } 12 | throw Error( 13 | "countryRegion is a needed field at case level to get population info" 14 | ); 15 | }, 16 | }, 17 | }; 18 | 19 | module.exports = { resolvers }; 20 | query-additional-resolvers.js: | 21 | const resolvers = { 22 | Query: { 23 | stat: async (root, args, { WorldPop, Covid }) => { 24 | const worldPop = await WorldPop.api.population({ 25 | country: args.country, 26 | }); 27 | const covid = await Covid.api.case({ 28 | countryRegion: args.country, 29 | }); 30 | const numberPop = worldPop.records[0].fields.value; 31 | 32 | const numberConfirmed = covid.confirmed; 33 | const numberDeath = covid.deaths; 34 | const numberRecovered = covid.recovered; 35 | return { 36 | confirmedRatio: ((numberConfirmed * 1.0) / numberPop) * 1.0, 37 | deathRatio: ((numberDeath * 1.0) / numberPop) * 1.0, 38 | recoveredRatio: ((numberRecovered * 1.0) / numberPop) * 1.0, 39 | case: covid, 40 | population: worldPop 41 | }; 42 | }, 43 | }, 44 | }; 45 | 46 | module.exports = { resolvers }; 47 | worldPop.json: |- 48 | { 49 | "type": "object", 50 | "title": "Api Population", 51 | "description": "Desc Api Population", 52 | "properties": { 53 | "records": { 54 | "type": "array", 55 | "items": { 56 | "type": "object", 57 | "title": "Result", 58 | "description": "Result of API", 59 | "properties": { 60 | "fields": { 61 | "type": "object", 62 | "properties": { 63 | "country_name": { 64 | "type": "string" 65 | }, 66 | "value": { 67 | "type": "number" 68 | }, 69 | "year": { 70 | "type": "string" 71 | } 72 | } 73 | } 74 | } 75 | } 76 | } 77 | } 78 | } 79 | kind: ConfigMap 80 | metadata: 81 | creationTimestamp: null 82 | name: src-cm 83 | -------------------------------------------------------------------------------- /k8s/jsonschema-covid19/src/case-additional-resolvers.js: -------------------------------------------------------------------------------- 1 | const resolvers = { 2 | Case: { 3 | population: async ({ countryRegion }, args, { WorldPop }) => { 4 | if (countryRegion) { 5 | return await WorldPop.api.population({ 6 | country: countryRegion, 7 | }); 8 | } 9 | throw Error( 10 | "countryRegion is a needed field at case level to get population info" 11 | ); 12 | }, 13 | }, 14 | }; 15 | 16 | module.exports = { resolvers }; 17 | -------------------------------------------------------------------------------- /k8s/jsonschema-covid19/src/query-additional-resolvers.js: -------------------------------------------------------------------------------- 1 | const resolvers = { 2 | Query: { 3 | stat: async (root, args, { WorldPop, Covid }) => { 4 | const worldPop = await WorldPop.api.population({ 5 | country: args.country, 6 | }); 7 | const covid = await Covid.api.case({ 8 | countryRegion: args.country, 9 | }); 10 | const numberPop = worldPop.records[0].fields.value; 11 | 12 | const numberConfirmed = covid.confirmed; 13 | const numberDeath = covid.deaths; 14 | const numberRecovered = covid.recovered; 15 | return { 16 | confirmedRatio: ((numberConfirmed * 1.0) / numberPop) * 1.0, 17 | deathRatio: ((numberDeath * 1.0) / numberPop) * 1.0, 18 | recoveredRatio: ((numberRecovered * 1.0) / numberPop) * 1.0, 19 | case: covid, 20 | population: worldPop 21 | }; 22 | }, 23 | }, 24 | }; 25 | 26 | module.exports = { resolvers }; 27 | -------------------------------------------------------------------------------- /k8s/jsonschema-covid19/src/worldPop.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "object", 3 | "title": "Api Population", 4 | "description": "Desc Api Population", 5 | "properties": { 6 | "records": { 7 | "type": "array", 8 | "items": { 9 | "type": "object", 10 | "title": "Result", 11 | "description": "Result of API", 12 | "properties": { 13 | "fields": { 14 | "type": "object", 15 | "properties": { 16 | "country_name": { 17 | "type": "string" 18 | }, 19 | "value": { 20 | "type": "number" 21 | }, 22 | "year": { 23 | "type": "string" 24 | } 25 | } 26 | } 27 | } 28 | } 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /kind-config.yaml: -------------------------------------------------------------------------------- 1 | kind: Cluster 2 | apiVersion: kind.x-k8s.io/v1alpha4 3 | nodes: 4 | - role: control-plane 5 | kubeadmConfigPatches: 6 | - | 7 | kind: InitConfiguration 8 | nodeRegistration: 9 | kubeletExtraArgs: 10 | node-labels: "ingress-ready=true" 11 | extraPortMappings: 12 | - containerPort: 80 13 | hostPort: 80 14 | protocol: TCP 15 | - containerPort: 443 16 | hostPort: 443 17 | protocol: TCP -------------------------------------------------------------------------------- /update.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | over=0.2.11 3 | nver=0.2.13 4 | sed -i "" "s/$over/$nver/g" docker-compose.yaml 5 | docker-compose build 6 | sed -i "" "s/$over/$nver/g" helm-src/values.yaml 7 | cd helm-chart 8 | ./build.sh 9 | ./index.sh 10 | cd .. 11 | 12 | sed -i "" "s/$over/$nver/g" README.md 13 | git add -A 14 | git commit -m "$nver" 15 | --------------------------------------------------------------------------------