The following sub-sections describe the steps involved in creating a cartridge base image on the GCE IaaS:

Step 1 - Spawn an instance

  1. Navigate to the Google Developers Console.
  2. Launch an instance with your preferred OS and other related settings as follows:
    1. On the Compute menu, click Compute Engine and then click VM instances.
    2. Click Create instance

      The create a new instance interface appears.
    3. After entering the required instance details, click Save to create the instance.
  3. SSH to the spawned instance and make relevant changes to the base image (e.g., If you need a PHP cartridge, install PHP related libraries).

    1. On the Compute menu, click Compute Engine and then click VM Instances.
    2. Click the more option in the Connect column.
    3. Click Open in browser window.

     

Step 2 - Configure the cartridge base image

Follow the steps given below to configure a base Image:

  1. Start up a virtual machine (VM) instance using a preferred OS, on a preferred IaaS.

  2. Install the Puppet agent.

    If you are using Ubuntu 12, you will require the following Puppet repository to install the Puppet agent.

    wget http://apt.puppetlabs.com/puppetlabs-release-precise.deb
    dpkg -i puppetlabs-release-precise.deb
    sudo apt-get update
    sudo apt-get install puppet


     If you are using Ubuntu 14, you will require the following Puppet repository to install the Puppet agent.

    wget http://apt.puppetlabs.com/puppetlabs-release-trusty.deb
    dpkg -i puppetlabs-release-trusty.deb
    sudo apt-get update
    sudo apt-get install puppet


    1. Enable dependencies and Puppet labs repository on Master.

      # rpm -ivh http://yum.puppetlabs.com/puppetlabs-release-el-7.noarch.rpm
      # rpm -ivh http://yum.puppetlabs.com/puppetlabs-release-el-6.noarch.rpm
      # rpm -ivh http://yum.puppetlabs.com/puppetlabs-release-el-5.noarch.rpm
    2. Install and upgrade Puppet on the agent node.

      # yum install puppet
      # puppet resource package puppet ensure=latest
      # /etc/init.d/puppet restart

    For more information on installing the Puppet agent on CentOS, see installing Puppet on CentOS.

  3. Open the puppet file, which is in the <PUPPET_AGENT>/etc/default directory and configure it as follows:

    START=yes
  4. Add the following to the puppet.conf file, which is in the <PUPPET_AGENT> /etc/puppet directory:

    [main]
    server=puppet.stratos.org

    If you are unsure of the server name, use a dummy hostname. Stratos will update the above with the respective server name, when it starts running.

  5. Stop the puppet instance or instances that are running.

    cd /etc/init.d/puppet
    stop
    • When the Puppet agent is installed as mentioned in step 1, there is a high tendency that a puppet instance will start running. Therefore before creating the base image you need to stop any puppet instances that are running.
    • Execute the following command to identify the running puppet instances:

      ps -ef | grep puppet

      The following output will be given, if any Puppet instances are running.

      Example:

      root      1321     1  0 Sep09 ?        00:00:17 /usr/bin/ruby /usr/bin/puppet agent
      root     12149 12138  0 05:44 pts/0    00:00:00 grep --color=auto puppet
  6. Copy the init.sh script into the <PUPPET_AGENT>/root/bin directory.

    You can find the init.sh script for the respective IaaS here.

    The init.sh file differs based on the IaaS. If you wish to find the init.sh script for a different IaaS, go to init-scripts. You can find the respective init.sh script by navigating to the init-script/<IAAS>/<OS> path.

  7. Update the /etc/rc.local file.

    /root/bin/init.sh > /tmp/puppet_log
    exit 0
  8. Execute the following commands:

    rm -rf /var/lib/puppet/ssl/*
    rm -rf /tmp/*

    By executing the above commands you will be cleaning up the base image, for Stratos to install the required certificates and payloads. This is done to avoid any errors that will be given, if Stratos starts installing a certificate or payload that already exists in the base image.

Step 3 - Create a snapshot of the instance

  1. Set the auto-delete state of the root persistent disk to  false as follows:
    This is done to avoid the persistent disk from being automatically deleted when you terminate the instance.

    1. On the Compute menu, click Compute Engine and then click VM Instances.
    2. Click on the name of the instance.

    3. Edit the settings related to the instance. 

    4. Uncheck the Delete boot disk when instance is deleted option. This is done to ensure that  all the data is not deleted  when you terminate the instance.

    5. Click Save.
      If you wish to view details on the disk related to the instance, click Compute Engine and then click Disks.  

  2. Delete the instance.
    Initially, you need to terminate the spawned instance using the root persistent disk to be able to create an image. When you are terminating the instance make sure that the persistent disk is not attached to any other virtual machines.

    1. On the Compute menu, click Compute Engine and then click VM Instances.
    2. Check the instance that you need to delete.
    3. Click Delete to delete the instance.
  3. Create a new image as follows:

    1. On the Compute menu, click Compute Engine and then click Images.
    2. Click Create Image.
    3. Provide the Source type as Disk and select the relevant disk name from the dropdown menu. You need to do this to create the image based on the persistent disk.
    4. Click Create

      The newly created image is immediately available under the Images section.
       
  • No labels