ocglooctl- OpenShift v3.7+ deployed somewhere. minishift is a great way to get a cluster up quickly.
-
Gloo and Envoy deployed and running on OpenShift:
glooctl install openshift -
Next, deploy the Pet Store app to OpenShift:
oc apply \ -f https://raw.githubusercontent.com/solo-io/gloo/master/example/petstore/petstore.yaml -
The discovery services should have already created an Upstream for the petstore service. Let's verify this:
glooctl upstream get default-petstore-8080 gloo-system-gloo-8081 gloo-system-ingress-8080 gloo-system-ingress-8443The upstream we want to see is
default-petstore-8080. Digging a little deeper, we can verify that Gloo's function discovery populated our upstream with the available rest endpoints it implements. Note: the upstream was created in thegloo-systemnamespace rather thandefaultbecause it was created by a discovery service. Upstreams and virtualservices do not need to live in thegloo-systemnamespace to be processed by Gloo.
-
Let's take a closer look at the functions that are available on this upstream (edited here to reduce verbosity):
glooctl upstream get default-petstore-8080 -o yaml functions: - name: addPet spec: body: '{"tag": "{{tag}}","id": {{id}},"name": "{{name}}"}' headers: :method: POST path: /api/pets - name: deletePet spec: body: "" headers: :method: DELETE path: /api/pets/{{id}} - name: findPetById spec: body: "" headers: :method: GET path: /api/pets/{{id}} - name: findPets spec: body: "" headers: :method: GET path: /api/pets?tags={{tags}}&limit={{limit}} metadata: annotations: generated_by: kubernetes-upstream-discovery gloo.solo.io/swagger_url: http://petstore.default.svc.cluster.local:8080/swagger.json namespace: gloo-system resource_version: "320962" name: default-petstore-8080 spec: labels: null service_name: petstore service_namespace: default service_port: 8080 status: state: Accepted type: kubernetes -
Let's now use
glooctlto create a route for this upstream.glooctl route create \ --path-exact /petstore/list \ --upstream default-petstore-8080 \ --prefix-rewrite /api/petsWe need the
--prefix-rewriteflag so Envoy knows to change the path on the outgoing request to the path our petstore expects.With
glooctl, we can see that a virtual host was created with our route:glooctl virtualservice get -o yaml metadata: namespace: gloo-system resource_version: "3052" name: default routes: - request_matcher: path_exact: /petstore/list single_destination: upstream: name: default-petstore-8080 status: state: Accepted -
Let's test the route
/petstore/listusingcurl:export GATEWAY_URL=http://$(minishift ip):$(oc get svc ingress -n gloo-system -o 'jsonpath={.spec.ports[?(@.name=="http")].nodePort}') curl ${GATEWAY_URL}/petstore/list [{"id":1,"name":"Dog","status":"available"},{"id":2,"name":"Cat","status":"pending"}]
Great! our gateway is up and running. Let's make things a bit more sophisticated in the next section with Function Routing.