diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index cb8092d..a1a128c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -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,,${CI_REGISTRY_IMAGE},g" kubernetes/deployment.yaml + - sed -i "s//${CI_COMMIT_SHA}/g" kubernetes/deployment.yaml + - kubectl apply -f kubernetes/deployment.yaml + + - sed -i "s,,${CLIENT_ID},g" kubernetes/configmap.yaml + - sed -i "s//${CLIENT_SECRET}/g" kubernetes/configmap.yaml + - sed -i "s,,${REDIRECT_URL},g" kubernetes/configmap.yaml + - sed -i "s,,${HOST},g" kubernetes/configmap.yaml + - sed -i "s,,${DATABASE},g" kubernetes/configmap.yaml + - sed -i "s,,${USER},g" kubernetes/configmap.yaml + - sed -i "s,,${PASSWORD},g" kubernetes/configmap.yaml + - kubectl apply -f kubernetes/configmap.yaml + + - kubectl apply -f kubernetes/service.yaml + + - sed -i "s//${URL}/g" kubernetes/traefik.yaml + - kubectl apply -f kubernetes/traefik.yaml diff --git a/kubernetes/configmap.yaml b/kubernetes/configmap.yaml new file mode 100644 index 0000000..eb8aa5c --- /dev/null +++ b/kubernetes/configmap.yaml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: env + namespace: analytics-for-spotify +data: + CLIENT_ID: "" + CLIENT_SECRET: "" + HOST: + DATABASE: + USER: + PASSWORD: + REDIRECT_URL: "" diff --git a/kubernetes/deployment.yaml b/kubernetes/deployment.yaml new file mode 100644 index 0000000..ccfecf9 --- /dev/null +++ b/kubernetes/deployment.yaml @@ -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: : + 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 diff --git a/kubernetes/service.yaml b/kubernetes/service.yaml new file mode 100644 index 0000000..7656b2e --- /dev/null +++ b/kubernetes/service.yaml @@ -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 diff --git a/kubernetes/traefik.yaml b/kubernetes/traefik.yaml new file mode 100644 index 0000000..384c19b --- /dev/null +++ b/kubernetes/traefik.yaml @@ -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(``)" + kind: Rule + services: + - name: analytics-for-spotify + port: 80