Calico provides Layer 3 Virtual Networking for Highly Scalable Data Centers
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

calico_compute.sh 5.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. #!/bin/bash
  2. exec > /tmp/calico_compute.log 2>&1
  3. set -x
  4. echo "Hi, I'm a compute node!"
  5. this_node_address=$(python get_node_ip.py `hostname`)
  6. controller_node_address=$(python get_controller_ip.py)
  7. # Get APT key for binaries.projectcalico.org.
  8. curl -L http://binaries.projectcalico.org/repo/key | apt-key add -
  9. # Add source for binaries.projectcalico.org, removing the priority files that
  10. # were automatically created by the fuel plugin installer (the version number
  11. # in the file names causes problems as it contains full stops, and the file
  12. # contents aren't what we want).
  13. rm -f /etc/apt/preferences.d/calico-fuel-plugin-1.0.0 /etc/apt/sources.list.d/calico-fuel-plugin-1.0.0.list
  14. cat > /etc/apt/sources.list.d/calico.list <<EOF
  15. deb http://binaries.projectcalico.org/fuel6.1 ./
  16. EOF
  17. cat << PREFS >> /etc/apt/preferences.d/calico-fuel
  18. Package: *
  19. Pin: origin binaries.projectcalico.org
  20. Pin-Priority: 1100
  21. PREFS
  22. # Add PPA for the etcd packages, and ensure that it has lower priority than
  23. # binaries.projectcalico.org so that we get the fuel versions of the calico
  24. # packages.
  25. apt-add-repository -y ppa:project-calico/juno
  26. cat > /etc/apt/preferences.d/calico-etcd <<EOF
  27. Package: *
  28. Pin: origin ppa:project-calico/juno
  29. Pin-Priority: 1075
  30. EOF
  31. # Pick up package details from new sources.
  32. apt-get update
  33. # Install etcd and configure it for a compute node.
  34. apt-get -y install etcd
  35. service etcd stop
  36. rm -rf /var/lib/etcd/*
  37. awk '/exec \/usr\/bin\/etcd/{while(getline && $0 != ""){}}1' /etc/init/etcd.conf > tmp
  38. mv tmp /etc/init/etcd.conf
  39. cat << EXEC_CMD >> /etc/init/etcd.conf
  40. exec /usr/bin/etcd -proxy on \\
  41. -listen-client-urls http://127.0.0.1:4001 \\
  42. -initial-cluster controller=http://${controller_node_address}:2380
  43. EXEC_CMD
  44. service etcd start
  45. # Run apt-get upgrade and apt-get dist-upgrade. These commands will
  46. # bring in Calico-specific updates to the OpenStack packages and to
  47. # dnsmasq.
  48. apt-get -y upgrade
  49. apt-get -y dist-upgrade
  50. # Open /etc/nova/nova.conf and remove the linuxnet_interface_driver line.
  51. cp /etc/nova/nova.conf /etc/nova/nova.conf.pre-calico
  52. sed -i "/^linuxnet_interface_driver/d" /etc/nova/nova.conf
  53. service nova-compute restart
  54. # Install some extra packages.
  55. apt-get -y install neutron-common neutron-dhcp-agent nova-api-metadata
  56. # Open /etc/neutron/dhcp_agent.ini in your preferred text editor. In
  57. # the [DEFAULT] section, add the following line:
  58. #
  59. # interface_driver = neutron.agent.linux.interface.RoutedInterfaceDriver
  60. cp /etc/neutron/dhcp_agent.ini /etc/neutron/dhcp_agent.ini.pre-calico
  61. sed -i "/^interface_driver/d" /etc/neutron/dhcp_agent.ini
  62. sed -i "/^\[DEFAULT\]/a\
  63. interface_driver = neutron.agent.linux.interface.RoutedInterfaceDriver
  64. " /etc/neutron/dhcp_agent.ini
  65. # Allow BGP connections through the Fuel firewall. We do this before
  66. # installing calico-compute, so that they will be included when the
  67. # calico-compute install script does iptables-save.
  68. iptables -I INPUT 1 -p tcp --dport 179 -j ACCEPT
  69. # Add sources for BIRD and Ubuntu Precise.
  70. gpg --keyserver keyserver.ubuntu.com --recv-keys F9C59A45
  71. gpg -a --export F9C59A45 | apt-key add -
  72. cat > /etc/apt/sources.list.d/bird.list <<EOF
  73. deb http://ppa.launchpad.net/cz.nic-labs/bird/ubuntu trusty main
  74. EOF
  75. cat > /etc/apt/sources.list.d/trusty.list <<EOF
  76. deb http://gb.archive.ubuntu.com/ubuntu/ trusty main
  77. deb http://gb.archive.ubuntu.com/ubuntu/ trusty universe
  78. EOF
  79. apt-get update
  80. # Install BIRD and calico-compute packages.
  81. # Note that this will trigger the installation of iptables-persistent which
  82. # will attempt to bring up a dialog box. We use debconf-set-selections to set
  83. # the value beforehand to avoid this (so not to interrupt the automated
  84. # installation process).
  85. echo iptables-persistent iptables-persistent/autosave_v4 boolean true | debconf-set-selections
  86. echo iptables-persistent iptables-persistent/autosave_v6 boolean true | debconf-set-selections
  87. apt-get -y install calico-compute bird
  88. # Configure BIRD. By default Calico assumes that you'll be deploying
  89. # a route reflector to avoid the need for a full BGP mesh. To this
  90. # end, it includes useful configuration scripts that will prepare a
  91. # BIRD config file with a single peering to the route reflector. If
  92. # that's correct for your network, you can run the following command
  93. # for IPv4 connectivity between compute hosts.
  94. #
  95. # The calico_route_reflector.sh script will set up the required BGP
  96. # Route Reflctor configuration on the controller to allow connections
  97. # from the compute nodes.
  98. #
  99. # If you are configuring a full BGP mesh you'll need to handle the BGP
  100. # configuration appropriately - by editing this script/the Route Reflector
  101. # script. You should consult the relevant documentation for your chosen BGP
  102. # stack.
  103. calico-gen-bird-conf.sh $this_node_address $controller_node_address 64511
  104. # Edit the /etc/calico/felix.cfg file:
  105. # Change the MetadataAddr setting to 127.0.0.1.
  106. # Change the MetadataPort setting to 8775.
  107. cp /etc/calico/felix.cfg.example /etc/calico/felix.cfg
  108. sed -i "/^MetadataAddr/d" /etc/calico/felix.cfg
  109. sed -i "/^\[global\]/a\
  110. MetadataAddr = 127.0.0.1
  111. " /etc/calico/felix.cfg
  112. sed -i "/^MetadataPort/d" /etc/calico/felix.cfg
  113. sed -i "/^\[global\]/a\
  114. MetadataPort = 8775
  115. " /etc/calico/felix.cfg
  116. # Restart the Felix service:
  117. service calico-felix restart
  118. exit 0