Select Page

Sagayaraj D

|
originally published on Feb 19, 2020
Share

By default, Spinnaker does not have CentOS baking option. In this technical blog, we will be demonstrating how to bake a CentOS image and deploy an instance using the baked image on AWS cloud.

Scope

This procedure is performed under the following environment,
– Spinnaker 17.4.0 (However the same can work on new versions of Spinnaker)
– Cloud provider is AWS

Pre-Requirements

To enable CentOS image baking option in Spinnaker, we assume that following requirements and configurations are already met:

– You have a valid Access and Secret keys to connect with your AWS account
– In Spinnaker, an AWS Account is added & enabled for EC2 deployment
– A Spinnaker application is created with AWS cloud-provider enabled

If you have a Managed Account created, then following commands can enable AWS account on your Spinnaker

Note:  Throughout this document, you will find references to AWS Accesskey and Secretkey. You must replace them with your Accesskey and Secretkey. You will also find an S3 bucket name and it should be replaced with your storage bucket value.

How to do?

Procedure Outline

1. Setup AWS Cloud provider account
– Enable AWS CloudProvider account

2. Publish RPMs
– Build Code and generate deploy-able RPM package
– Setup Yum repository on a Build machine
– Setup Yum repository on S3 bucket

3. Configure Bake Stage & Deploy Stage

4. Pipeline execution and verification

Detailed Procedure

1. Setup AWS Cloud provider account
Please refer to the blog ‘Setting up AWS as a cloud provider account‘ to configure your AWS cloud provider account.

2. Publish RPMs
Build Code and generate deploy-able RPM package:

You can generate your app’s RPM package by any of your methods like a step in Gradle/Maven build or by a Shell post-build script process.

3. Setup Yum repository on a Build machine
a. Yum repo is a directory structure with some special files like repomd.xml.

NOTE: Technically every time there is rpm file update on the target Yum repository, we need to update the repomd.xml and other metadata files within the repo.  Therefore, we use a program called createrepo on the Build, machine to update the said files and then sync the repo content with remote S3 bucket repo which is the actual Yum repo source for package deployments.

The directory structure looks like the below

Assuming that our YUM repo ($YUMREPO_PATH) resides here – /repos/OpsMx-yum, create the mandatory directories with the command

b. Copy the rpm files from your application directory to the ${YUM_REPO}/Packages`

c. Create the rpm metadata files so that the repo becomes yum-repostiroy.

For every subsequent rpm files update, you can update the repo as

4. Setup Yum repository on S3 bucket

  • Create an S3 bucket in your AWS account
  • Make the bucket publically accessible
  • On the Build machine, run the below command to sync the repo content to S3 bucket

Note: The procedure in step 3 and 4 are given in the script snippet below

5. Configure Bake Stage & Deploy Stage

a. Create/update the file ~/.hal/default/profiles/rosco-local.yml with the content below. This is the S3 bucket where we published our RPMs, you would need to replace it with your bucket.

b. Create/update the file ~/.hal/default/profiles/rosco.yml with the content below. NOTE: You would have the update and trim the images list. Also, modify the AWS_ACCESS_KEY and AWS_SECRET_KEY values to your spec.

Note: To know the list of images, you can run one of the commands below

Then, you can run hal deploy apply for the changes to take effect.

c. Now go to your application > pipeline and configure the Bake stage similar to the below

Here, you should be able to change the ‘Base OS’ to CentOS. Optionally, if you want to override Yum repository to be a different one than what is configured in the rosco-local.yml file, then you can set ‘Extended Attribute with a Key name to repository and it’s Value to your yum-repo’

6. Execute the pipeline and verify that your pipeline is run as expected.

0 Comments

Submit a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.