diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 062c53d..22849cc 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -2,9 +2,11 @@ variables: WEBSITE_SRC: ${CI_PROJECT_DIR}/website INFRA_SRC: ${CI_PROJECT_DIR}/infra TEAMSPEAK_SRC: ${CI_PROJECT_DIR}/teamspeak + DEFIANT_SRC: ${CI_PROJECT_DIR}/defiant IMAGE_PREFIX: registry.gitlab.com/momothereal/momoperes.ca WEBSITE_IMAGE: ${IMAGE_PREFIX}/website + DEFIANT_IMAGE: ${IMAGE_PREFIX}/defiant KUBECONFIG_PARENT: /etc/deploy KUBECONFIG: ${KUBECONFIG_PARENT}/config @@ -48,6 +50,8 @@ website:deploy: changes: - website/**/* +# INFRA # + infra:deploy: stage: deploy image: lwolf/helm-kubectl-docker:v1.15.4-v2.14.3 @@ -68,6 +72,8 @@ infra:deploy: changes: - infra/**/* +# TEAMSPEAK # + teamspeak:deploy: stage: deploy image: lwolf/helm-kubectl-docker:v1.15.4-v2.14.3 @@ -85,3 +91,22 @@ teamspeak:deploy: - master changes: - teamspeak/**/* + +# DEFIANT # + +defiant:release: + stage: release + image: + name: gcr.io/kaniko-project/executor:debug + entrypoint: [""] + script: + - cd ${DEFIANT_SRC}/src + - git clone https://github.com/momothereal/code-jam-2.git defiant + - cp main_config.yaml defiant/config/main_config.yaml + + - echo "Building to ${DEFIANT_IMAGE}:${CI_COMMIT_TAG}" + - echo "{\"auths\":{\"${CI_REGISTRY}\":{\"username\":\"${CI_REGISTRY_USER}\",\"password\":\"${CI_REGISTRY_PASSWORD}\"}}}" > /kaniko/.docker/config.json + - /kaniko/executor --context ${DEFIANT_SRC}/src/defiant --dockerfile ${DEFIANT_SRC}/src/defiant/Dockerfile --destination ${DEFIANT_IMAGE}:${CI_COMMIT_REF_SLUG}-${CI_COMMIT_SHORT_SHA} --destination ${DEFIANT_IMAGE}:${CI_COMMIT_REF_SLUG} + only: + changes: + - defiant/**/* \ No newline at end of file diff --git a/defiant/.gitignore b/defiant/.gitignore new file mode 100644 index 0000000..ecb1c44 --- /dev/null +++ b/defiant/.gitignore @@ -0,0 +1,2 @@ +.idea/ +chart/defiant/manifests/ diff --git a/defiant/chart/defiant/Chart.yaml b/defiant/chart/defiant/Chart.yaml new file mode 100644 index 0000000..41f7ac8 --- /dev/null +++ b/defiant/chart/defiant/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +description: DefiantSails entry for PythonDiscord code jam number 2 +engine: gotpl +name: defiant +version: 0.1.0 diff --git a/defiant/chart/defiant/templates/deployment.yaml b/defiant/chart/defiant/templates/deployment.yaml new file mode 100644 index 0000000..fe0b28d --- /dev/null +++ b/defiant/chart/defiant/templates/deployment.yaml @@ -0,0 +1,50 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Release.Name }} + labels: + app: defiant + chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + replicas: 1 + selector: + matchLabels: + app: defiant + chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} + template: + metadata: + {{- if .Values.podAnnotations }} + annotations: +{{ toYaml .Values.podAnnotations | indent 8 }} + {{- end }} + labels: + app: defiant + chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} + spec: + {{- with .Values.nodeSelector }} + nodeSelector: +{{ toYaml . | indent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: +{{ toYaml . | indent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: +{{ toYaml . | indent 8 }} + {{- end }} + containers: + - name: defiant + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - containerPort: 80 + protocol: TCP + resources: +{{ toYaml .Values.resources | indent 12 }} diff --git a/defiant/chart/defiant/templates/rethinkdb-deployment.yaml b/defiant/chart/defiant/templates/rethinkdb-deployment.yaml new file mode 100644 index 0000000..5a816d0 --- /dev/null +++ b/defiant/chart/defiant/templates/rethinkdb-deployment.yaml @@ -0,0 +1,61 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Release.Name }} + labels: + app: rethinkdb + chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + replicas: 1 + selector: + matchLabels: + app: rethinkdb + chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} + template: + metadata: + {{- if .Values.podAnnotations }} + annotations: +{{ toYaml .Values.podAnnotations | indent 8 }} + {{- end }} + labels: + app: rethinkdb + chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} + spec: + {{- with .Values.nodeSelector }} + nodeSelector: +{{ toYaml . | indent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: +{{ toYaml . | indent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: +{{ toYaml . | indent 8 }} + {{- end }} + containers: + - name: defiant + image: "rethinkdb:2.3.6" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - containerPort: 28015 + protocol: TCP + resources: +{{ toYaml .Values.resources | indent 12 }} + volumeMounts: + - mountPath: /data + name: rethinkdb-data + volumes: + - name: rethinkdb-data + {{- if .Values.persistence.enabled }} + persistentVolumeClaim: + claimName: {{ .Values.persistence.existingClaim | default (printf "%s-%s" (.Release.Name) "data") | quote }} + {{- else }} + emptyDir: {} + {{- end }} diff --git a/defiant/chart/defiant/templates/rethinkdb-pvc.yaml b/defiant/chart/defiant/templates/rethinkdb-pvc.yaml new file mode 100644 index 0000000..826bc3e --- /dev/null +++ b/defiant/chart/defiant/templates/rethinkdb-pvc.yaml @@ -0,0 +1,28 @@ +{{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim) }} +kind: PersistentVolumeClaim +apiVersion: v1 +metadata: + name: {{ .Release.Name }}-data + labels: + app: checkmk + chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} + {{- if .Values.persistence.annotations }} + annotations: +{{ toYaml .Values.persistence.annotations | indent 4 }} + {{- end }} +spec: + accessModes: + - {{ .Values.persistence.accessMode | quote }} + resources: + requests: + storage: {{ .Values.persistence.storageSize | quote }} + {{- if .Values.persistence.storageClass }} + {{- if (eq "-" .Values.persistence.storageClass) }} + storageClassName: "" + {{- else }} + storageClassName: "{{ .Values.persistence.storageClass }}" + {{- end }} + {{- end }} +{{- end }} \ No newline at end of file diff --git a/defiant/chart/defiant/templates/rethinkdb-service.yaml b/defiant/chart/defiant/templates/rethinkdb-service.yaml new file mode 100644 index 0000000..fd2fbc9 --- /dev/null +++ b/defiant/chart/defiant/templates/rethinkdb-service.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Release.Name }} + labels: + app: rethinkdb + chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + type: ClusterIP + ports: + - targetPort: 28015 + protocol: TCP + name: rethinkdb + port: 28015 + selector: + app: rethinkdb + release: {{ .Release.Name }} diff --git a/defiant/chart/defiant/templates/service.yaml b/defiant/chart/defiant/templates/service.yaml new file mode 100644 index 0000000..563e027 --- /dev/null +++ b/defiant/chart/defiant/templates/service.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Release.Name }} + labels: + app: defiant + chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + type: ClusterIP + ports: + - targetPort: 80 + protocol: TCP + name: defiant-voice + port: 80 + selector: + app: defiant + release: {{ .Release.Name }} diff --git a/defiant/chart/defiant/values.yaml b/defiant/chart/defiant/values.yaml new file mode 100644 index 0000000..7c0f49d --- /dev/null +++ b/defiant/chart/defiant/values.yaml @@ -0,0 +1,26 @@ +image: + repository: registry.gitlab.com/momothereal/momoperes.ca/defiant + tag: latest + pullPolicy: Always + +podAnnotations: {} + +resources: + limits: + cpu: 250m + memory: 512Mi + requests: + cpu: 100m + memory: 256Mi + +nodeSelector: {} +tolerations: [] +affinity: {} + +persistence: + enabled: true + accessMode: ReadWriteOnce + annotations: + "helm.sh/resource-policy": keep + storageClass: do-block-storage + storageSize: 1Gi diff --git a/defiant/src/main_config.yaml b/defiant/src/main_config.yaml new file mode 100644 index 0000000..10e81ab --- /dev/null +++ b/defiant/src/main_config.yaml @@ -0,0 +1,26 @@ +web: + # Flask (web) configuration + ip: "0.0.0.0" + port: 80 + +database: + # RethinkDB configuration + ip: "rethinkdb.public" + port: 28015 + database_name: "battle_myth_theater" + +admin: + username: "admin" #Insecure, change from example credentials. + password: "admin" #Insecure, change from example credentials. + +game: + max_stat_points: 20 + +debug: true + +stories: + # Path to FFMPEG executable + ffmpeg: "/usr/bin/ffmpeg" + # Max story count per user. + # Note: this is ignored when 'debug' is set to true + max_story_count: 10