-
Notifications
You must be signed in to change notification settings - Fork 43
Lab: Deploying EKS Microservices using Jenkins
In this lab we will be doing below steps:
- We will build the docker image and push it to ECR.
- Then Pull the image on Spinnaker and try to do deployments with the help of Spinnaker.
Before starting working on the Lab, Make sure you are sharing your GITHUB Token
and YOUR_TEAM_NAME
with Instructor of the workshop so that they can add your account in Spinnaker from the back-end.
Now Fork the Spinnaker-Study Repository into your Public Github account and then clone it to your local.
Notice the manifests/deploy-microservice.yml file, and see the Deployment, and the Service.
Now we need to make updates on the all the files present under manifests
directory and replace mild-temper
with YOUR-NAME
or YOUR-TEAM-NAME
.
After making the updates you are good to push your code back to your repository.
-
Open Jenkins and login with the
username: spinnaker
andpassword: timeisluxury
-
Click on New Item, and a
Pipeline Job
in Jenkins -
Name your job
<YOUR-TEAM-NAME>-microservice
, and click Ok -
Under
Build Triggers
, selectPoll SCM
, and in the text area enter* * * * *
. -
Under Pipeline, change Definition to
Pipeline Script from SCM
. -
Change SCM to
Git
, and enter your repository URL that you cloned for your team i.e. Spinnaker-Study repository -
Save and Build the Job and see if your docker image is getting push to ECR or not.
-
Open Spinnaker, this is not secure so don’t place any personal information.
-
Once there create an Application with the
name
:<YOUR-TEAM-NAME>-microservice
-
Add
your email
asOwner Email
-
In
Repo Type
, Choosegithub
. -
In
Repo Project
, EnterForked Repo Link
. -
In
Repo Name
, EnterName of your repositoey
. -
In
Cloud Providers
, ChooseKUBERNETES
. -
Create an instance port of 80
-
Click on
Create
to create the Application
Now you should inside the Application that you have created.
-
Click on Pipelines, and click on "Configure a new pipeline"
-
Under Pipeline Name, name it "ToStaging"
We will require two artifacts:
- The Deployment yaml from Github
- The Docker Container from ECR
-
In Configuration under the Expect Artifacts section, click on
Add Artifact
-
In Account field, choose
your github account
-
In File Path, enter
manifests/deploy-microservice.yml
, remember where you saw this entry -
In Display Name, enter 'deploy-microservice.yml'
-
Check Use
Default Artifact
-
Select your determined
github account
-
Enter in your content url and keep in mind this is a different kind of url: https://api.github.com/repos/$ORG/$REPO/contents/$FILEPATH
**For Example: https://api.github.com/repos/mehulsharma2010/spinnaker-study/contents/manifests/deploy-microservice.yml**
- In
Commit/Branch
entermaster
-
In Configuration under the Add Artifacts section, Again click on
Add Artifact
-
In Account, choose
Docker Registry
Account -
In Docker Image, add 702037529261.dkr.ecr.us-west-2.amazonaws.com/ followed by
<YOUR-TEAM-NAME>-microservice
name. This will typically be your project name followed by microservice, ask the instructor to show what is on the ECR, or have them show you. -
In
Display Name
, enter'<YOUR-TEAM-NAME>-microservice'
.
-
In Automated Triggers section, click
Add Trigger
-
In the Type drop-down field, select
Docker Registry
-
In the Registry Name field, select
my-ecr-registry
-
In the Image field, select your image.
-
In the Notifications Section, click Add Notification Preference, this will produce a dialog box
-
In the Notify Via, select
Email
-
In the Email Address, enter
your email address
-
Select
all the boxes
for all notification
Now we can SAVE
the changes.
-
In your pipeline, click on the
Add Stage
button -
In the Type field, select
Deploy (Manifest)
-
This will present some new sections and fields
-
Go to the
Deploy (Manifest)
Configuration and Basic Settings section, in Account selecteks-stage
-
In the Manifest Configuration section, and for the Manifest Source, select
Artifact
-
In the Manifest Artifact select your
deploy-microservice.yaml
file -
In the Required Artifacts to Bind select your
container artifact
binding
-
Click on the pipelines icon.
-
Click on Start Manual Execution
-
Check Results
-
If it doesn’t work, check configurations
If Pipline completes successfully then you can go to the Infrastructure
section and explore what is happening there.
-
Click on Pipelines, and click on "Configure a new pipeline"
-
Under Pipeline Name, name it "ToProd"
-
Declare the two artifacts that you expect from the previous pipeline
a. One would be the
Github
reference to your kubernetes yml fileb. The other would be a reference to your Docker artifact
-
In the new Pipeline Configuration, go to
Automatic Triggers
-
In the Type field select
Pipeline
-
In the Application field select
your Application name
(e.g. mehul-microservice) -
In the Pipeline field select
toStaging
, which was the pipeline that was created -
In the Pipeline Status select
Successful
-
For Artifact Constraints add
deploy-microservice.yml
and<YOUR-TEAM-NAME>-microservice
-
In your pipeline, click on the
Add Stage
button -
In the Type field, select
Deploy (Manifest)
-
This will present some new sections and fields
-
Go to the
Deploy (Manifest)
Configuration and Basic Settings section, in Account selecteks-prod
-
In the Manifest Configuration section, and for the Manifest Source, select
Artifact
-
In the Manifest Artifact select your
deploy-microservice.yml
file -
In the Required Artifacts to Bind select
your container artifact binding
-
Make a change in your repository
-
Commit and Push
-
Ensure that your pipeline works!