Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
DevOps Project
1. Table ofContents
Project Implementation .....................................................................3
Executive Overview ..........................................................................3
Problem definition............................................................................3
Code Pre-requisites...........................................................................3
Run the Code...................................................................................3
what will happen with this Start.sh file....................................................4
Files using to do the deployments ..........................................................4
Note:.......................................................................................................................4
Code Descriptions.............................................................................5
Deployment.Yaml ...................................................................................................5
DockerFile ..............................................................................................................6
Start.sh ...................................................................................................................7
App.py ....................................................................................................................8
2. Project Implementation
Executive Overview
The purpose of this project is to:
1. Create endpoints using python language include with HTTP Service.
2. Deploy HTTP Services using Kubernetes.
3. Share the code and documentation.
Table 1 Project Scope
Task name Task Deliverable
YAML File Troubleshooting Working YAML file to deploy the code
Short Term Changes Documentation.
High Level Diagram of alternatives Documentation.
Problem definition
TheaimoftestistocreateasimpleHTTPservicethatstoresandreturnsconfigurationsthatsatisfy
certain conditions. Since we love automating things, the service should be automatically deployed to
Kubernetes.
Code Pre-requisites
1. Docker installs in your pc
2. working Kubernetes Cluster or Mini cube
3. Kubectl install in your pc
4. Docker hubaccount
Run theCode
1. Go to Projectfolder
2. Run start.sh
3. what will happen with this Start.sh file
1. Build docker image with Python Code
2. Push this docker image to docker registry
3. Create Deployment in Kubernetes cluster using uploaded docker image
4. Create Replication Controller
5. ExposethisReplication Controller as a Serviceto access from outside the Kubernetes cluster
Files using to do the deployments
File name Descriptions
Docker file this will use to create docker image
Deployment.Yaml This will use to create Deployment inside
the Kubernetescluster.
Inthisfilewecanmentionalldetailssuch
as docker image name ports environment
variable details and everything
Start.sh Contains Command lines to start the
deployment and Runt the Project
app.py This is the endpoint structure and return the
HTTP status codes.
Note:-
• inyour Deployment.Yaml fileyouhave toreplace<user_dockerhub_username> partwith
your docker hubusername.
• in start.sh file also you have to change <user_dockerhub_username> and
<user_dockerhub_passowrd>
• Oncethestart.shwillbedonetheoutputwillbelikethefollowing,copythatExternal-IP
and brows it through the browser.:-
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
hello-web LoadBalancer 10.245.85.187 157.230.75.39 80:30522/TCP 4d22h
4. Code Descriptions
Deployment.Yaml
Figure 1 Screensht of YAML FILE
As you see from the above Figure which is Data-structure hierarchy is maintained by outline
indentation, the abovefile
• A Deployment named Python-app-deployment is created, indicated bythe .metadata.name
field.
• The Deployment creates two replicated Pods, indicated by the replicas field.
• simplyselectalabelthatisdefinedinthePodtemplate(app:python-app),However,more
sophisticated selection rules are possible, as long as the Pod template itself satisfies therule.
• The template field contains the following sub-fields:
o The Pods are labeled app: python-app the labels field.
o Create one container and name it python-app using the name field.
5. DockerFile
Figure 2 Dockerfile code
build images automatically by reading the instructions from a Dockerfile.
• TheFROM instruction initializes anewbuildstageandsetstheBaseImageforsubsequent
instructions.
• The WORKDIRlinespecifies a newdefaultdirectorywithintheimage'sfile system.
• Copy command let you copy files from a specific location into a Docker image.
• CMDistoprovidedefaultsforanexecutingcontainer,AddthelastlinetoyourDockerfileto
execute the script.
6. Start.sh
Figure 3 Start.sh Code
Thisfilecontainsdifferentcommandlinethatshouldbeexecutedtobuildtheimageandloginto
your docker hub, please replace with your username for valid deployment otherwise the
deployment will be invalid, and it will generate an error.
7. App.py
Figure 4 Python code
This is contains HTTP Services with the following endpoints
Name Method URL
List GET /configs
Create POST /configs
Get GET /configs/{name}
Update PUT/PATCH /configs/{name}
Delete PUT/PATCH /configs/{name}
Query GET /search?metadata.key=value