Switch branches/tags
Nothing to show
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
..
Failed to load latest commit information.
README.md
cf-jenkins-elb-302.yml
cf-jenkins-main-302.yml
cf-jenkins-monitoring-302.yml
cf-jenkins-vpc-302.yml

README.md

LinkedIn slack Github

File me tickets or star the repo.

Table of Contents

Requirements

1. Finish Scenario-301
2. Get slack notificaiton for autoscaling events.
   Here we assume, one SNS topic has already been created.
   Verify it by terminating existing instance
3. In ELB, enable monitoring
   Verify it by terminating existing instance
4. In Jenkins deployment, create a pipeline

Procedures

Launch

  • Use CF to setup the env

Here we use nested CF, to organize code in small modules.

export STACK_NAME="aws-jenkins"
# The IP address range that can be used to Access Jenkins URL
[ -n "$JENKINS_LOCATION" ] || export JENKINS_LOCATION="0.0.0.0/0"
# Test jenkins username and password
export JENKINS_USER="jenkins123"
export JENKINS_PASSWD="password123"
[ -n "$JENKINS_PORT" ] || export JENKINS_PORT='8081'

# Slack Token for Jenkins jobs. If empty, no slack notifications
[ -n "$SLACK_TOKEN" ] || export SLACK_TOKEN='CUSTOMIZETHIS'
# ssh key name to access EC2 instance
[ -n "$SSH_KEY_NAME" ] || export SSH_KEY_NAME="YOUR_SSH_KEYNAME_CUSTOMIZE"
[ -n "$SNS_TOPIC_ARN" ] || export SNS_TOPIC_ARN="arn:aws:sns:us-east-1:YOUR_SNS_TOPIC"
[ -n "$SIZE_DESIRED" ] || export SIZE_DESIRED="1"
[ -n "$SIZE_MIN" ] || export SIZE_MIN="1"
export TMP_FILE="file://cf-jenkins-main-302.yml"
aws cloudformation create-stack --template-body "$TMP_FILE" \
    --stack-name "$STACK_NAME" --parameters \
    ParameterKey=JenkinsTestUser,ParameterValue=$JENKINS_USER \
    ParameterKey=JenkinsTestPasswd,ParameterValue=$JENKINS_PASSWD \
    ParameterKey=SlackAuthToken,ParameterValue=$SLACK_TOKEN \
    ParameterKey=JenkinsLocation,ParameterValue=$JENKINS_LOCATION \
    ParameterKey=JenkinsPort,ParameterValue=$JENKINS_PORT \
    ParameterKey=KeyName,ParameterValue=$SSH_KEY_NAME \
    ParameterKey=SizeDesired,ParameterValue=$SIZE_DESIRED \
    ParameterKey=SizeMin,ParameterValue=$SIZE_MIN \
    ParameterKey=SNSTopicARN,ParameterValue=$SNS_TOPIC_ARN
aws cloudformation delete-stack --stack-name "$STACK_NAME"

Verifications

  • How to test autoscaling
1. We now only have one Jenkins master instance. Terminate the instance.
2. We shall get one slack notification about the temrination.
3. Very soon, we shall get another slack notification about launching a new EC2 instance
  • How to monitoring
1. Login to instance and shutdown jenkins service
2. We shall slack notification from ELB-5XX metric
3. Start jenkins, it shall return to normal

Highlights

  • Provision Loadbalancer would take minutes
  • TODO: enable ThinBackup for config changes
  • TODO: remove two jenkins warnings
Allowing Jenkins CLI to work in -remoting mode is considered
dangerous and usually unnecessary. You are advised to disable this
mode. Please refer to the CLI documentation for details.

Agent to master security subsystem is currently off. Please read the
documentation and consider turning it on
  • Useful Commands
s3cmd put "cf-jenkins-elb-302.yml" s3://aws.dennyzhang.com/

dns_url=http://aws-jenkins-elb-kcnzdkirty1x-2072597276.us-east-1.elb.amazonaws.com
for((i=0; i< 10; i++)); do { curl -I "$dns_url"; sleep 1 ;}; done
  • Cloudformation Wizard