-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add `microservice-python-deploy-kubernetes` template.
- Loading branch information
Sergio García Prado
committed
Dec 13, 2021
1 parent
93b03a3
commit 7def6f7
Showing
7 changed files
with
93 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
microservice/language/python/deploy/kubernetes/Makefile.jinja
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
build: | ||
docker build --no-cache -t {{ project_name }}_{{ name }} -f deploy/Dockerfile . | ||
docker tag {{ project_name }}_{{ name }}:latest {{ kubernetes_registry }}/{{ project_name }}_{{ name }}:{{ version }} | ||
docker push {{ kubernetes_registry }}/{{ project_name }}_{{ name }}:{{ version }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: | ||
type: str | ||
help: What is the name of the microservice? | ||
version: | ||
type: str | ||
help: What is the version of the microservice? | ||
project_name: | ||
type: str | ||
help: What is the name of the project? | ||
rest_port: | ||
type: int | ||
default: 8080 | ||
help: What is the rest's port? | ||
kubernetes_config: | ||
type: str | ||
default: microservices-config | ||
help: What is the kubernetes config? | ||
kubernetes_registry: | ||
type: str | ||
help: What is the kubernetes registry? | ||
|
||
_envops: | ||
block_start_string: "{%" | ||
block_end_string: "%}" | ||
comment_start_string: "{#" | ||
comment_end_string: "#}" | ||
variable_start_string: "{{" | ||
variable_end_string: "}}" | ||
keep_trailing_newline: false | ||
|
||
_templates_suffix: .jinja |
17 changes: 17 additions & 0 deletions
17
microservice/language/python/deploy/kubernetes/deploy/Dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
FROM ghcr.io/clariteia/minos-microservice:0.1.5 as development | ||
|
||
COPY ./pyproject.toml ./poetry.lock ./ | ||
RUN poetry install --no-root | ||
COPY . . | ||
CMD ["poetry", "run", "microservice", "start"] | ||
|
||
FROM development as build | ||
RUN poetry export --without-hashes > req.txt && pip wheel -r req.txt --wheel-dir ./dist | ||
RUN poetry build --format wheel | ||
|
||
FROM python:3.9-slim as production | ||
COPY --from=build /microservice/dist/ ./dist | ||
RUN pip install --no-deps ./dist/* | ||
COPY config.yml ./config.yml | ||
ENTRYPOINT ["microservice"] | ||
CMD ["start"] |
24 changes: 24 additions & 0 deletions
24
microservice/language/python/deploy/kubernetes/deploy/deployment.yaml.jinja
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: {{ project_name }}-{{ name }} | ||
namespace: {{ project_name }} | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app.kubernetes.io/name: {{ project_name }}-{{ name }} | ||
template: | ||
metadata: | ||
labels: | ||
app.kubernetes.io/name: {{ project_name }}-{{ name }} | ||
spec: | ||
containers: | ||
- name: {{ project_name }}-{{ name }} | ||
image: {{ kubernetes_registry }}/{{ project_name }}-{{ name }}:{{ version }} | ||
imagePullPolicy: "IfNotPresent" | ||
ports: | ||
- containerPort: {{ rest_port }} | ||
envFrom: | ||
- configMapRef: | ||
name: {{ kubernetes_config }} |
12 changes: 12 additions & 0 deletions
12
microservice/language/python/deploy/kubernetes/deploy/service.yaml.jinja
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: {{ project_name }}-{{ name }} | ||
namespace: {{ project_name }} | ||
spec: | ||
type: ClusterIP | ||
ports: | ||
- port: {{ rest_port }} | ||
targetPort: {{ rest_port }} | ||
selector: | ||
app.kubernetes.io/name: {{ project_name }}-{{ name }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters