Comment 2 for bug 1529760

Revision history for this message
XuXinkun (xuxinkun) wrote :

OK. In my opinion, service create will follow this way:
1. get bay stack, check whether it is in UPDATE_COMPLETE or CREATE_COMPLETE state. if no, return state error.
2. create namespace service with k8s api.
3. get the response of the creating namespace service. check the ports, whether it has "node_port". if no, return service.
4. get the bay stack template, and then modify the template. I pick part of my template here:
 service_pool_template = """
   %(service_pool)s:
  type: OS::Neutron::Pool
  properties:
    protocol: {get_param: loadbalancing_protocol}
    subnet: {get_resource: fixed_subnet}
    lb_method: ROUND_ROBIN
    vip:
   protocol_port: %(port)s

   %(service_pool_floating)s:
  type: OS::Neutron::FloatingIP
  depends_on:
    - extrouter_inside
  properties:
    floating_network: {get_param: external_network}
    port_id: {get_attr: [%(service_pool)s, vip, port_id]}
 """

 service_pool_memeber_template = """
   %(service_pool_member)s:
  type: OS::Neutron::PoolMember
  properties:
    pool_id: {get_resource: %(service_pool)s}
    address: {get_attr: [kube_minions, kube_minion_ip, %(node_count)s]}
    protocol_port: %(node_port)s
 """

 service_output_template = """
  %(service_address)s:
   value:
     str_replace:
    template: service_ip_address
    params:
      service_ip_address: {get_attr: [%(service_pool_floating)s, floating_ip_address]}
   description: >
     This is the Service endpoint of %(service_pool)s.
 """

 service_pool_template is using to create pool and floating ip for service.
 service_pool_memeber_template is using to create pool member for pool. every node will be a pool member.
 service_output_template is using to output the floating ip as the service ip.
5. update the bay stack with new template.