Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a resource for GCE routes #993

Merged
merged 8 commits into from Sep 4, 2018
Merged

Conversation

benhamad
Copy link
Contributor

An example of a route is

  resources.gceRoutes.lb-default = {
    name = "lb-default";
    priority = 800;
    destination = "8.8.8.8/32";
    tags = [ "workers" ];
  };

self.copy_credentials(defn)

if check:
if self._check():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't seem like self._check() ever returns True right ?

Fix an issue with real_state_differ check, GCP API adds the region and
the project name to the network so we need to remove those before
checking if the network in the state match.
…tHop

Example:

```
{}:{
  machine =
    { config, pkgs, resources, lib, ... }:
    let
    in
    {
      deployment.targetEnv = "gce";
      ....
    };

  ec2machine = {resources, lib, ...}:
  {
    deployment.targetEnv = "ec2";
    ...

  };
  resources.gceRoutes.lb-default = {resources, ...}:{
    destination = resources.machines.ec2machine;
    priority = 800;
    nextHop = resources.machines.machine ;
    tags = [ "workers" ] ;
  };

}
```

Be aware that nextHop can only be a GCE machine, if not an exception
will be raised
raise Exception("nextHop can only be a GCE machine.")
raise
except libcloud.common.google.ResourceNotFoundError:
raise Exception("The machine {0} isn't deployed, it need to be before it's added as nextHop".format(nextHop_name))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use create_after method instead ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added create_after, but I'm keeping this in case we use --include the flag to only deploy the route. In that case the deployment the above exception will be raised.

};

destination = mkOption {
example ="1.1.1.1/32";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: add space afer =

example ="1.1.1.1/32";
type = types.nullOr (types.either types.str (resource "machine"));
apply = x: if x == null || (builtins.isString x) then x else "res-" + x._name;
description = "The destination IP range that this route applies to. If the destination IP of a packet falls in this range, it matches this route.";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: can you use '' '' for long descriptions instead

description = ''
   foo
''

If nextHop or destination is a machine, wait for them to be deployed
before creating the route.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants