heat_template_version: 2014-10-16

description: Simple template to deploy kuryr resources

parameters:
  public_net:
    type: string
    label: public net ID
    description: Public network for the node FIPs
  vm_net_cidr:
    type: string
    description: vm_net network address (CIDR notation)
  vm_net_gateway:
    type: string
    description: vm_net network gateway address

resources:
  vm_net:
    type: OS::Neutron::Net
    properties:
      name:
        str_replace:
          template: __stack__/vm_net
          params:
            __stack__: { get_param: 'OS::stack_name' }

  vm_subnet:
    type: OS::Neutron::Subnet
    properties:
      network_id: { get_resource: vm_net }
      cidr: { get_param: vm_net_cidr }
      gateway_ip: { get_param: vm_net_gateway }
      name:
        str_replace:
          template: __stack__/vm_subnet
          params:
            __stack__: { get_param: 'OS::stack_name' }

  kuryr_router:
    type: OS::Neutron::Router
    properties:
      external_gateway_info:
        network: { get_param: public_net }
      name:
        str_replace:
          template: __stack__/router
          params:
            __stack__: { get_param: 'OS::stack_name' }

  kr_vm_iface:
    type: OS::Neutron::RouterInterface
    properties:
      router_id: { get_resource: kuryr_router }
      subnet_id: { get_resource: vm_subnet }

  k8s_api_sg:
    type: OS::Neutron::SecurityGroup
    properties:
      name: K8s_api_sg
      description: Ping and SSH
      rules:
      - protocol: icmp
      - ethertype: IPv4
        remote_mode: remote_group_id
      - ethertype: IPv6
        remote_mode: remote_group_id
      - protocol: tcp
        port_range_min: 22
        port_range_max: 22
      - protocol: tcp
        port_range_min: 8080
        port_range_max: 8080

outputs:
  vm_net_id:
    value: { get_resource: vm_net }
  vm_subnet_id:
    value: { get_resource: vm_subnet }
  k8s_api_sg_id:
    value: { get_resource: k8s_api_sg }
