Skip to content

Commit

Permalink
refactor: rename endpoints to ingresses
Browse files Browse the repository at this point in the history
BREAKING CHANGES:

Any `garden.yml` file that includes an `endpoints` key will need to
be updated. Sorry. But this should be much clearer for users.
  • Loading branch information
edvald committed Sep 12, 2018
1 parent af2af06 commit dde932f
Show file tree
Hide file tree
Showing 49 changed files with 180 additions and 180 deletions.
10 changes: 5 additions & 5 deletions docs/examples/simple-project.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,11 @@ module:
ports:
- name: http
containerPort: 8080
endpoints:
ingresses:
- path: /hello-node
port: http
```
The [services](../guides/configuration.md#Services) directive is specific to container modules, and defines the services exposed by the module. In this case, our containerized Node.js server. The sub-directives tell Garden how to start the service and which endpoints to expose.
The [services](../guides/configuration.md#Services) directive is specific to container modules, and defines the services exposed by the module. In this case, our containerized Node.js server. The sub-directives tell Garden how to start the service and which ingress endpoints to expose.

## Deploying

Expand All @@ -132,7 +132,7 @@ Garden can now deploy our service to a local Kubernetes cluster:
$ garden deploy
```

To verify that everything is working, we can call the service at the `/hello-node` endpoint defined in `/services/node-service/app.js`:
To verify that everything is working, we can call the service at the `/hello-node` ingress defined in `/services/node-service/app.js`:

```sh
$ garden call node-service/hello-node
Expand Down Expand Up @@ -160,7 +160,7 @@ module:
ports:
- name: http
containerPort: 80
endpoints:
ingresses:
- path: /hello-go
port: http
```
Expand Down Expand Up @@ -290,7 +290,7 @@ module:
ports:
- name: http
containerPort: 8080
endpoints:
ingresses:
- path: /
port: http
dependencies:
Expand Down
2 changes: 1 addition & 1 deletion docs/guides/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ module:
ports:
- name: http
containerPort: 8080
endpoints:
ingresses:
- path: /hello
port: http
healthCheck:
Expand Down
24 changes: 12 additions & 12 deletions docs/guides/glossary.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
# Glossary

#### Environment
Represents the current configuration and status of any running services in the [project](#project), which may be
Represents the current configuration and status of any running services in the [project](#project), which may be
inspected and modified via the Garden CLI's `environment` command.

Several named environment configurations may be defined (e.g. _dev_, _testing_, ...) in the [project's
Several named environment configurations may be defined (e.g. _dev_, _testing_, ...) in the [project's
`garden.yml`](../guides/configuration.md#project-configuration).

#### Module
The basic unit of configuration in Garden. A module is defined by its
[`garden.yml` configuration file](../guides/configuration.md#module-configuration), located in the module's top-level
directory,
which
[`garden.yml` configuration file](../guides/configuration.md#module-configuration), located in the module's top-level
directory,
which
is a subdirectory of the [project](#project) repository's top-level directory.

Each module has a [plugin](#plugin) type, and may define one or more [services](#service).

Essentially, a project is organized into modules at the granularity of its *build* steps. A module's build step may
depend on one or more other modules, as specified in its `garden.yml`, in which case those modules will be built
Essentially, a project is organized into modules at the granularity of its *build* steps. A module's build step may
depend on one or more other modules, as specified in its `garden.yml`, in which case those modules will be built
first, and their build output made available to the requiring module's build step.

#### Plugin
Expand All @@ -26,21 +26,21 @@ A [module's](#module) plugin type defines its behavior when it is built, deploye
(such as NPM modules) are under development.

#### Project
The top-level unit of organization in Garden. A project consists of one or more [modules](#module), along with a
The top-level unit of organization in Garden. A project consists of one or more [modules](#module), along with a
project-level [`garden.yml` configuration file](../guides/configuration.md#project-configuration).

Garden CLI commands are run in the context of a project, and are aware of all its modules and services.

Currently, Garden projects assume that all their modules are rooted in subdirectories of the same Git repository, with
the project-level `garden.yml` located in the repository's top-level directory. In a future release, this mono-repo
the project-level `garden.yml` located in the repository's top-level directory. In a future release, this mono-repo
structure will be made optional.

#### Provider
An implementation of a [plugin type](#plugin) (e.g. `local-kubernetes` for the `container` plugin).

#### Service
The unit of deployment in Garden. Services are defined in their parent [module](#module)'s `garden.yml`, each
exposing [one or more endpoints](../guides/configuration.md#services).
The unit of deployment in Garden. Services are defined in their parent [module](#module)'s `garden.yml`, each
exposing [one or more ingress endpoints](../guides/configuration.md#services).

Services may depend on services defined in other modules, in which case those services will be deployed first, and
Services may depend on services defined in other modules, in which case those services will be deployed first, and
their deployment output made available to the requiring service's deploy step.
8 changes: 4 additions & 4 deletions docs/reference/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,17 @@ Examples:

### garden call

Call a service endpoint.
Call a service ingress endpoint.

This command resolves the deployed external endpoint for the given service and path, calls the given endpoint and
This command resolves the deployed ingress endpoint for the given service and path, calls the given endpoint and
outputs the result.

Examples:

garden call my-container
garden call my-container/some-path

Note: Currently only supports simple GET requests for HTTP/HTTPS endpoints.
Note: Currently only supports simple GET requests for HTTP/HTTPS ingresses.

##### Usage

Expand All @@ -72,7 +72,7 @@ Note: Currently only supports simple GET requests for HTTP/HTTPS endpoints.

| Argument | Required | Description |
| -------- | -------- | ----------- |
| `serviceAndPath` | Yes | The name of the service(s) to call followed by the endpoint path (e.g. my-container/somepath).
| `serviceAndPath` | Yes | The name of the service(s) to call followed by the ingress path (e.g. my-container/somepath).

### garden create project

Expand Down
4 changes: 2 additions & 2 deletions docs/reference/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -481,14 +481,14 @@ module:
# Optional.
daemon: false

# List of endpoints that the service exposes.
# List of ingress endpoints that the service exposes.
#
# Example:
# - path: /api
# port: http
#
# Optional.
endpoints:
ingresses:
- # The hostname that should route to this service. Defaults to the default hostname
# configured
# in the provider configuration.
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/template-strings.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ modules:
# Example:
# my-service:
# outputs:
# endpoint: 'http://my-service/path/to/endpoint'
# ingress: 'http://my-service/path/to/endpoint'
# version: v17ad4cb3fd
#
services:
Expand Down
2 changes: 1 addition & 1 deletion examples/hello-world/services/hello-container/garden.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module:
ports:
- name: http
containerPort: 8080
endpoints:
ingresses:
- path: /hello
port: http
healthCheck:
Expand Down
2 changes: 1 addition & 1 deletion examples/local-tls/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ file, but you may also edit it directly (it's at `/etc/hosts` on most platforms)

## Usage

Once you've completed the above, you can run deploy example project and the exposed endpoints will be secured with TLS!
Once you've completed the above, you can run deploy example project and the exposed ingress endpoints will be secured with TLS!

Deploy the project:

Expand Down
2 changes: 1 addition & 1 deletion examples/local-tls/services/go-service/garden.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ module:
ports:
- name: http
containerPort: 80
endpoints:
ingresses:
- path: /
port: http
2 changes: 1 addition & 1 deletion examples/local-tls/services/node-service/garden.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module:
ports:
- name: http
containerPort: 8080
endpoints:
ingresses:
- path: /hello
port: http
- path: /call-go-service
Expand Down
2 changes: 1 addition & 1 deletion examples/multi-container/services/result/garden.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module:
services:
- name: result
command: [nodemon, server.js]
endpoints:
ingresses:
- path: /
port: ui
ports:
Expand Down
2 changes: 1 addition & 1 deletion examples/multi-container/services/vote/garden.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module:
services:
- name: vote
command: [python, app.py]
endpoints:
ingresses:
- path: /vote/
port: interface
ports:
Expand Down
2 changes: 1 addition & 1 deletion examples/simple-project/services/go-service/garden.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ module:
ports:
- name: http
containerPort: 80
endpoints:
ingresses:
- path: /hello-go
port: http
2 changes: 1 addition & 1 deletion examples/simple-project/services/node-service/garden.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module:
ports:
- name: http
containerPort: 8080
endpoints:
ingresses:
- path: /hello-node
port: http
- path: /call-go-service
Expand Down
52 changes: 26 additions & 26 deletions garden-cli/src/commands/call.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ import {
import { splitFirst } from "../util/util"
import { ParameterError, RuntimeError } from "../exceptions"
import { pick, find } from "lodash"
import { ServiceEndpoint, getEndpointUrl } from "../types/service"
import { ServiceIngress, getIngressUrl } from "../types/service"
import dedent = require("dedent")

const callArgs = {
serviceAndPath: new StringParameter({
help: "The name of the service(s) to call followed by the endpoint path (e.g. my-container/somepath).",
help: "The name of the service(s) to call followed by the ingress path (e.g. my-container/somepath).",
required: true,
}),
}
Expand All @@ -33,18 +33,18 @@ type Args = typeof callArgs

export class CallCommand extends Command<Args> {
name = "call"
help = "Call a service endpoint."
help = "Call a service ingress endpoint."

description = dedent`
This command resolves the deployed external endpoint for the given service and path, calls the given endpoint and
This command resolves the deployed ingress endpoint for the given service and path, calls the given endpoint and
outputs the result.
Examples:
garden call my-container
garden call my-container/some-path
Note: Currently only supports simple GET requests for HTTP/HTTPS endpoints.
Note: Currently only supports simple GET requests for HTTP/HTTPS ingresses.
`

arguments = callArgs
Expand All @@ -63,64 +63,64 @@ export class CallCommand extends Command<Args> {
})
}

if (!status.endpoints) {
throw new ParameterError(`Service ${service.name} has no active endpoints`, {
if (!status.ingresses) {
throw new ParameterError(`Service ${service.name} has no active ingresses`, {
serviceName: service.name,
serviceStatus: status,
})
}

// find the correct endpoint to call
let matchedEndpoint: ServiceEndpoint | null = null
let matchedIngress: ServiceIngress | null = null
let matchedPath

// we can't easily support raw TCP or UDP in a command like this
const endpoints = status.endpoints.filter(e => e.protocol === "http" || e.protocol === "https")
const ingresses = status.ingresses.filter(e => e.protocol === "http" || e.protocol === "https")

if (!path) {
// if no path is specified and there's a root endpoint (path === "/") we use that
const rootEndpoint = <ServiceEndpoint>find(endpoints, e => e.path === "/")
const rootIngress = <ServiceIngress>find(ingresses, e => e.path === "/")

if (rootEndpoint) {
matchedEndpoint = rootEndpoint
if (rootIngress) {
matchedIngress = rootIngress
matchedPath = "/"
} else {
// if there's no root endpoint, pick the first endpoint
matchedEndpoint = endpoints[0]
matchedPath = endpoints[0].path
matchedIngress = ingresses[0]
matchedPath = ingresses[0].path
}

path = matchedPath

} else {
path = "/" + path

for (const endpoint of status.endpoints) {
if (endpoint.path) {
if (path.startsWith(endpoint.path) && (!matchedPath || endpoint.path.length > matchedPath.length)) {
matchedEndpoint = endpoint
matchedPath = endpoint.path
for (const ingress of status.ingresses) {
if (ingress.path) {
if (path.startsWith(ingress.path) && (!matchedPath || ingress.path.length > matchedPath.length)) {
matchedIngress = ingress
matchedPath = ingress.path
}
} else if (!matchedPath) {
matchedEndpoint = endpoint
matchedIngress = ingress
}
}
}

if (!matchedEndpoint) {
throw new ParameterError(`Service ${service.name} does not have an HTTP/HTTPS endpoint at ${path}`, {
if (!matchedIngress) {
throw new ParameterError(`Service ${service.name} does not have an HTTP/HTTPS ingress at ${path}`, {
serviceName: service.name,
path,
availableEndpoints: status.endpoints,
availableIngresses: status.ingresses,
})
}

const url = resolve(getEndpointUrl(matchedEndpoint), path || matchedPath)
const url = resolve(getIngressUrl(matchedIngress), path || matchedPath)
// TODO: support POST requests with request body
const method = "get"

const entry = garden.log.info({
msg: chalk.cyan(`Sending ${matchedEndpoint.protocol.toUpperCase()} GET request to `) + url + "\n",
msg: chalk.cyan(`Sending ${matchedIngress.protocol.toUpperCase()} GET request to `) + url + "\n",
status: "active",
})

Expand All @@ -131,7 +131,7 @@ export class CallCommand extends Command<Args> {
method,
url,
headers: {
host: matchedEndpoint.hostname,
host: matchedIngress.hostname,
},
})

Expand Down
2 changes: 1 addition & 1 deletion garden-cli/src/commands/create/config-templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export function containerTemplate(moduleName: string): DeepPartial<ContainerModu
name: "http",
containerPort: 8080,
}],
endpoints: [{
ingresses: [{
path: "/",
port: "http",
}],
Expand Down
4 changes: 2 additions & 2 deletions garden-cli/src/config/config-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ class ModuleContext extends ConfigContext {
}
}

const exampleOutputs = { endpoint: "http://my-service/path/to/endpoint" }
const exampleOutputs = { ingress: "http://my-service/path/to/endpoint" }

class ServiceContext extends ConfigContext {
@schema(
Expand All @@ -217,7 +217,7 @@ class ServiceContext extends ConfigContext {
@schema(Joi.string().description("The current version of the service.").example(exampleVersion))
public version: string

// TODO: add endpoints
// TODO: add ingresses

constructor(root: ConfigContext, service: Service, outputs: PrimitiveMap) {
super(root)
Expand Down
Loading

0 comments on commit dde932f

Please sign in to comment.