Skip to content

Commit

Permalink
feat(deployment): adds vpn client toggle in manifest
Browse files Browse the repository at this point in the history
This commit adds support for enabling vpn client in a deployment via the
deployment manifest. Here's an example on how to enable VPN

apiVersion: "apiextensions.rapyuta.io/v1"
kind: Deployment
metadata:
  name: "dep-nginx"
  depends:
    kind: package
    nameOrGUID: "nginx"
    version: "1.0.0"
spec:
  runtime: cloud
  features:
    vpn:
      enabled: true
  • Loading branch information
pallabpain committed May 9, 2023
1 parent d1290aa commit a6223cc
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
27 changes: 19 additions & 8 deletions riocli/deployment/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ def create_object(self, client: Client) -> typing.Any:
runtime = internal_component['runtime']

if 'runtime' in self.spec and runtime != self.spec.runtime:
click.secho('>> runtime mismatch => ' +
'deployment:{}.runtime !== package:{}.runtime '.format(
self.metadata.name, pkg['packageName']
), fg='red'
)
click.secho(
'>> runtime mismatch => ' +
'deployment:{}.runtime !== package:{}.runtime '.format(
self.metadata.name, pkg['packageName']
), fg='red')
return

provision_config = pkg.get_provision_configuration(__planId)
Expand Down Expand Up @@ -142,15 +142,26 @@ def create_object(self, client: Client) -> typing.Any:
})
provision_config.context['managedServices'] = managed_services

# inject the vpn managedservice instance if the flag is set to
# true. 'rio-internal-headscale' is the default vpn instance
if 'features' in self.spec:
if 'vpn' in self.spec.features and self.spec.features.vpn.enabled:
provision_config.context['managedServices'] = [{
"instance": "rio-internal-headscale"
}]

if self.spec.runtime == 'device':
device_guid, device = self.rc.find_depends(self.spec.device.depends)
device_guid, device = self.rc.find_depends(
self.spec.device.depends)
if device is None and device_guid:
device = client.get_device(device_guid)
provision_config.add_device(__componentName, device=device, set_component_alias=False)
provision_config.add_device(__componentName, device=device,
set_component_alias=False)

if 'restart' in self.spec:
provision_config.add_restart_policy(
__componentName, self.RESTART_POLICY[self.spec.restart.lower()])
__componentName,
self.RESTART_POLICY[self.spec.restart.lower()])

# Add Network
# if self.spec.rosNetworks:
Expand Down
11 changes: 11 additions & 0 deletions riocli/jsonschema/schemas/deployment-schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,17 @@ definitions:
enum:
- cloud

features:
type: object
properties:
vpn:
type: object
properties:
enabled:
type: boolean
required:
- enabled

envArgs:
type: array
items:
Expand Down

0 comments on commit a6223cc

Please sign in to comment.