Skip to content

Commit

Permalink
Kubernetes Configs
Browse files Browse the repository at this point in the history
  • Loading branch information
ArthurVardevanyan committed Oct 17, 2021
1 parent bfda653 commit 1125f57
Show file tree
Hide file tree
Showing 5 changed files with 141 additions and 0 deletions.
26 changes: 26 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,29 @@ PushDevelop:
- docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
- docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA $CI_REGISTRY_IMAGE:$CI_COMMIT_BRANCH
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_BRANCH

DeployKubernetes:
stage: deploy
image: ${IMAGE}
environment: production
only:
- develop
- production
script:
- sed -i "s,<IMAGE>,${CI_REGISTRY_IMAGE},g" kubernetes/deployment.yaml
- sed -i "s/<VERSION>/${CI_COMMIT_SHA}/g" kubernetes/deployment.yaml
- kubectl apply -f kubernetes/deployment.yaml

- sed -i "s,<CLIENT_ID>,${CLIENT_ID},g" kubernetes/configmap.yaml
- sed -i "s/<CLIENT_SECRET>/${CLIENT_SECRET}/g" kubernetes/configmap.yaml
- sed -i "s,<REDIRECT_URL>,${REDIRECT_URL},g" kubernetes/configmap.yaml
- sed -i "s,<HOST>,${HOST},g" kubernetes/configmap.yaml
- sed -i "s,<DATABASE>,${DATABASE},g" kubernetes/configmap.yaml
- sed -i "s,<USER>,${USER},g" kubernetes/configmap.yaml
- sed -i "s,<PASSWORD>,${PASSWORD},g" kubernetes/configmap.yaml
- kubectl apply -f kubernetes/configmap.yaml

- kubectl apply -f kubernetes/service.yaml

- sed -i "s/<URL>/${URL}/g" kubernetes/traefik.yaml
- kubectl apply -f kubernetes/traefik.yaml
13 changes: 13 additions & 0 deletions kubernetes/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: env
namespace: analytics-for-spotify
data:
CLIENT_ID: "<CLIENT_ID>"
CLIENT_SECRET: "<CLIENT_SECRET>"
HOST: <HOST>
DATABASE: <DATABASE>
USER: <USER>
PASSWORD: <PASSWORD>
REDIRECT_URL: "<REDIRECT_URL>"
75 changes: 75 additions & 0 deletions kubernetes/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: analytics-for-spotify
namespace: analytics-for-spotify
labels:
app: analytics-for-spotify
spec:
replicas: 1
revisionHistoryLimit: 0
strategy:
type: RollingUpdate
selector:
matchLabels:
app: analytics-for-spotify
template:
metadata:
labels:
app: analytics-for-spotify
annotations:
enable.version-checker.io/analytics-for-spotify: "false"
spec:
containers:
- env:
- name: CLIENT_ID
valueFrom:
configMapKeyRef:
key: CLIENT_ID
name: env
- name: CLIENT_SECRET
valueFrom:
configMapKeyRef:
key: CLIENT_SECRET
name: env
- name: DATABASE
valueFrom:
configMapKeyRef:
key: DATABASE
name: env
- name: DOCKER
value: "YES"
- name: HOST
valueFrom:
configMapKeyRef:
key: HOST
name: env
- name: PASSWORD
valueFrom:
configMapKeyRef:
key: PASSWORD
name: env
- name: REDIRECT_URL
valueFrom:
configMapKeyRef:
key: REDIRECT_URL
name: env
- name: USER
valueFrom:
configMapKeyRef:
key: USER
name: env
image: <IMAGE>:<VERSION>
imagePullPolicy: IfNotPresent
name: analytics-for-spotify
ports:
- containerPort: 80
resources:
limits:
cpu: 350m
memory: 250M
requests:
cpu: 150m
memory: 175M
hostname: analytics-for-spotify
restartPolicy: Always
13 changes: 13 additions & 0 deletions kubernetes/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: Service
metadata:
namespace: analytics-for-spotify
name: analytics-for-spotify
spec:
ports:
- protocol: TCP
name: web
port: 80
targetPort: 80
selector:
app: analytics-for-spotify
14 changes: 14 additions & 0 deletions kubernetes/traefik.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
name: analytics-for-spotify
namespace: analytics-for-spotify
spec:
entryPoints:
- web
routes:
- match: "Host(`<URL>`)"
kind: Rule
services:
- name: analytics-for-spotify
port: 80

0 comments on commit 1125f57

Please sign in to comment.