From ab2ef9208f2f075bd070ef37e9e3f3235050e351 Mon Sep 17 00:00:00 2001 From: vDawgg Date: Fri, 22 Jul 2022 13:28:14 +0200 Subject: [PATCH 1/5] Kubernetes deployment cluster-thruster --- kubernetes/thruster.yml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 kubernetes/thruster.yml diff --git a/kubernetes/thruster.yml b/kubernetes/thruster.yml new file mode 100644 index 0000000..8d5ed0e --- /dev/null +++ b/kubernetes/thruster.yml @@ -0,0 +1,32 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: cluster-thruster +spec: + selector: + matchLabels: + app: cluster-thruster + template: + metadata: + labels: + app: cluster-thruster + spec: + containers: + - name: server + image: cluster-thruster + ports: + - containerPort: 8080 +--- +apiVersion: v1 +kind: Service +metadata: + name: cluster-thruster-external +spec: + type: NodePort + selector: + run: cluster-thruster + ports: + - name: http + protocol: TCP + port: 8080 + targetPort: 8080 From 811dba234f604a3dc0c570930e105687aa5bfccb Mon Sep 17 00:00:00 2001 From: vDawgg Date: Fri, 22 Jul 2022 13:29:19 +0200 Subject: [PATCH 2/5] Kubernetes deployment mongodb --- kubernetes/mongo_db.yml | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 kubernetes/mongo_db.yml diff --git a/kubernetes/mongo_db.yml b/kubernetes/mongo_db.yml new file mode 100644 index 0000000..f2e9a6a --- /dev/null +++ b/kubernetes/mongo_db.yml @@ -0,0 +1,35 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: mongodb-deployment + labels: + app: mongodb +spec: + replicas: 1 + selector: + matchLabels: + app: mongodb + template: + metadata: + labels: + app: mongodb + spec: + containers: + - name: mongodb + image: mongo + ports: + - containerPort: 27017 + +--- +apiVersion: v1 +kind: Service +metadata: + name: mongodb-service +spec: + type: LoadBalancer + selector: + app: mongodb + ports: + - protocol: TCP + port: 27017 + targetPort: 27017 \ No newline at end of file From bdbf902120ecfc2ceaead66baf4a6c7648f698e8 Mon Sep 17 00:00:00 2001 From: vDawgg Date: Fri, 22 Jul 2022 13:30:22 +0200 Subject: [PATCH 3/5] Skaffold --- skaffold.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 skaffold.yml diff --git a/skaffold.yml b/skaffold.yml new file mode 100644 index 0000000..2a2f06c --- /dev/null +++ b/skaffold.yml @@ -0,0 +1,28 @@ +apiVersion: skaffold/v2beta29 +kind: Config +metadata: + name: app +build: + artifacts: + - image: cluster-thruster + context: . +deploy: + kubectl: + manifests: + - ./kubernetes/mongo_db.yml + - ./kubernetes/thruster.yml +profiles: + # "gcb" profile allows building and pushing the images + # on Google Container Builder without requiring docker + # installed on the developer machine. However, note that + # since GCB does not cache the builds, each build will + # start from scratch and therefore take a long time. + # + # This is not used by default. To use it, run: + # skaffold run -p gcb + - name: gcb + build: + googleCloudBuild: + diskSizeGb: 300 + machineType: N1_HIGHCPU_32 + timeout: 4000s \ No newline at end of file From e0a6a4422d7d5ae2592a7c313f34fecfb1dd6ca8 Mon Sep 17 00:00:00 2001 From: vDawgg <83905032+vDawgg@users.noreply.github.com> Date: Sat, 23 Jul 2022 17:35:17 +0200 Subject: [PATCH 4/5] Fixed issue exposing api. --- kubernetes/mongo_db.yml | 1 - kubernetes/thruster.yml | 10 +++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/kubernetes/mongo_db.yml b/kubernetes/mongo_db.yml index f2e9a6a..4a231ad 100644 --- a/kubernetes/mongo_db.yml +++ b/kubernetes/mongo_db.yml @@ -26,7 +26,6 @@ kind: Service metadata: name: mongodb-service spec: - type: LoadBalancer selector: app: mongodb ports: diff --git a/kubernetes/thruster.yml b/kubernetes/thruster.yml index 8d5ed0e..393ca0a 100644 --- a/kubernetes/thruster.yml +++ b/kubernetes/thruster.yml @@ -5,14 +5,14 @@ metadata: spec: selector: matchLabels: - app: cluster-thruster + run: cluster-thruster template: metadata: labels: - app: cluster-thruster + run: cluster-thruster spec: containers: - - name: server + - name: cluster-thruster image: cluster-thruster ports: - containerPort: 8080 @@ -22,11 +22,11 @@ kind: Service metadata: name: cluster-thruster-external spec: - type: NodePort + clusterIP: 10.102.68.76 + type: LoadBalancer selector: run: cluster-thruster ports: - name: http protocol: TCP port: 8080 - targetPort: 8080 From 8610906f364f4c319f3e79c60a5b941114268bf4 Mon Sep 17 00:00:00 2001 From: yesoer Date: Sun, 24 Jul 2022 09:00:24 +0200 Subject: [PATCH 5/5] init helm chart --- charts/.helmignore | 23 +++++++ charts/Chart.yaml | 16 +++++ charts/templates/_helpers.tpl | 62 +++++++++++++++++++ {kubernetes => charts/templates}/mongo_db.yml | 0 charts/templates/tests/test-connection.yaml | 15 +++++ {kubernetes => charts/templates}/thruster.yml | 0 charts/values.yaml | 9 +++ 7 files changed, 125 insertions(+) create mode 100644 charts/.helmignore create mode 100644 charts/Chart.yaml create mode 100644 charts/templates/_helpers.tpl rename {kubernetes => charts/templates}/mongo_db.yml (100%) create mode 100644 charts/templates/tests/test-connection.yaml rename {kubernetes => charts/templates}/thruster.yml (100%) create mode 100644 charts/values.yaml diff --git a/charts/.helmignore b/charts/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/charts/.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/charts/Chart.yaml b/charts/Chart.yaml new file mode 100644 index 0000000..74f5c4e --- /dev/null +++ b/charts/Chart.yaml @@ -0,0 +1,16 @@ +apiVersion: v2 +name: cluster-thruster +description: A helm chart for the cluster thruster api, which starts the server, aswell as a mongodb instance + +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. +# It is recommended to use it with quotes. +appVersion: "1.16.0" diff --git a/charts/templates/_helpers.tpl b/charts/templates/_helpers.tpl new file mode 100644 index 0000000..96c9c5d --- /dev/null +++ b/charts/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "cluster-thruster.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 "cluster-thruster.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 "cluster-thruster.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "cluster-thruster.labels" -}} +helm.sh/chart: {{ include "cluster-thruster.chart" . }} +{{ include "cluster-thruster.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "cluster-thruster.selectorLabels" -}} +app.kubernetes.io/name: {{ include "cluster-thruster.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "cluster-thruster.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "cluster-thruster.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/kubernetes/mongo_db.yml b/charts/templates/mongo_db.yml similarity index 100% rename from kubernetes/mongo_db.yml rename to charts/templates/mongo_db.yml diff --git a/charts/templates/tests/test-connection.yaml b/charts/templates/tests/test-connection.yaml new file mode 100644 index 0000000..851533f --- /dev/null +++ b/charts/templates/tests/test-connection.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "cluster-thruster.fullname" . }}-test-connection" + labels: + {{- include "cluster-thruster.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ include "cluster-thruster.fullname" . }}:{{ .Values.service.port }}'] + restartPolicy: Never diff --git a/kubernetes/thruster.yml b/charts/templates/thruster.yml similarity index 100% rename from kubernetes/thruster.yml rename to charts/templates/thruster.yml diff --git a/charts/values.yaml b/charts/values.yaml new file mode 100644 index 0000000..146620b --- /dev/null +++ b/charts/values.yaml @@ -0,0 +1,9 @@ +# Default values configuration for the cluster thruster backend. +# Feel free to create your own version according to your requirements +# +# As for naming conventions: +# - start with lower case letters +# - use camelcase +# +# For every property in this file we expect you write a docstring with a short +# explanation on said property