diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ba6f609..9196fce 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,4 +1,5 @@ variables: + CI_PROJECT_NAME: "homer" CI_PROJECT_DIR: "." CI_REGISTRY_IMAGE: hub.ducoterra.net/ducoterra/homer @@ -30,10 +31,8 @@ deploy_to_prod: name: debian:10 entrypoint: [""] script: - - apt -qq update >> /dev/null && apt -qq install -y curl gettext >> /dev/null + - apt -qq update >> /dev/null && apt -qq install -y curl >> /dev/null - curl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl + - curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash - chmod +x ./kubectl - - mkdir /deploy - - for f in $(find k8s -regex '.*\.ya*ml'); do envsubst < $f > "/deploy/$(basename $f)"; done - - for f in $(find k8s/prod -regex '.*\.ya*ml'); do envsubst < $f > "/deploy/$(basename $f)"; done - - ./kubectl apply -f /deploy \ No newline at end of file + - helm install --set tag=$CI_COMMIT_TAG $CI_PROJECT_NAME ./helm \ No newline at end of file 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..cf7bc40 --- /dev/null +++ b/helm/Chart.yaml @@ -0,0 +1,23 @@ +apiVersion: v2 +name: helm +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 66% rename from k8s/deploy.yaml rename to helm/templates/deploy.yaml index f302c66..17cb874 100644 --- a/k8s/deploy.yaml +++ b/helm/templates/deploy.yaml @@ -1,19 +1,19 @@ apiVersion: apps/v1 kind: Deployment metadata: - name: dashboard + name: {{ .Release.Name }} spec: selector: matchLabels: - app: dashboard + app: {{ .Release.Name }} template: metadata: labels: - app: dashboard + app: {{ .Release.Name }} spec: containers: - - name: dashboard - image: $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG + - name: {{ .Release.Name }} + image: {{ .Values.image }}:{{ .Values.tag }} resources: limits: memory: "128Mi" diff --git a/k8s/ingress.yaml b/helm/templates/ingress.yaml similarity index 69% rename from k8s/ingress.yaml rename to helm/templates/ingress.yaml index b186e64..17e5ec8 100644 --- a/k8s/ingress.yaml +++ b/helm/templates/ingress.yaml @@ -1,7 +1,7 @@ apiVersion: traefik.containo.us/v1alpha1 kind: IngressRoute metadata: - name: dashboard-internal-tls + name: {{ .Release.Name }}-internal-tls annotations: kubernetes.io/ingress.class: traefik-internal spec: @@ -12,10 +12,10 @@ spec: domains: - main: "*.ducoterra.net" routes: - - match: Host(`dashboard.ducoterra.net`) + - match: Host(`{{ .Release.Name }}.ducoterra.net`) kind: Rule services: - - name: dashboard + - name: {{ .Release.Name }} port: 8080 --- @@ -23,17 +23,17 @@ spec: apiVersion: traefik.containo.us/v1alpha1 kind: IngressRoute metadata: - name: dashboard-internal-web + name: {{ .Release.Name }}-internal-web annotations: kubernetes.io/ingress.class: traefik-internal spec: entryPoints: - web routes: - - match: Host(`dashboard.ducoterra.net`) + - match: Host(`{{ .Release.Name }}.ducoterra.net`) kind: Rule services: - - name: dashboard + - name: {{ .Release.Name }} port: 8080 middlewares: - name: httpsredirect \ No newline at end of file diff --git a/k8s/service.yaml b/helm/templates/service.yaml similarity index 63% rename from k8s/service.yaml rename to helm/templates/service.yaml index dac0db5..91237a6 100644 --- a/k8s/service.yaml +++ b/helm/templates/service.yaml @@ -1,10 +1,10 @@ apiVersion: v1 kind: Service metadata: - name: dashboard + name: {{ .Release.Name }} spec: selector: - app: dashboard + app: {{ .Release.Name }} ports: - port: 8080 targetPort: 8080 \ No newline at end of file diff --git a/helm/values.yaml b/helm/values.yaml new file mode 100644 index 0000000..f5a0d96 --- /dev/null +++ b/helm/values.yaml @@ -0,0 +1 @@ +image: hub.ducoterra.net/ducoterra/homer \ No newline at end of file