Commit e8b8c035 authored by Nane Kratzke's avatar Nane Kratzke
Browse files
parents 3b4c35d5 d866594b
......@@ -3,6 +3,10 @@ variables:
NAMESPACE: "nane-kratzke"
VERSION: "0.0.1"
URL: "prime-nk.loki.th-luebeck.dev"
PRIME: "yes"
CACHE: "no"
PERSISTENT_CACHE: "yes"
stages:
- prepare
......@@ -23,14 +27,21 @@ prepare:
--docker-password=$CI_REGISTRY_TOKEN \
-n $NAMESPACE"
build:
claim-volume:
stage: prepare
only:
variables:
- $PERSISTENT_CACHE == "yes"
image:
name: $KUBECTL
entrypoint: [""]
script:
- kubectl apply -f deploy/storage -n $NAMESPACE
build-prime:
stage: build
services:
- docker:dind
only:
changes:
- prime/*
- .gitlab-ci.yml
script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- cd prime
......@@ -38,18 +49,46 @@ build:
- docker push $CI_REGISTRY_IMAGE/prime:$VERSION
- docker push $CI_REGISTRY_IMAGE/prime:latest
deploy:
deploy-prime:
stage: deploy
only:
variables:
- $PRIME == "yes"
image:
name: $KUBECTL
entrypoint: [""]
script:
- echo "Deploying to Kubernetes"
- wget -q https://github.com/mikefarah/yq/releases/download/3.4.0/yq_linux_amd64 -O ./yq && chmod +x yq
- ./yq w -i deploy/service/prime-ingress.yaml spec.rules[0].host $URL
- ./yq w -i deploy/service/prime-ingress.yaml spec.tls[0].hosts[0] $URL
- cat deploy/service/prime-ingress.yaml
- kubectl delete -f deploy/service -n $NAMESPACE || true
- kubectl apply -f deploy/service -n $NAMESPACE
- ./yq w -i deploy/prime/prime-ingress.yaml spec.rules[0].host $URL
- ./yq w -i deploy/prime/prime-ingress.yaml spec.tls[0].hosts[0] $URL
- kubectl delete -f deploy/prime -n $NAMESPACE || true
- kubectl apply -f deploy/prime -n $NAMESPACE
deploy-cache:
stage: deploy
only:
variables:
- $CACHE == "yes"
image:
name: $KUBECTL
entrypoint: [""]
script:
- kubectl delete -f deploy/persistent-redis -n $NAMESPACE || true
- kubectl delete -f deploy/redis -n $NAMESPACE || true
- kubectl apply -f deploy/redis -n $NAMESPACE
deploy-persistent-cache:
stage: deploy
only:
variables:
- $PERSISTENT_CACHE == "yes"
image:
name: $KUBECTL
entrypoint: [""]
script:
- kubectl delete -f deploy/redis -n $NAMESPACE || true
- kubectl delete -f deploy/persistent-redis -n $NAMESPACE || true
- kubectl apply -f deploy/persistent-redis -n $NAMESPACE
apiVersion: apps/v1
kind: Deployment
metadata:
name: redis
labels:
app: redis
spec:
selector:
matchLabels:
app: redis
replicas: 1
template:
metadata:
labels:
app: redis
spec:
containers:
- name: master
image: k8s.gcr.io/redis
resources:
limits:
cpu: 100m
memory: 100Mi
ports:
- containerPort: 6379
volumeMounts:
- mountPath: "/data"
name: redis-volume
volumes:
- name: redis-volume
persistentVolumeClaim:
claimName: redis-volume-claim
---
apiVersion: v1
kind: Service
metadata:
name: redis-service
spec:
selector:
app: redis
ports:
- protocol: TCP
port: 6379
targetPort: 6379
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