diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2d6a6a5..062c53d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,6 +1,7 @@ variables: WEBSITE_SRC: ${CI_PROJECT_DIR}/website INFRA_SRC: ${CI_PROJECT_DIR}/infra + TEAMSPEAK_SRC: ${CI_PROJECT_DIR}/teamspeak IMAGE_PREFIX: registry.gitlab.com/momothereal/momoperes.ca WEBSITE_IMAGE: ${IMAGE_PREFIX}/website @@ -66,3 +67,21 @@ infra:deploy: - master changes: - infra/**/* + +teamspeak: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 ${TEAMSPEAK_SRC}/chart + - mkdir -p manifests/ + - helm template ./teamspeak/ --output-dir manifests/ --name teamspeak -f ./teamspeak/values.yaml + - kubectl apply --namespace ${DEPLOY_NAMESPACE} -R -f manifests/ + only: + refs: + - master + changes: + - teamspeak/**/* diff --git a/teamspeak/.gitignore b/teamspeak/.gitignore new file mode 100644 index 0000000..a9a9780 --- /dev/null +++ b/teamspeak/.gitignore @@ -0,0 +1,2 @@ +.idea/ +chart/teamspeak/manifests/ diff --git a/teamspeak/chart/teamspeak/Chart.yaml b/teamspeak/chart/teamspeak/Chart.yaml new file mode 100644 index 0000000..d34b7cf --- /dev/null +++ b/teamspeak/chart/teamspeak/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v1 +description: teamspeak +engine: gotpl +name: teamspeak +version: 0.1.0 +appVersion: 3.9.1 diff --git a/teamspeak/chart/teamspeak/templates/deployment.yaml b/teamspeak/chart/teamspeak/templates/deployment.yaml new file mode 100644 index 0000000..5d44d9a --- /dev/null +++ b/teamspeak/chart/teamspeak/templates/deployment.yaml @@ -0,0 +1,66 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Release.Name }} + labels: + app: teamspeak + chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + replicas: 1 + selector: + matchLabels: + app: teamspeak + 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: teamspeak + 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: teamspeak-server + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - containerPort: 9987 + protocol: UDP + resources: +{{ toYaml .Values.resources | indent 12 }} + env: + - name: TS3SERVER_LICENSE + value: accept + volumeMounts: + - mountPath: /var/ts3server/ + name: teamspeak-data + imagePullSecrets: + - name: {{ .Values.image.pullSecret }} + volumes: + - name: teamspeak-data + {{- if .Values.persistence.enabled }} + persistentVolumeClaim: + claimName: {{ .Values.persistence.existingClaim | default (printf "%s-%s" (.Release.Name) "data") | quote }} + {{- else }} + emptyDir: {} + {{- end }} diff --git a/teamspeak/chart/teamspeak/templates/pvc.yaml b/teamspeak/chart/teamspeak/templates/pvc.yaml new file mode 100644 index 0000000..826bc3e --- /dev/null +++ b/teamspeak/chart/teamspeak/templates/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/teamspeak/chart/teamspeak/templates/service.yaml b/teamspeak/chart/teamspeak/templates/service.yaml new file mode 100644 index 0000000..de60541 --- /dev/null +++ b/teamspeak/chart/teamspeak/templates/service.yaml @@ -0,0 +1,20 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Release.Name }} + labels: + app: teamspeak + chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + type: {{ .Values.service.type }} + ports: + - nodePort: {{ .Values.service.nodePort }} + targetPort: 9987 + protocol: UDP + name: teamspeak-voice + port: 9987 + selector: + app: teamspeak + release: {{ .Release.Name }} diff --git a/teamspeak/chart/teamspeak/values.yaml b/teamspeak/chart/teamspeak/values.yaml new file mode 100644 index 0000000..e49cc3f --- /dev/null +++ b/teamspeak/chart/teamspeak/values.yaml @@ -0,0 +1,30 @@ +image: + repository: teamspeak + tag: 3.9.1 + pullPolicy: Always + +podAnnotations: {} + +service: + type: LoadBalancer + nodePort: 30987 + +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