Skip to content

Commit

Permalink
update readme and add kubernetes deployment configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
iperoyg committed Jul 10, 2022
1 parent 6a5e8fe commit d74f495
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,16 @@ http://127.0.0.1:8000/

## Docker

- Build Image: `docker build -t complexop_iperoyg/api -f Dockerfile.API .`
- Open Shell: `docker run -it --rm --name api_container complexop_iperoyg/api sh`



- Build Image: `docker build -t iperoyg/complexop_api:v1.0.0 -f Dockerfile.API .`
- Open Shell: `docker run -it --rm --name api_container iperoyg/complexop_api:v1.0.0 sh`
- Run API:
- `docker run -d -p 12345:80 --name api_container iperoyg/complexop_api:v1.0.0 uvicorn main:app --host 0.0.0.0 --port 80`
- `docker run -d --rm -p 12345:80 --env PORT=80 --name api_container iperoyg/complexop_api:v1.0.0`
- Push to registry:
- `docker push iperoyg/complexop_api:v1.0.0`


## Kubernetes
- kubectl get deploy
- kubectl delete deploy <deployment name>
- kubectl apply -f .\kubernetes_deploy.yml
64 changes: 64 additions & 0 deletions src/apicomplexoperations/kubernetes_deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# check out all Kubernetes commands here:
# https://kubernetes.io/docs/reference/kubectl/cheatsheet/
# -----------------------------------------------------------*
# implies the use of kubernetes 1.7
# -----------------------------------------------------------*
apiVersion: apps/v1
kind: Deployment
metadata:
name: complexop-api
namespace: default
spec:
replicas: 2 # this is number of pods
selector:
matchLabels:
app: complexop-api
template:
metadata:
labels:
app: complexop-api
spec:
# Kubernetes run docker pull pseudo/your-image:latest under the hood
# Image field in Kubernetes resources is simply the docker image to run.
containers:
- name: complexop-api
image: iperoyg/complexop_api:v1.0.0
env:
- name: PORT
value: "42"
# specify the container port
ports:
- containerPort: 42
# using if not present works well with images that has tag
# if you image is tag:lastest - use Always otherwise you
# wouldn't get the fresh version of your image
# imagePullPolicy: Always
# -----------------------------------------------------------*
# It is a good practice to declare resource requests and
# limits for both memory and cpu for each container.
# This helps to schedule the container to a node that has
# available resources for your Pod, and also so that your
# Pod does not use resources that other Pods needs
# -----------------------------------------------------------*
resources:
limits:
memory: 64Mi
cpu: "250m"
requests:
memory: 32Mi
cpu: "200m"
---
apiVersion: v1
kind: Service
metadata:
name: complexop-api-entrypoint
namespace: default
spec:
type: LoadBalancer
selector:
app: complexop-api
ports:
- name: http
protocol: TCP
port: 30000
targetPort: 42

0 comments on commit d74f495

Please sign in to comment.