From 69cc2b1dfb2c0bb639f24ba2cdd6a056c5e95d99 Mon Sep 17 00:00:00 2001 From: Aram Peres Date: Fri, 4 Dec 2020 23:21:17 -0500 Subject: [PATCH] abitibi --- .gitlab-ci.yml | 33 ++++++++++ abitibi/.gitignore | 2 + abitibi/chart/abitibi/Chart.yaml | 5 ++ abitibi/chart/abitibi/templates/_helpers.tpl | 45 ++++++++++++++ .../chart/abitibi/templates/deployment.yaml | 52 ++++++++++++++++ abitibi/chart/abitibi/templates/service.yaml | 19 ++++++ abitibi/chart/abitibi/values.yaml | 15 +++++ abitibi/docker/Dockerfile | 3 + abitibi/docker/nginx.conf | 21 +++++++ abitibi/src/index.html | 61 +++++++++++++++++++ infra/manifests/ingress.yaml | 12 +++- 11 files changed, 267 insertions(+), 1 deletion(-) create mode 100644 abitibi/.gitignore create mode 100644 abitibi/chart/abitibi/Chart.yaml create mode 100644 abitibi/chart/abitibi/templates/_helpers.tpl create mode 100644 abitibi/chart/abitibi/templates/deployment.yaml create mode 100644 abitibi/chart/abitibi/templates/service.yaml create mode 100644 abitibi/chart/abitibi/values.yaml create mode 100644 abitibi/docker/Dockerfile create mode 100644 abitibi/docker/nginx.conf create mode 100644 abitibi/src/index.html diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c7b1bea..46ffde4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,10 +4,12 @@ variables: TEAMSPEAK_SRC: ${CI_PROJECT_DIR}/teamspeak DEFIANT_SRC: ${CI_PROJECT_DIR}/defiant CHARTMUSEUM_SRC: ${CI_PROJECT_DIR}/chartmuseum + ABITIBI_SRC: ${CI_PROJECT_DIR}/abitibi IMAGE_PREFIX: registry.gitlab.com/momothereal/momoperes.ca WEBSITE_IMAGE: ${IMAGE_PREFIX}/website DEFIANT_IMAGE: ${IMAGE_PREFIX}/defiant + ABITIBI_IMAGE: ${IMAGE_PREFIX}/abitibi KUBECONFIG_PARENT: /etc/deploy KUBECONFIG: ${KUBECONFIG_PARENT}/config @@ -49,6 +51,37 @@ website:deploy: changes: - website/**/* +### ABITIBI ### + +abitibi:release: + stage: release + image: + name: gcr.io/kaniko-project/executor:debug + entrypoint: [""] + script: + - echo "Building to ${ABITIBI_IMAGE}:${CI_COMMIT_TAG}" + - echo "{\"auths\":{\"${CI_REGISTRY}\":{\"username\":\"${CI_REGISTRY_USER}\",\"password\":\"${CI_REGISTRY_PASSWORD}\"}}}" > /kaniko/.docker/config.json + - /kaniko/executor --context ${ABITIBI_SRC} --dockerfile ${ABITIBI_SRC}/docker/Dockerfile --destination ${ABITIBI_IMAGE}:${CI_COMMIT_REF_SLUG}-${CI_COMMIT_SHORT_SHA} --destination ${ABITIBI_IMAGE}:${CI_COMMIT_REF_SLUG} + only: + changes: + - abitibi/**/* + +abitibi:deploy: + stage: deploy + image: lwolf/helm-kubectl-docker:v1.15.4-v2.14.3 + script: + - mkdir -p ${KUBECONFIG_PARENT} + - echo ${K8S_CLUSTER_CONFIG} | base64 -d > ${KUBECONFIG} + + # Deploy using helm chart + - cd ${ABITIBI_SRC} + - helm upgrade --install --force --namespace ${DEPLOY_NAMESPACE} --set image.name=${ABITIBI_IMAGE},image.tag=${CI_COMMIT_REF_SLUG}-${CI_COMMIT_SHORT_SHA} website ./chart/abitibi + only: + refs: + - master + changes: + - abitibi/**/* + # INFRA # infra:deploy: diff --git a/abitibi/.gitignore b/abitibi/.gitignore new file mode 100644 index 0000000..a78aadb --- /dev/null +++ b/abitibi/.gitignore @@ -0,0 +1,2 @@ +.idea/ +chart/abitibi/manifests/ diff --git a/abitibi/chart/abitibi/Chart.yaml b/abitibi/chart/abitibi/Chart.yaml new file mode 100644 index 0000000..f5607ec --- /dev/null +++ b/abitibi/chart/abitibi/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +appVersion: "1.0" +description: Helm chart for my personal abitibi +name: abitibi +version: 0.1.0 diff --git a/abitibi/chart/abitibi/templates/_helpers.tpl b/abitibi/chart/abitibi/templates/_helpers.tpl new file mode 100644 index 0000000..fd1cf2b --- /dev/null +++ b/abitibi/chart/abitibi/templates/_helpers.tpl @@ -0,0 +1,45 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "abitibi.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "abitibi.fullname" -}} +{{- if .Values.fullnameOverride -}} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- if contains $name .Release.Name -}} +{{- .Release.Name | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} +{{- end -}} +{{- end -}} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "abitibi.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Common labels +*/}} +{{- define "abitibi.labels" -}} +app.kubernetes.io/name: {{ include "abitibi.name" . }} +helm.sh/chart: {{ include "abitibi.chart" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end -}} diff --git a/abitibi/chart/abitibi/templates/deployment.yaml b/abitibi/chart/abitibi/templates/deployment.yaml new file mode 100644 index 0000000..eba2f74 --- /dev/null +++ b/abitibi/chart/abitibi/templates/deployment.yaml @@ -0,0 +1,52 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "abitibi.fullname" . }} + labels: +{{ include "abitibi.labels" . | indent 4 }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + app.kubernetes.io/name: {{ include "abitibi.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + template: + metadata: + labels: + app.kubernetes.io/name: {{ include "abitibi.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.name }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - name: http + containerPort: 80 + protocol: TCP + livenessProbe: + httpGet: + path: / + port: http + readinessProbe: + httpGet: + path: / + port: http + resources: + {{- toYaml .Values.resources | nindent 12 }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/abitibi/chart/abitibi/templates/service.yaml b/abitibi/chart/abitibi/templates/service.yaml new file mode 100644 index 0000000..a5d7e96 --- /dev/null +++ b/abitibi/chart/abitibi/templates/service.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "abitibi.fullname" . }} + labels: +{{ include "abitibi.labels" . | indent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + {{- if (eq .Values.service.type "ClusterIP") }} + nodePort: null + {{- end }} + selector: + app.kubernetes.io/name: {{ include "abitibi.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} diff --git a/abitibi/chart/abitibi/values.yaml b/abitibi/chart/abitibi/values.yaml new file mode 100644 index 0000000..00c61ce --- /dev/null +++ b/abitibi/chart/abitibi/values.yaml @@ -0,0 +1,15 @@ +replicaCount: 2 + +image: + name: notset + tag: latest + pullPolicy: Always + +imagePullSecrets: [] + +nameOverride: "" +fullnameOverride: "" + +service: + type: ClusterIP + port: 9000 diff --git a/abitibi/docker/Dockerfile b/abitibi/docker/Dockerfile new file mode 100644 index 0000000..027eaa7 --- /dev/null +++ b/abitibi/docker/Dockerfile @@ -0,0 +1,3 @@ +FROM nginx:alpine +COPY src/ /usr/share/nginx/html +COPY docker/nginx.conf /etc/nginx/conf.d/default.conf \ No newline at end of file diff --git a/abitibi/docker/nginx.conf b/abitibi/docker/nginx.conf new file mode 100644 index 0000000..9128b3f --- /dev/null +++ b/abitibi/docker/nginx.conf @@ -0,0 +1,21 @@ +server { + listen 80; + server_name localhost; + + add_header Content-Security-Policy "default-src 'self'; object-src 'none'; style-src 'self' 'unsafe-inline'"; + add_header X-Frame-Options "SAMEORIGIN"; + + location / { + root /usr/share/nginx/html; + index index.html; + try_files $uri $uri/ /index.html; + } + + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /usr/share/nginx/html; + } + location = /resume.txt { + root /usr/share/nginx/html; + } +} diff --git a/abitibi/src/index.html b/abitibi/src/index.html new file mode 100644 index 0000000..33beccb --- /dev/null +++ b/abitibi/src/index.html @@ -0,0 +1,61 @@ + + + + + Abitibi Temiscamingue E-sports + + + + + + + + + +
+

+ Abitibi Temiscamingue E-sports. +

+
+ + + diff --git a/infra/manifests/ingress.yaml b/infra/manifests/ingress.yaml index afa4f11..6f09b36 100644 --- a/infra/manifests/ingress.yaml +++ b/infra/manifests/ingress.yaml @@ -11,6 +11,9 @@ spec: - defiant.momoperes.ca - charts.momoperes.ca secretName: momoperes.ca-wildcard-tls + - hosts: + - abitibitemiscamingueesports.club + secretName: abitibi-wildcard-tls rules: - host: momoperes.ca http: @@ -22,7 +25,7 @@ spec: - path: /files backend: serviceName: website-files - servicePort: 9000 + servicePort: 9000 - host: defiant.momoperes.ca http: paths: @@ -37,3 +40,10 @@ spec: backend: serviceName: chartmuseum servicePort: 8080 + - host: abitibitemiscamingueesports.club + http: + paths: + - path: / + backend: + serviceName: abitibi + servicePort: 9000