Skip to content

Commit 1efe2fb

Browse files
committedSep 17, 2020
Initial Commit
0 parents  commit 1efe2fb

21 files changed

+776
-0
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
[
2+
{
3+
"ParameterKey": "EnvironmentName",
4+
"ParameterValue": "UdacityCapstoneProject"
5+
},
6+
{
7+
"ParameterKey": "KeyPairName",
8+
"ParameterValue": "custom-key-pair"
9+
},
10+
{
11+
"ParameterKey": "DesiredInstances",
12+
"ParameterValue": "3"
13+
},
14+
{
15+
"ParameterKey": "ImageID",
16+
"ParameterValue": "ami-0d1cd67c26f5fca19"
17+
},
18+
{
19+
"ParameterKey": "MinSize",
20+
"ParameterValue": "1"
21+
},
22+
{
23+
"ParameterKey": "MaxSize",
24+
"ParameterValue": "4"
25+
}
26+
]
+165
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
Description: >
2+
Arnab / Udacity Cloud DevOps
3+
Capstone project for Cloud DevOps Nanodegree Program
4+
5+
Parameters:
6+
EnvironmentName:
7+
Description: An Environment name that will be prefixed to resources
8+
Type: String
9+
10+
ImageID:
11+
Description: An image ID for EC2 Instance
12+
Type: String
13+
14+
KeyPairName:
15+
Description: The EC2 Key Pair to allow SSH access to the instances
16+
Type: AWS::EC2::KeyPair::KeyName
17+
18+
DesiredInstances:
19+
Description: How many instances should be created.
20+
Type: Number
21+
22+
MinSize:
23+
Description: Minimum number of web application servers
24+
Type: String
25+
26+
MaxSize:
27+
Description: Maximum number of web application servers
28+
Type: String
29+
30+
Resources:
31+
InstanceProfile:
32+
Type: AWS::IAM::InstanceProfile
33+
Properties:
34+
Path: "/"
35+
Roles:
36+
- !Ref InstanceRole
37+
38+
InstanceRole:
39+
Type: AWS::IAM::Role
40+
Properties:
41+
AssumeRolePolicyDocument:
42+
Version: "2012-10-17"
43+
Statement:
44+
- Effect: Allow
45+
Principal:
46+
Service:
47+
- ec2.amazonaws.com
48+
Action:
49+
- sts:AssumeRole
50+
Path: "/"
51+
ManagedPolicyArns:
52+
- arn:aws:iam::aws:policy/AmazonEKSWorkerNodePolicy
53+
- arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy
54+
- arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly
55+
56+
NodesSecurityGroup:
57+
Type: AWS::EC2::SecurityGroup
58+
Properties:
59+
GroupDescription: Security group for the nodes.
60+
VpcId:
61+
Fn::ImportValue: !Sub "${EnvironmentName}-VPCID"
62+
SecurityGroupIngress:
63+
- IpProtocol: tcp
64+
FromPort: 0
65+
ToPort: 65535
66+
CidrIp: 0.0.0.0/0
67+
- IpProtocol: tcp
68+
FromPort: 1025
69+
ToPort: 65535
70+
CidrIp: 0.0.0.0/0
71+
- IpProtocol: tcp
72+
FromPort: 443
73+
ToPort: 443
74+
CidrIp: 0.0.0.0/0
75+
SecurityGroupEgress:
76+
- IpProtocol: tcp
77+
FromPort: 0
78+
ToPort: 65535
79+
CidrIp: 0.0.0.0/0
80+
- IpProtocol: tcp
81+
FromPort: 1025
82+
ToPort: 65535
83+
CidrIp: 0.0.0.0/0
84+
- IpProtocol: tcp
85+
FromPort: 443
86+
ToPort: 443
87+
CidrIp: 0.0.0.0/0
88+
Tags:
89+
- Key: !Sub
90+
- "kubernetes.io/cluster/${EksId}"
91+
- EksId:
92+
Fn::ImportValue: !Sub "${EnvironmentName}-EKS"
93+
Value: "owned"
94+
95+
NodesAutoScalingGroup:
96+
Type: AWS::AutoScaling::AutoScalingGroup
97+
Properties:
98+
DesiredCapacity: !Sub ${DesiredInstances}
99+
LaunchConfigurationName: !Ref LaunchConfiguration
100+
MinSize: !Ref MinSize
101+
MaxSize: !Ref MaxSize
102+
VPCZoneIdentifier:
103+
Fn::Split:
104+
- ","
105+
- Fn::ImportValue:
106+
Fn::Sub: ${EnvironmentName}-PUB-NETS
107+
Tags:
108+
- Key: Name
109+
Value: !Sub
110+
- "${EksId}-CapstoneNodesGroup-Node"
111+
- EksId:
112+
Fn::ImportValue: !Sub "${EnvironmentName}-EKS"
113+
PropagateAtLaunch: "true"
114+
- Key: !Sub
115+
- "kubernetes.io/cluster/${EksId}"
116+
- EksId:
117+
Fn::ImportValue: !Sub "${EnvironmentName}-EKS"
118+
Value: "owned"
119+
PropagateAtLaunch: "true"
120+
UpdatePolicy:
121+
AutoScalingRollingUpdate:
122+
MaxBatchSize: "1"
123+
MinInstancesInService: 3
124+
PauseTime: "PT5M"
125+
126+
LaunchConfiguration:
127+
Type: AWS::AutoScaling::LaunchConfiguration
128+
Properties:
129+
AssociatePublicIpAddress: "true"
130+
IamInstanceProfile: !Ref InstanceProfile
131+
ImageId: !Ref ImageID
132+
InstanceType: t2.medium
133+
KeyName: !Ref KeyPairName
134+
SecurityGroups:
135+
- !Ref NodesSecurityGroup
136+
BlockDeviceMappings:
137+
- DeviceName: /dev/xvda
138+
Ebs:
139+
VolumeSize: 10
140+
VolumeType: gp2
141+
DeleteOnTermination: true
142+
UserData:
143+
Fn::Base64: !Sub
144+
- |
145+
#!/bin/bash
146+
set -o xtrace
147+
/etc/eks/bootstrap.sh ${EksId}
148+
/opt/aws/bin/cfn-signal --exit-code $? \
149+
--stack ${AWS::StackName} \
150+
--resource NodesAutoScalingGroup \
151+
--region ${AWS::Region}
152+
- EksId:
153+
Fn::ImportValue: !Sub "${EnvironmentName}-EKS"
154+
155+
Outputs:
156+
InstanceRole:
157+
Description: The node instance role
158+
Value: !GetAtt InstanceRole.Arn
159+
Export:
160+
Name: !Sub ${EnvironmentName}-IR
161+
NodesSecurityGroup:
162+
Description: The security group for the nodes.
163+
Value: !Ref NodesSecurityGroup
164+
Export:
165+
Name: !Sub ${EnvironmentName}-NSG

‎CloudFormation/aws-auth-cm.yaml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: aws-auth
5+
namespace: kube-system
6+
data:
7+
mapRoles: |
8+
- rolearn: arn:aws:iam::988212813982:role/nodegroup-InstanceRole-1NRDD0R220DDT
9+
username: system:node:{{EC2PrivateDNSName}}
10+
groups:
11+
- system:bootstrappers
12+
- system:nodes
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[
2+
{
3+
"ParameterKey": "EnvironmentName",
4+
"ParameterValue": "UdacityCapstoneProject"
5+
}
6+
]

‎CloudFormation/eks-cluster.yml

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
Description: >
2+
Arnab / Udacity Cloud DevOps
3+
Capstone project for Cloud DevOps Nanodegree Program
4+
5+
Parameters:
6+
EnvironmentName:
7+
Description: An Environment name that will be prefixed to resources
8+
Type: String
9+
10+
Resources:
11+
ClusterInstanceProfile:
12+
Type: AWS::IAM::InstanceProfile
13+
Properties:
14+
Path: "/"
15+
Roles:
16+
- !Ref ClusterRole
17+
18+
ClusterRole:
19+
Type: AWS::IAM::Role
20+
Properties:
21+
AssumeRolePolicyDocument:
22+
Version: "2012-10-17"
23+
Statement:
24+
- Effect: Allow
25+
Principal:
26+
Service:
27+
- eks.amazonaws.com
28+
Action:
29+
- sts:AssumeRole
30+
Path: "/"
31+
ManagedPolicyArns:
32+
- arn:aws:iam::aws:policy/AmazonEKSClusterPolicy
33+
- arn:aws:iam::aws:policy/AmazonEKSServicePolicy
34+
- arn:aws:iam::aws:policy/ElasticLoadBalancingFullAccess
35+
36+
CapstoneEKS:
37+
Type: AWS::EKS::Cluster
38+
Properties:
39+
Version: "1.13"
40+
RoleArn: !GetAtt ClusterRole.Arn
41+
ResourcesVpcConfig:
42+
SecurityGroupIds:
43+
- Fn::ImportValue: !Sub "${EnvironmentName}-SCG"
44+
SubnetIds:
45+
Fn::Split:
46+
- ","
47+
- Fn::ImportValue:
48+
Fn::Sub: ${EnvironmentName}-PUB-NETS
49+
Outputs:
50+
EksId:
51+
Description: The EKS id.
52+
Value: !Ref CapstoneEKS
53+
Export:
54+
Name: !Sub ${EnvironmentName}-EKS
55+
56+
EKSRoleArn:
57+
Description: The role that Amazon EKS will use to create AWS resources for Kubernetes clusters
58+
Value: !GetAtt ClusterRole.Arn
59+
Export:
60+
Name: !Sub "${EnvironmentName}-EKSRoleArn"

‎CloudFormation/network-params.json

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
[
2+
{
3+
"ParameterKey": "EnvironmentName",
4+
"ParameterValue": "UdacityCapstoneProject"
5+
},
6+
{
7+
"ParameterKey": "VpcCIDR",
8+
"ParameterValue": "192.168.0.0/16"
9+
},
10+
{
11+
"ParameterKey": "PublicSubnet1CIDR",
12+
"ParameterValue": "192.168.64.0/18"
13+
},
14+
{
15+
"ParameterKey": "PublicSubnet2CIDR",
16+
"ParameterValue": "192.168.128.0/18"
17+
},
18+
{
19+
"ParameterKey": "PublicSubnet3CIDR",
20+
"ParameterValue": "192.168.192.0/18"
21+
}
22+
]

‎CloudFormation/network.yml

+185
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
Description: >
2+
Arnab / Udacity Cloud DevOps
3+
Capstone project for Cloud DevOps Nanodegree Program
4+
5+
Parameters:
6+
EnvironmentName:
7+
Description: An environment name that will be prefixed to resource names
8+
Type: String
9+
10+
VpcCIDR:
11+
Description: Please enter the IP range (CIDR notation) for this VPC
12+
Type: String
13+
Default: 192.168.0.0/16
14+
15+
PublicSubnet1CIDR:
16+
Description: Please enter the IP range (CIDR notation) for the public subnet in the first Availability Zone
17+
Type: String
18+
Default: 192.168.0.0/16
19+
20+
PublicSubnet2CIDR:
21+
Description: Please enter the IP range (CIDR notation) for the public subnet in the second Availability Zone
22+
Type: String
23+
Default: 192.168.128.0/18
24+
25+
PublicSubnet3CIDR:
26+
Description: Please enter the IP range (CIDR notation) for the public subnet in the second Availability Zone
27+
Type: String
28+
Default: 192.168.192.0/18
29+
30+
Resources:
31+
VPC:
32+
Type: AWS::EC2::VPC
33+
Properties:
34+
CidrBlock: !Ref VpcCIDR
35+
EnableDnsHostnames: true
36+
Tags:
37+
- Key: Name
38+
Value: !Ref EnvironmentName
39+
40+
InternetGateway:
41+
Type: AWS::EC2::InternetGateway
42+
Properties:
43+
Tags:
44+
- Key: Name
45+
Value: !Ref EnvironmentName
46+
47+
InternetGatewayAttachment:
48+
Type: AWS::EC2::VPCGatewayAttachment
49+
Properties:
50+
InternetGatewayId: !Ref InternetGateway
51+
VpcId: !Ref VPC
52+
53+
PublicSubnet1:
54+
Type: AWS::EC2::Subnet
55+
Properties:
56+
MapPublicIpOnLaunch: true
57+
VpcId: !Ref VPC
58+
AvailabilityZone: !Select [0, !GetAZs ""]
59+
CidrBlock: !Ref PublicSubnet1CIDR
60+
MapPublicIpOnLaunch: true
61+
Tags:
62+
- Key: Name
63+
Value: !Sub ${EnvironmentName} Public Subnet (AZ1)
64+
65+
PublicSubnet2:
66+
Type: AWS::EC2::Subnet
67+
Properties:
68+
MapPublicIpOnLaunch: true
69+
VpcId: !Ref VPC
70+
AvailabilityZone: !Select [1, !GetAZs ""]
71+
CidrBlock: !Ref PublicSubnet2CIDR
72+
MapPublicIpOnLaunch: true
73+
Tags:
74+
- Key: Name
75+
Value: !Sub ${EnvironmentName} Public Subnet (AZ2)
76+
77+
PublicSubnet3:
78+
Type: AWS::EC2::Subnet
79+
Properties:
80+
MapPublicIpOnLaunch: true
81+
VpcId: !Ref VPC
82+
AvailabilityZone: !Select [2, !GetAZs ""]
83+
CidrBlock: !Ref PublicSubnet3CIDR
84+
MapPublicIpOnLaunch: true
85+
Tags:
86+
- Key: Name
87+
Value: !Sub ${EnvironmentName} Public Subnet (AZ3)
88+
89+
PublicRouteTable:
90+
Type: AWS::EC2::RouteTable
91+
Properties:
92+
VpcId: !Ref VPC
93+
Tags:
94+
- Key: Name
95+
Value: !Sub ${EnvironmentName} Public Routes
96+
97+
DefaultPublicRoute:
98+
Type: AWS::EC2::Route
99+
DependsOn: InternetGatewayAttachment
100+
Properties:
101+
RouteTableId: !Ref PublicRouteTable
102+
DestinationCidrBlock: 0.0.0.0/0
103+
GatewayId: !Ref InternetGateway
104+
105+
PublicSubnet1RouteTableAssociation:
106+
Type: AWS::EC2::SubnetRouteTableAssociation
107+
Properties:
108+
RouteTableId: !Ref PublicRouteTable
109+
SubnetId: !Ref PublicSubnet1
110+
111+
PublicSubnet2RouteTableAssociation:
112+
Type: AWS::EC2::SubnetRouteTableAssociation
113+
Properties:
114+
RouteTableId: !Ref PublicRouteTable
115+
SubnetId: !Ref PublicSubnet2
116+
117+
PublicSubnet3RouteTableAssociation:
118+
Type: AWS::EC2::SubnetRouteTableAssociation
119+
Properties:
120+
RouteTableId: !Ref PublicRouteTable
121+
SubnetId: !Ref PublicSubnet3
122+
123+
DefaultSecurityGroup:
124+
Type: AWS::EC2::SecurityGroup
125+
Properties:
126+
VpcId: !Ref VPC
127+
GroupDescription: Default security group for EKS.
128+
SecurityGroupIngress:
129+
- IpProtocol: tcp
130+
FromPort: 1025
131+
ToPort: 65535
132+
CidrIp: 0.0.0.0/0
133+
- IpProtocol: tcp
134+
FromPort: 443
135+
ToPort: 443
136+
CidrIp: 0.0.0.0/0
137+
SecurityGroupEgress:
138+
- IpProtocol: tcp
139+
FromPort: 1025
140+
ToPort: 65535
141+
CidrIp: 0.0.0.0/0
142+
143+
Outputs:
144+
VPC:
145+
Description: A reference to the created VPC
146+
Value: !Ref VPC
147+
Export:
148+
Name: !Sub ${EnvironmentName}-VPCID
149+
150+
VPCPublicRouteTable:
151+
Description: Public Routing
152+
Value: !Ref PublicRouteTable
153+
Export:
154+
Name: !Sub ${EnvironmentName}-PUB-RT
155+
156+
PublicSubnets:
157+
Description: A list of the public subnets
158+
Value:
159+
!Join [",", [!Ref PublicSubnet1, !Ref PublicSubnet2, !Ref PublicSubnet3]]
160+
Export:
161+
Name: !Sub ${EnvironmentName}-PUB-NETS
162+
163+
SecurityGroup:
164+
Description: Cluster security group.
165+
Value: !Ref DefaultSecurityGroup
166+
Export:
167+
Name: !Sub ${EnvironmentName}-SCG
168+
169+
PublicSubnet1:
170+
Description: A reference to the public subnet in the 1st Availability Zone
171+
Value: !Ref PublicSubnet1
172+
Export:
173+
Name: !Sub ${EnvironmentName}-PUB1-SN
174+
175+
PublicSubnet2:
176+
Description: A reference to the public subnet in the 2nd Availability Zone
177+
Value: !Ref PublicSubnet2
178+
Export:
179+
Name: !Sub ${EnvironmentName}-PUB2-SN
180+
181+
PublicSubnet3:
182+
Description: A reference to the public subnet in the 2nd Availability Zone
183+
Value: !Ref PublicSubnet2
184+
Export:
185+
Name: !Sub ${EnvironmentName}-PUB3-SN

‎Dockerfile

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FROM nginx:latest
2+
3+
# Copy source code to working directory
4+
COPY index.html /usr/share/nginx/html
5+
6+
# Expose port 80
7+
EXPOSE 80

‎Jenkinsfile

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
pipeline {
2+
agent any
3+
stages {
4+
stage('Build') {
5+
steps {
6+
sh 'echo Building...'
7+
}
8+
}
9+
stage('Lint HTML') {
10+
steps {
11+
sh 'tidy -q -e *.html'
12+
}
13+
}
14+
stage('Build Docker Image') {
15+
steps {
16+
sh 'docker build -t udacity-cloud-devops-capstone .'
17+
}
18+
}
19+
stage('Push Docker Image') {
20+
steps {
21+
withDockerRegistry([url: "", credentialsId: "docker-hub"]) {
22+
sh "docker tag udacity-cloud-devops-capstone mydocker49/udacity-cloud-devops-capstone"
23+
sh 'docker push mydocker49/udacity-cloud-devops-capstone'
24+
}
25+
}
26+
}
27+
stage('Deploying') {
28+
steps{
29+
echo 'Deploying to AWS...'
30+
withAWS(credentials: 'aws', region: 'ap-south-1') {
31+
sh "aws eks --region ap-south-1 update-kubeconfig --name jenkinscapstone"
32+
sh "kubectl config use-context arn:aws:eks:ap-south-1:527375347403:cluster/jenkinscapstone"
33+
sh "kubectl set image deployments/udacity-cloud-devops-capstone udacity-cloud-devops-capstone=mydocker49/udacity-cloud-devops-capstone:latest"
34+
sh "kubectl apply -f deployment/deployment.yml"
35+
sh "kubectl get nodes"
36+
sh "kubectl get deployment"
37+
sh "kubectl get pod -o wide"
38+
sh "kubectl get service/udacity-cloud-devops-capstone"
39+
}
40+
}
41+
}
42+
stage("Cleaning up") {
43+
steps{
44+
echo 'Cleaning up...'
45+
sh "docker system prune"
46+
}
47+
}
48+
}
49+
}

‎Makefile

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
## The Makefile includes instructions on running the commands
2+
# create stack
3+
# update stack
4+
# delete stack
5+
# Dockerfile should pass hadolint
6+
# index.html should pass lint
7+
# (Optional) Build a simple integration test
8+
9+
docker-build: docker build --tag=udacity-capstone-app .
10+
11+
# docker-upload:
12+
13+
# run-kube:
14+
15+
lint:
16+
# See local hadolint install instructions: https://github.com/hadolint/hadolint
17+
# This is linter for Dockerfiles
18+
hadolint Dockerfile
19+
# This is a linter for Python source code linter: https://www.pylint.org/
20+
# This should be run from inside a virtualenv
21+
# pylint --disable=R,C,W1203 app.py
22+
23+
all: install lint test

‎README.md

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# udacity-cloud-devops-capstone
2+
3+
<h2>Project Overview</h2>
4+
5+
<p> In this project, I applied the skills and knowledge which was developed throughout the Cloud DevOps Nanodegree program. These include:</p>
6+
7+
<ul>
8+
<li>Working in AWS</li>
9+
<li>Using Jenkins to implement Continuous Integration and Continuous Deployment</li>
10+
<li>Building pipelines</li>
11+
<li>Working with Ansible and CloudFormation to deploy clusters</li>
12+
<li>Building Kubernetes clusters</li>
13+
<li>Building Docker containers in pipelines</li>
14+
</ul>
15+
16+
***
17+
18+
<p>I developed a CI/CD pipeline for microservices applications with rolling deployment. I developed Continuous Integration steps, such as typographical checking (aka “linting”). I also developed Contiguous Deployment steps. These includes:</p>
19+
20+
<ul>
21+
<li>Pushing the built Docker containers to the Docker repository</li>
22+
<li>Deploying these Docker containers to a small Kubernetes cluster. For Kubernetes cluster I used AWS EKS. To deploy my Kubernetes cluster using Cloudformation. I ran these from Jenkins as an independent pipeline.</li>
23+
</ul>
24+
25+
***
26+
27+
<h2>Environment Setup</h2>
28+
29+
<ul>
30+
<li>Create a <code>Makefile</code></li>
31+
<li>Create a <code>Dockerfile</code></li>
32+
<li>Create a <code>Jenkinsfile</code> including all the necessary steps</li>
33+
<li>Create CloudFormation Script using <code>create-stack.sh</code> command</li>
34+
<li>Install Jenkins and all the necessary plugins in the EC2 Instance</li>
35+
</ul>
36+
37+
<h2>Linting App</h2>
38+
39+
<ul>
40+
<li>Run <code>make lint</code> to lint the app locally</li>
41+
</ul>
42+
43+
<h2>Running App</h2>
44+
45+
<ul>
46+
<li>Run Docker: <code>./run_docker.sh</code></li>
47+
<li>Run Kubernetes: <code>./run_kubernetes.sh</code></li>
48+
</ul>
49+
50+
<h2>Uploading to the Docker Hub</h2>
51+
52+
<ul>
53+
<li>Run <code>./upload_docker.sh</code> to upload the api to the Docker Hub</li>
54+
</ul>
55+
56+
<h2>Deploying App to AWS</h2>
57+
58+
<pre>
59+
<code>
60+
aws eks --region ap-south-1 update-kubeconfig --name EKS-Name
61+
kubectl apply -f aws/aws-auth-cm.yaml
62+
kubectl apply -f deployment/deployment.yml
63+
kubectl get nodes
64+
kubectl get pods -o wide
65+
</code>
66+
</pre>
67+
68+
<h2>Cleaning App</h2>
69+
70+
<ul>
71+
<li>Run <code>docker system prune</code> to clean up </li>
72+
</ul>

‎deployment/deployment.yml

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: udacity-cloud-devops-capstone
5+
labels:
6+
app: udacity-cloud-devops-capstone
7+
namespace: default
8+
spec:
9+
replicas: 3
10+
selector:
11+
matchLabels:
12+
app: udacity-cloud-devops-capstone
13+
strategy:
14+
rollingUpdate:
15+
maxSurge: 25%
16+
maxUnavailable: 25%
17+
type: RollingUpdate
18+
template:
19+
metadata:
20+
labels:
21+
app: udacity-cloud-devops-capstone
22+
spec:
23+
containers:
24+
- image: mydocker49/udacity-cloud-devops-capstone
25+
imagePullPolicy: Always
26+
name: udacity-cloud-devops-capstone
27+
ports:
28+
- containerPort: 80
29+
30+
---
31+
apiVersion: v1
32+
kind: Service
33+
metadata:
34+
name: udacity-cloud-devops-capstone
35+
labels:
36+
app: udacity-cloud-devops-capstone
37+
spec:
38+
type: LoadBalancer
39+
selector:
40+
app: udacity-cloud-devops-capstone
41+
ports:
42+
- port: 80
43+
targetPort: 80
44+
nodePort: 30000
45+
protocol: TCP

‎deployment/load-balancer.yml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: udacity-cloud-devops-capstone
5+
labels:
6+
app: udacity-cloud-devops-capstone
7+
spec:
8+
type: LoadBalancer
9+
selector:
10+
app: udacity-cloud-devops-capstone
11+
ports:
12+
- port: 80
13+
targetPort: 80

‎index.html

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="UTF-8" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>Welcome to my Capstone<title>
8+
</head>
9+
10+
<body>
11+
Hello, Welcome to Arnab's udacity cloud devops capstone project! 🚀
12+
</body>
13+
14+
</html>

‎scripts/create-kubeconfig.sh

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
aws eks \
2+
--region ap-south-1 \
3+
update-kubeconfig \
4+
--name $1 \

‎scripts/create-stack.sh

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
aws cloudformation create-stack \
2+
--stack-name $1 \
3+
--template-body file://$2 \
4+
--parameters file://$3 \
5+
--region ap-south-1 \
6+
--capabilities CAPABILITY_NAMED_IAM

‎scripts/delete-stack.sh

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
aws cloudformation delete-stack \
2+
--stack-name $1

‎scripts/run-docker.sh

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env bash
2+
3+
## Complete the following steps to get Docker running locally
4+
5+
# Step 1:
6+
# Build image and add a descriptive tag
7+
docker build -t udacity-capstone-app .
8+
9+
# Step 2:
10+
# List docker images
11+
docker images
12+
13+
# Step 3:
14+
# Run app
15+
docker run -p 80:80 udacity-capstone-app

‎scripts/run-kubernetes.sh

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env bash
2+
3+
# This tags and uploads an image to Docker Hub
4+
5+
# Step 1:
6+
# This is your Docker ID/path
7+
dockerpath="mydocker49/udacity-capstone-app"
8+
9+
# Step 2
10+
# Run the Docker Hub container with kubernetes
11+
kubectl run udacity-capstone-app --image=$dockerpath --port=80
12+
13+
14+
# Step 3:
15+
# List kubernetes pods
16+
kubectl get pods
17+
18+
19+
# Step 4:
20+
# Forward the container port to a host
21+
kubectl expose deployment udacity-capstone-app --type=LoadBalancer --port=80
22+
23+
# Open the service
24+
# minikube service udacity-capstone-app

‎scripts/update-stack.sh

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
aws cloudformation update-stack \
2+
--stack-name $1 \
3+
--template-body file://$2 \
4+
--parameters file://$3 \
5+
--region ap-south-1 \
6+
--capabilities CAPABILITY_NAMED_IAM

‎scripts/upload-docker.sh

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env bash
2+
# This file tags and uploads an image to Docker Hub
3+
4+
# Assumes that an image is built via `run_docker.sh`
5+
6+
# Step 1:
7+
# Create dockerpath
8+
dockerpath="mydocker49/udacity-capstone-app"
9+
10+
11+
# Step 2:
12+
# Authenticate & tag
13+
14+
docker login --username "mydocker49" &&\
15+
docker image tag cloudDevops-capstone $dockerpath
16+
echo "Docker ID and Image: $dockerpath"
17+
18+
# Step 3:
19+
# Push image to a docker repository
20+
docker image push $dockerpath

0 commit comments

Comments
 (0)
Please sign in to comment.