working helm chart
parent
e9f0f81f94
commit
29ab885606
@ -0,0 +1,12 @@
|
|||||||
|
|
||||||
|
IMAGE_NAME=registry.runcible.io/demo-helm
|
||||||
|
IMAGE_VERSION=1.0.1
|
||||||
|
|
||||||
|
push-app-image: build-app-image
|
||||||
|
docker push $(IMAGE_NAME):$(IMAGE_VERSION)
|
||||||
|
|
||||||
|
build-app-image:
|
||||||
|
docker build -t $(IMAGE_NAME):$(IMAGE_VERSION) ./app
|
||||||
|
|
||||||
|
check:
|
||||||
|
echo $(IMAGE_NAME):$(IMAGE_VERSION)
|
@ -1,3 +1,16 @@
|
|||||||
# demo-helm
|
# demo-helm
|
||||||
|
|
||||||
A demo helm chart to deploy a simple web app written in Python
|
A demo helm chart to deploy a simple web app written in Python
|
||||||
|
|
||||||
|
|
||||||
|
## Setting registry pull secrets
|
||||||
|
|
||||||
|
From: [The k8s docs](https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/#create-a-secret-by-providing-credentials-on-the-command-line)
|
||||||
|
|
||||||
|
```
|
||||||
|
kubectl create secret docker-registry regcred \
|
||||||
|
--docker-server=<your-registry-server> \
|
||||||
|
--docker-username=<your-name> \
|
||||||
|
--docker-password=<your-pword> \
|
||||||
|
--docker-email=<your-email>
|
||||||
|
```
|
@ -0,0 +1,27 @@
|
|||||||
|
# Base Image
|
||||||
|
FROM python:3.7.3-stretch
|
||||||
|
|
||||||
|
ENV APP_HOME=/opt/app
|
||||||
|
|
||||||
|
# Create directory for the app
|
||||||
|
RUN mkdir $APP_HOME
|
||||||
|
WORKDIR $APP_HOME
|
||||||
|
|
||||||
|
# Create the app user
|
||||||
|
RUN groupadd app && useradd -g app app
|
||||||
|
|
||||||
|
# Install Requirements
|
||||||
|
COPY requirements.txt .
|
||||||
|
|
||||||
|
RUN pip install --no-cache -r requirements.txt
|
||||||
|
|
||||||
|
# Install app
|
||||||
|
COPY app.py .
|
||||||
|
|
||||||
|
# Chown all the files to the app user
|
||||||
|
RUN chown -R app:app $APP_HOME
|
||||||
|
|
||||||
|
# Change to the app user
|
||||||
|
USER app
|
||||||
|
|
||||||
|
CMD gunicorn --log-level=debug -b 0.0.0.0:5000 app:app
|
@ -0,0 +1,18 @@
|
|||||||
|
import os
|
||||||
|
from flask import Flask
|
||||||
|
|
||||||
|
app = Flask(__name__)
|
||||||
|
|
||||||
|
__version__ = "1.0.0"
|
||||||
|
|
||||||
|
@app.route("/ping")
|
||||||
|
@app.route("/")
|
||||||
|
def pong():
|
||||||
|
"""A simple ping route."""
|
||||||
|
return {"message": "pong"}
|
||||||
|
|
||||||
|
|
||||||
|
@app.route("/env")
|
||||||
|
def env():
|
||||||
|
"""Exposes the environment variables."""
|
||||||
|
return dict(os.environ)
|
@ -0,0 +1,2 @@
|
|||||||
|
flask==2.0.2
|
||||||
|
gunicorn==20.1.0
|
@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
apiVersion: v2
|
||||||
|
name: demo-helm
|
||||||
|
appVersion: 1.0.1
|
||||||
|
description: A Helm chart to practice helm
|
||||||
|
version: 0.1.1
|
||||||
|
type: application
|
@ -0,0 +1,13 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
name: backend
|
||||||
|
name: backend
|
||||||
|
spec:
|
||||||
|
ports:
|
||||||
|
- protocol: 'TCP'
|
||||||
|
port: 80
|
||||||
|
targetPort: 5000
|
||||||
|
selector:
|
||||||
|
app: backend
|
@ -0,0 +1,23 @@
|
|||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: backend
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: backend
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: backend
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- image: registry.runcible.io/demo-helm:1.0.1
|
||||||
|
imagePullPolicy: Always
|
||||||
|
name: backend
|
||||||
|
ports:
|
||||||
|
- name: backend
|
||||||
|
containerPort: 5000
|
||||||
|
imagePullSecrets:
|
||||||
|
- name: regcred
|
@ -0,0 +1,14 @@
|
|||||||
|
apiVersion: extensions/v1beta1
|
||||||
|
# apiVersion: networking.k8s.io/v1 # Supposed to be the new API but of course the spec structure has changed.
|
||||||
|
kind: Ingress
|
||||||
|
metadata:
|
||||||
|
name: demo-helm-ingress
|
||||||
|
spec:
|
||||||
|
rules:
|
||||||
|
- host: backend.runcible.io
|
||||||
|
http:
|
||||||
|
paths:
|
||||||
|
- path: /
|
||||||
|
backend:
|
||||||
|
serviceName: backend
|
||||||
|
servicePort: 80
|
Loading…
Reference in New Issue