From 3ce71a668295abfd7c26409502f390bc1a856306 Mon Sep 17 00:00:00 2001 From: ducoterra Date: Sat, 16 May 2020 12:19:36 -0400 Subject: [PATCH] add gitlab ci --- .gitlab-ci.yml | 38 ++++++++++++++++++++++++++++ docker-compose.yaml | 2 +- helm/.helmignore | 23 +++++++++++++++++ helm/Chart.yaml | 23 +++++++++++++++++ {k8s => helm/templates}/deploy.yaml | 12 ++++----- {k8s/pvc => helm/templates}/pvc.yaml | 4 +-- {k8s => helm/templates}/service.yaml | 6 ++--- helm/values.yaml | 1 + server/server.properties | 6 ++--- 9 files changed, 100 insertions(+), 15 deletions(-) create mode 100644 .gitlab-ci.yml create mode 100644 helm/.helmignore create mode 100644 helm/Chart.yaml rename {k8s => helm/templates}/deploy.yaml (76%) rename {k8s/pvc => helm/templates}/pvc.yaml (76%) rename {k8s => helm/templates}/service.yaml (58%) create mode 100644 helm/values.yaml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..4d1cddd --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,38 @@ +variables: + CI_PROJECT_NAME: "minecraft" + CI_PROJECT_DIR: "." + CI_REGISTRY_IMAGE: hub.ducoterra.net/ducoterra/homer + +stages: + - build + - test + - deploy + +build: + only: + variables: + - $CI_COMMIT_TAG + stage: build + image: + name: gcr.io/kaniko-project/executor:debug + entrypoint: [""] + script: + - echo $DEPLOY + - /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG + +deploy_to_prod: + variables: + DEPLOY: prod + stage: deploy + only: + variables: + - $CI_COMMIT_TAG + image: + name: debian:10 + entrypoint: [""] + script: + - apt -qq update >> /dev/null && apt -qq install -y curl >> /dev/null + - curl -L -o /usr/local/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl + - chmod +x /usr/local/bin/kubectl + - curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash + - helm template $CI_PROJECT_NAME --set tag=1.1.1 ./helm | kubectl apply -f - \ No newline at end of file diff --git a/docker-compose.yaml b/docker-compose.yaml index 12818a5..50000b8 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -3,7 +3,7 @@ version: '3' services: minecraft: build: . - image: hub.ducoterra.net/ducoterra/minecraft:1.15.2 + image: hub.ducoterra.net/ducoterra/minecraft:1.15.2_1 ports: - 25565:25565 volumes: diff --git a/helm/.helmignore b/helm/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/helm/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/helm/Chart.yaml b/helm/Chart.yaml new file mode 100644 index 0000000..52c1320 --- /dev/null +++ b/helm/Chart.yaml @@ -0,0 +1,23 @@ +apiVersion: v2 +name: charts +description: A Helm chart for Kubernetes + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 0.1.0 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +appVersion: 1.16.0 diff --git a/k8s/deploy.yaml b/helm/templates/deploy.yaml similarity index 76% rename from k8s/deploy.yaml rename to helm/templates/deploy.yaml index c33249a..0ecf55a 100644 --- a/k8s/deploy.yaml +++ b/helm/templates/deploy.yaml @@ -1,19 +1,19 @@ apiVersion: apps/v1 kind: Deployment metadata: - name: minecraft + name: {{ .Release.Name }} spec: selector: matchLabels: - app: minecraft + app: {{ .Release.Name }} template: metadata: labels: - app: minecraft + app: {{ .Release.Name }} spec: containers: - - name: minecraft - image: hub.ducoterra.net/ducoterra/minecraft:1.15.2 + - name: {{ .Release.Name }} + image: {{ .Values.image }} ports: - containerPort: 25565 volumeMounts: @@ -38,4 +38,4 @@ spec: volumes: - name: data persistentVolumeClaim: - claimName: minecraft + claimName: {{ .Release.Name }} diff --git a/k8s/pvc/pvc.yaml b/helm/templates/pvc.yaml similarity index 76% rename from k8s/pvc/pvc.yaml rename to helm/templates/pvc.yaml index 5765652..a745357 100644 --- a/k8s/pvc/pvc.yaml +++ b/helm/templates/pvc.yaml @@ -1,11 +1,11 @@ apiVersion: v1 kind: PersistentVolumeClaim metadata: - name: minecraft + name: {{ .Release.Name }} spec: storageClassName: nfs-encrypted accessModes: - ReadWriteMany resources: requests: - storage: 64Gi \ No newline at end of file + storage: 32Gi \ No newline at end of file diff --git a/k8s/service.yaml b/helm/templates/service.yaml similarity index 58% rename from k8s/service.yaml rename to helm/templates/service.yaml index 0db9f16..8d6dba2 100644 --- a/k8s/service.yaml +++ b/helm/templates/service.yaml @@ -1,12 +1,12 @@ apiVersion: v1 kind: Service metadata: - name: minecraft + name: {{ .Release.Name }} spec: selector: - app: minecraft + app: {{ .Release.Name }} ports: - port: 25565 targetPort: 25565 - name: minecraft + name: {{ .Release.Name }} type: LoadBalancer \ No newline at end of file diff --git a/helm/values.yaml b/helm/values.yaml new file mode 100644 index 0000000..d293fa0 --- /dev/null +++ b/helm/values.yaml @@ -0,0 +1 @@ +image: hub.ducoterra.net/ducoterra/minecraft:1.15.2_1 \ No newline at end of file diff --git a/server/server.properties b/server/server.properties index 9aec811..8bfda80 100644 --- a/server/server.properties +++ b/server/server.properties @@ -13,7 +13,7 @@ spawn-monsters=true op-permission-level=4 pvp=true snooper-enabled=true -level-type=default +level-type=amplified hardcore=false enable-command-block=false max-players=20 @@ -25,13 +25,13 @@ server-ip= spawn-npcs=true allow-flight=true level-name=world -view-distance=10 +view-distance=20 resource-pack= spawn-animals=true white-list=true generate-structures=true online-mode=true -max-build-height=256 +max-build-height=512 level-seed= prevent-proxy-connections=false use-native-transport=true