Skip to content

smaillns/k8s-microservices

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Udacity Cloud Devleloper

Project : Refactor Udagram App into Microservices and Deploy

Standing up a kubernetes cluster on AWS using kops and Travis-CI as CI/CD Pipeline

Step0: Prepare the application to deploy

You can find the source code and the different Dockerfile in the directory udagram-prject

Step1: Deploy the cluster

that is how the cluster will look like

cluster image

Update and load the required environment variables:

The domain name that is hosted in AWS Route 53

export DOMAIN_NAME="kops.ucci.uk"

Friendly name to use as an alias for our cluster

export CLUSTER_ALIAS="udagramk8s"

Full DNS name of our cluster

export CLUSTER_FULL_NAME="${CLUSTER_ALIAS}.${DOMAIN_NAME}"

AWS availability zone where the cluster will be created

export CLUSTER_AWS_AZ="us-east-1a"

AWS Route 53 hosted zone ID for your domain

export DOMAIN_NAME_ZONE_ID=$(aws route53 list-hosted-zones \
       | jq -r '.HostedZones[] | select(.Name=="'${DOMAIN_NAME}'.") | .Id' \
       | sed 's/\/hostedzone\///') 

Note : you have to configure the aws profile first aws configure, the IAM must the following policies attached to it

    AmazonEC2FullAccess
    AmazonRoute53FullAccess
    AmazonS3FullAccess
    IAMFullAccess
    AmazonVPCFullAccess

We use Kops to stand up the cluster

Create the S3 bucket in AWS, which will be used by Kops for cluster configuration storage:

aws s3api create-bucket --bucket ${CLUSTER_FULL_NAME}-state --region us-west-2 --create-bucket-configuration LocationConstraint=us-west-2

Set the KOPS_STATE_STORE variable to the URL of the S3 bucket that was just created:

export KOPS_STATE_STORE="s3://${CLUSTER_FULL_NAME}-state"

Create the cluster with Kops:

kops create cluster \
     --name=${CLUSTER_FULL_NAME} \
     --zones=${CLUSTER_AWS_AZ} \
     --master-size="t2.medium" \
     --node-size="t2.medium" \
     --node-count="2" \
     --dns-zone=${DOMAIN_NAME} \
     --ssh-public-key="~/.ssh/id_rsa.pub" \
kops update cluster --name udagramk8s.kops.ucci.uk --yes

It will take approximately 5 minutes for the cluster to become availble, next we validate and check the status of the cluster by running the following command :

kops validate cluster

Check more if the cluster is ready :

kubectl get nodes

Step2 : Configure the Travis-CI pipeline

...

Setup the account

...

Setup the environement variables from the Travis-CI console, under project > settings

travis-ci

Note execute cat ~/.kube/config to get the values ...

check the different scripts

../..

Clear All thing

Remove the cluster

kops delete cluster --name=$CLUSTER_FULL_NAME --state=s3://${CLUSTER_FULL_NAME}-state --yes

Destroy the ressources created by terraform

terraform destroy

Note : The aim of this ReadMe file is just to give a general idea about how our kubernetes cluster and CI/CD environment are stood up

Licence

About

Testing TravisCI

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors