Now that we got Spinnaker up and running. Let’s see how we can launch an instance.

The recipe for launching an Instance in the cloud.

  • Your business logic should be in a .deb ( or a debian )
  • Business logic Example : Apache / nginx webserver, application server, a python script.
  • Your debian + BaseAMI = your application.
  • Packer : The tool we will use to achive the above ( Your Debian and BaseAMI = Your AMI).
  • The AMI will be used to launch an instance.

Task # 1 : Install Jenkins

  1. Launch an EC2 Debian instance
  2. Update and install Jenkins
1. sudo apt update
2. sudo apt install openjdk-11-jdk
3. curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo tee /usr/share/keyrings/jenkins-keyring.asc > /dev/null
4. echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] https://pkg.jenkins.io/debian-stable binary/ | sudo tee /etc/apt/sources.list.d/jenkins.list > /dev/null
5. sudo apt update
# If the above fails then run the following
# wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -
# sudo sh -c 'echo deb https://pkg.jenkins.io/debian-stable binary/ > \
#e> /etc/apt/sources.list.d/jenkins.list'
# sudo apt-get update -y

6. sudo apt install jenkins
7. systemctl status jenkins
8. sudo apt install git

# Install deb-s3 which is used to upload files to S3
1. sudo apt install ruby
2. sudo apt install ruby-full
3. sudo gem install pkgr deb-s3

# Login to Jenkins
1. sudo cat /var/lib/jenkins/secrets/initialAdminPassword
2. You should be able to loing using the Admin Password
3. Login URL = http://public_IP:8080

Task # 2 : Build your first Debian using Jenkins

Prerequisite : Create a public S3 bucket for hosting debian . This is for Spinnaker to pick them up when baking an AMI. An Artifactory is a place to store your debians.

Login to your Jenkins instance → Create job → “Freestyle Project” Perform the following,

  • Under “Source Code Management”,
  • Select : “Git”
  • Provide the git URL : https://github.com/nagwww/adobe-deb.git
  • Select the Branch as “Main:
  • Under “Build Steps” select “Execute shell” , type in
./gradlew buildDeb
deb-s3 upload --bucket s3-bucket-for-artifactory --arch all --codename trusty --preserve-versions true build/distributions/*.deb
  • Under “Post Build” select “Archive Artifacts”
build/distributions/*.deb
  • Click on “Build Now” you should see your Debian created.

Task # 3 : Spinnaker to Jenkins Integration

Add the following to Spinnaker for integrating your Jenkins instance

      ci:
jenkins:
enabled: true
masters:
- name: jenkins-master-name
address: http://44.203.77.241:8080/
username: admin
password: **************
csrf: false

Task # 4 : Create the following pipelines to launc an EC2 instance

The main things to note are the following,

Template File Name : aws-ebs.json

repository : http://a-artifactory.s3-website-us-east-1.amazonaws.com trusty main

Here is the working spinnakerservice.yaml

apiVersion: spinnaker.io/v1alpha2
kind: SpinnakerService
metadata:
name: spinnaker
spec:
spinnakerConfig:
service-settings:
rosco:
env:
SPINNAKER_AWS_DEFAULT_REGION: "us-east-1"
SPINNAKER_AWS_DEFAULT_ACCOUNT: "18"
profiles:
gate:
server:
servlet:
context-path: /api/v1
service-settings:
gate:
healthEndpoint: /api/v1/health
config:
security:
apiSecurity:
ssl:
enabled: false
overrideBaseUrl: https://spinnaker.corp.nag.com/api/v1
corsAccessPattern: https://spinnaker.corp.nag.com
uiSecurity:
ssl:
enabled: false
overrideBaseUrl: https://spinnaker.corp.nag.com
version: 1.29.2 # the version of Spinnaker to be deployed
persistentStorage:
persistentStoreType: s3
s3:
bucket: nag1-spinnaker # Change to a unique name. Spinnaker stores application and pipeline definitions here
rootFolder: front50
providers:
aws:
accessKeyId: "AKIA"
secretAccessKey: "lGQDviPv0MKKxO"
defaultAssumeRole: role/DevSpinnakerManagedRole
enabled: true
accounts:
- name: dev1
environment: dev
regions:
- name: us-east-1
accountId : '18'
assumeRole: role/DevSpinnakerManagedRole
primaryAccount: dev1
defaultRegions:
- name: us-east-1
defaults:
iamRole: BaseIAMRole
features:
artifacts: true
repository:
artifactory:
enabled: true
searches:
- name: 18
baseUrl: http://files.s3-website-us-east-1.amazonaws.com/
artifacts:
github:
enabled: true
accounts:
- name: nag
username: nag
token: dPLR2gsLlH
ci:
jenkins:
enabled: true
masters:
- name: jenkins-master-name
address: http://1.2.77.248:8080/
username: nag
password: nag
csrf: false

Documentation

--

--

No responses yet