commit 5f3ccc3df471d798fecb77fea0490cb718f0eec8 Author: Lauri Võsandi Date: Sun Nov 27 13:11:54 2022 +0200 Initial commit diff --git a/Chart.yaml b/Chart.yaml new file mode 100644 index 0000000..29987f6 --- /dev/null +++ b/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +name: logmower-operator +description: Helm chart for oidc-operator +type: application +version: 0.1.0 +appVersion: 0.0.1 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..49df335 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,8 @@ +FROM python:alpine +RUN pip3 install flask +LABEL name="codemowers/hello-helm" \ + version="rc" \ + maintainer="Lauri Võsandi " +ENV PYTHONUNBUFFERED=1 +ADD app /app +ENTRYPOINT /app/app.py diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..5f9ae76 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2022 Lauri Võsandi + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..71c71b4 --- /dev/null +++ b/README.md @@ -0,0 +1,29 @@ +# Hello cloud native Flask + +In this example skeleton Flask application is provided with Prometheus +metrics endpoint. + +Steps to take with this repository: + +* Fork this repository to your personal GitHub +* Clone the forked repository to your machine +* Obtain sandbox environment from https://dashboard.codemowers.eu/ +* Follow the instructions on the page regarding `~/.kube/config` reconfiguration +* Execute the `skaffold dev ...` command provided on the sandbox detailed view + page to build and deploy the application in the remote cluster sandbox +* Proceed to build your awesome Flask application + +# Building and running locally + +With vanilla Docker + +``` +docker build . -t hello-flask:latest +docker run --network host -it hello-flask:latest +``` + +With `docker-compose`: + +``` +docker-compose up --build +``` diff --git a/app/app.py b/app/app.py new file mode 100755 index 0000000..4545d4d --- /dev/null +++ b/app/app.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python3 +import sys +from flask import Flask + +_, greeting = sys.argv +app = Flask(__name__) + + +@app.route("/") +def index(): + return "%s" % greeting + + +app.run(host="0.0.0.0", port=8000) diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..8c273cb --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,6 @@ +version: '3.7' +services: + app: + network_mode: host + build: + context: . diff --git a/skaffold.yaml b/skaffold.yaml new file mode 100644 index 0000000..ac014ff --- /dev/null +++ b/skaffold.yaml @@ -0,0 +1,21 @@ +apiVersion: skaffold/v3 +kind: Config +metadata: + name: hello-flask + +build: + cluster: + dockerConfig: + secretName: kaniko-secret + artifacts: + - image: hello-flask + +deploy: + helm: + releases: + - name: myapp + chartPath: ./ + setValues: + image: logmower-operator + greeting: Heya Lauri! + hostname: heya-lauri diff --git a/templates/application.yml b/templates/application.yml new file mode 100644 index 0000000..be400ad --- /dev/null +++ b/templates/application.yml @@ -0,0 +1,70 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: hello-flask +spec: + replicas: 2 + selector: + matchLabels: + app: hello-flask + template: + metadata: + labels: + app: hello-flask + spec: + enableServiceLinks: false + imagePullSecrets: + - name: regcred + containers: + - name: hello-flask + image: {{ .Values.image }} + command: + - /app/app.py + - {{ .Values.greeting }} + env: + - name: MY_POD_NAME + valueFrom: + fieldRef: + fieldPath: spec.nodeName + ports: + - containerPort: 8000 + name: metrics +--- +apiVersion: v1 +kind: Service +metadata: + name: hello-flask + labels: + app: hello-flask +spec: + selector: + app: hello-flask + ports: + - protocol: TCP + port: 8000 +--- +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: hello-flask + annotations: + kubernetes.io/ingress.class: shared + traefik.ingress.kubernetes.io/router.entrypoints: websecure + traefik.ingress.kubernetes.io/router.tls: "true" + external-dns.alpha.kubernetes.io/target: traefik.codemowers.ee +spec: + rules: + - host: {{ .Values.hostname }}.codemowers.ee + http: + paths: + - pathType: Prefix + path: "/" + backend: + service: + name: hello-flask + port: + number: 8000 + tls: + - hosts: + - "*.codemowers.ee"