Commit d58d65cd authored by Nane Kratzke's avatar Nane Kratzke
Browse files

hiphop basic config

parent 74ead2a4
hiphop/__pycache__/*
stages:
- build
- deploy
- teardown
variables:
KUBECTL: "transit/kubectl-plus:v1.19.4"
CLUSTER: "rig.th-luebeck.dev"
container:
stage: build
only:
changes:
- hiphop/*
- hiphop/*/*
script:
- mkdir -p /kaniko/.docker
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
- cd src
- /kaniko/executor --context . --destination $CI_REGISTRY_IMAGE/hiphop:latest
secrets:
stage: build
image: $KUBECTL
script:
- kubectl delete secret gitlab-registry-credentials || true
- "kubectl create secret docker-registry gitlab-registry-credentials \
--docker-server=$CI_REGISTRY \
--docker-username=image-registry \
--docker-password=$REGISTRY_READ_TOKEN \
"
hiphop:
stage: deploy
image: $KUBECTL
script:
- NS=$(kubectl config view --minify --output 'jsonpath={..namespace}')
- VHOST=hiphop.$NS.$CLUSTER TIER=1 mo deploy/hiphop-deploy+svc.yaml | kubectl apply -f -
- VHOST=hiphop.$NS.$CLUSTER TIER=2 mo deploy/hiphop-deploy+svc.yaml | kubectl apply -f -
- VHOST=hiphop.$NS.$CLUSTER TIER=3 mo deploy/hiphop-deploy+svc.yaml | kubectl apply -f -
- VHOST=hiphop.$NS.$CLUSTER TIER=4 mo deploy/hiphop-deploy+svc.yaml | kubectl apply -f -
- VHOST=hiphop.$NS.$CLUSTER mo deploy/hiphop-ingress.yaml | kubectl apply -f -
shutdown:
stage: teardown
image: $KUBECTL
when: manual
script:
- NS=$(kubectl config view --minify --output 'jsonpath={..namespace}')
- VHOST=hiphop.$NS.$CLUSTER TIER=1 mo deploy/hiphop-deploy+svc.yaml | kubectl delete -f -
- VHOST=hiphop.$NS.$CLUSTER TIER=2 mo deploy/hiphop-deploy+svc.yaml | kubectl delete -f -
- VHOST=hiphop.$NS.$CLUSTER TIER=3 mo deploy/hiphop-deploy+svc.yaml | kubectl delete -f -
- VHOST=hiphop.$NS.$CLUSTER TIER=4 mo deploy/hiphop-deploy+svc.yaml | kubectl delete -f -
- VHOST=hiphop.$NS.$CLUSTER mo deploy/hiphop-ingress.yaml | kubectl delete -f -
apiVersion: apps/v1
kind: Deployment
metadata:
name: hiphop-deployment-{{ TIER }}
annotations:
sidecar.jaegertracing.io/inject: "true"
spec:
replicas: {{ TIER }}
selector:
matchLabels:
app: hiphop
tier: {{ TIER }}
template:
metadata:
labels:
app: hiphop
tier: {{ TIER }}
spec:
imagePullSecrets:
- name: gitlab-registry-credentials
containers:
- name: hiphop
image: git.mylab.th-luebeck.de:4181/cloud-native/lab-tracing/hiphop:latest
imagePullPolicy: Always
resources:
limits:
cpu: "50m"
ports:
- containerPort: 80
env:
- name: HIPHOP
value: "hiphop"
- name: TIER
value: {{ TIER }}
---
apiVersion: v1
kind: Service
metadata:
name: hiphop-service-{{ TIER }}
spec:
selector:
app: hiphop
tier: {{ TIER }}
ports:
- protocol: TCP
port: 80
targetPort: 80
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: hiphop-ingress
annotations:
cert-manager.io/cluster-issuer: "letsencrypt-production"
spec:
rules:
- host: {{ VHOST }}
http:
paths:
- backend:
serviceName: hiphop-service-1
servicePort: 80
tls:
- secretName: prime-ingress-cert
hosts:
- {{ VHOST }}
FROM python:3.9-alpine
COPY . /app/
WORKDIR /app
RUN apk update && apk upgrade && apk add --no-cache bash git openssh
RUN pip3 install -r requirements.txt
ENV FLASK_APP=service.py
EXPOSE 80
ENTRYPOINT ["flask", "run", "--host=0.0.0.0", "--port=80"]
from flask import Flask
from flask import Flask, redirect
from jaeger_client import Config
from flask_opentracing import FlaskTracing
import requests
import os
service = os.environ.get('HIPHOP', 'hiphop')
tier = int(os.environ.get('TIER', '1'))
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment