Skip to content
Snippets Groups Projects
Commit 881bade8 authored by maik.schaefer's avatar maik.schaefer
Browse files

add sre ci building blocks to CI and rename helm chart

parent 57f3c261
No related branches found
No related tags found
No related merge requests found
Showing
with 54 additions and 75 deletions
# Kaniko is used for building images in kubernetes.
# For more information see: https://docs.gitlab.com/ee/ci/docker/using_kaniko.html
build:
stage: build
image:
name: gcr.io/kaniko-project/executor:debug
# entrypoint needs to be overridden see: https://docs.gitlab.com/ee/ci/docker/using_kaniko.html
entrypoint: [""]
script:
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
- /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
tags:
- kubernetes
upload Helm Chart:
stage: build
image: alpine/helm:3.5.3
rules:
- if: $CI_MERGE_REQUEST_ID
when: never
- if: '$CI_COMMIT_BRANCH == "main"'
when: on_success
variables:
TAG_NAME: stable
- if: '$CI_COMMIT_BRANCH == "develop"'
when: on_success
variables:
TAG_NAME: latest
script:
- HELM_TAG=$(grep -E -o "(version:)(.*)" helm/manifest-service/Chart.yaml | sed -E 's/.*version:[[:space:]](.*)/\1/g')
- export HELM_EXPERIMENTAL_OCI=1
- helm registry login registry.open-xchange.com -u "$OX_REGISTRY_USER" -p "$OX_REGISTRY_TOKEN"
- helm chart save helm/manifest-service registry.open-xchange.com//frontend/manifest-service:$TAG_NAME
- helm chart save helm/manifest-service registry.open-xchange.com//frontend/manifest-service
- helm chart push registry.open-xchange.com//frontend/manifest-service:$TAG_NAME
- helm chart push registry.open-xchange.com//frontend/manifest-service:$HELM_TAG
tags:
- kubernetes
include:
- project: 'sre/ci-building-blocks'
file: '/gitlab-ci/node/kaniko.yml'
# Helm is used for deploying everything to kubernetes
# Afterwards we do a rolling restart of our deployment
......
apiVersion: v2
name: manifest-service
description: A Helm chart for Kubernetes
name: core-manifest-service
description: Helm chart for core manifest service
# A chart can be either an 'application' or a 'library' chart.
#
......@@ -15,7 +15,7 @@ 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
version: 0.2.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
......
......@@ -6,16 +6,16 @@
{{- end }}
{{- end }}
{{- else if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "manifest-service.fullname" . }})
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "core-manifest-service.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "manifest-service.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "manifest-service.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "core-manifest-service.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "core-manifest-service.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
echo http://$SERVICE_IP:{{ .Values.service.port }}
{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "manifest-service.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "core-manifest-service.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
......
{{/*
Expand the name of the chart.
*/}}
{{- define "manifest-service.name" -}}
{{- define "core-manifest-service.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}
......@@ -10,7 +10,7 @@ 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 "manifest-service.fullname" -}}
{{- define "core-manifest-service.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
......@@ -26,16 +26,16 @@ If release name contains chart name it will be used as a full name.
{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "manifest-service.chart" -}}
{{- define "core-manifest-service.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}
{{/*
Common labels
*/}}
{{- define "manifest-service.labels" -}}
helm.sh/chart: {{ include "manifest-service.chart" . }}
{{ include "manifest-service.selectorLabels" . }}
{{- define "core-manifest-service.labels" -}}
helm.sh/chart: {{ include "core-manifest-service.chart" . }}
{{ include "core-manifest-service.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
......@@ -45,17 +45,17 @@ app.kubernetes.io/managed-by: {{ .Release.Service }}
{{/*
Selector labels
*/}}
{{- define "manifest-service.selectorLabels" -}}
app.kubernetes.io/name: {{ include "manifest-service.name" . }}
{{- define "core-manifest-service.selectorLabels" -}}
app.kubernetes.io/name: {{ include "core-manifest-service.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
{{/*
Create the name of the service account to use
*/}}
{{- define "manifest-service.serviceAccountName" -}}
{{- define "core-manifest-service.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "manifest-service.fullname" .) .Values.serviceAccount.name }}
{{- default (include "core-manifest-service.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
......
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "manifest-service.fullname" . }}
name: {{ include "core-manifest-service.fullname" . }}
data:
urls.yaml: |
manifests:
......
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "manifest-service.fullname" . }}
name: {{ include "core-manifest-service.fullname" . }}
labels:
{{- include "manifest-service.labels" . | nindent 4 }}
{{- include "core-manifest-service.labels" . | nindent 4 }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "manifest-service.selectorLabels" . | nindent 6 }}
{{- include "core-manifest-service.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
......@@ -18,13 +18,13 @@ spec:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "manifest-service.selectorLabels" . | nindent 8 }}
{{- include "core-manifest-service.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "manifest-service.serviceAccountName" . }}
serviceAccountName: {{ include "core-manifest-service.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
......@@ -53,7 +53,7 @@ spec:
volumes:
- name: manifest-config
configMap:
name: {{ include "manifest-service.fullname" . }}
name: {{ include "core-manifest-service.fullname" . }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
......
......@@ -2,14 +2,14 @@
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "manifest-service.fullname" . }}
name: {{ include "core-manifest-service.fullname" . }}
labels:
{{- include "manifest-service.labels" . | nindent 4 }}
{{- include "core-manifest-service.labels" . | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "manifest-service.fullname" . }}
name: {{ include "core-manifest-service.fullname" . }}
minReplicas: {{ .Values.autoscaling.minReplicas }}
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
metrics:
......
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "manifest-service.fullname" . -}}
{{- $fullName := include "core-manifest-service.fullname" . -}}
{{- $svcPort := .Values.service.port -}}
{{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1beta1
......@@ -10,7 +10,7 @@ kind: Ingress
metadata:
name: {{ $fullName }}
labels:
{{- include "manifest-service.labels" . | nindent 4 }}
{{- include "core-manifest-service.labels" . | nindent 4 }}
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
......
apiVersion: v1
kind: Service
metadata:
name: {{ include "manifest-service.fullname" . }}
name: {{ include "core-manifest-service.fullname" . }}
labels:
{{- include "manifest-service.labels" . | nindent 4 }}
{{- include "core-manifest-service.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
......@@ -12,4 +12,4 @@ spec:
protocol: TCP
name: http
selector:
{{- include "manifest-service.selectorLabels" . | nindent 4 }}
{{- include "core-manifest-service.selectorLabels" . | nindent 4 }}
......@@ -2,9 +2,9 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "manifest-service.serviceAccountName" . }}
name: {{ include "core-manifest-service.serviceAccountName" . }}
labels:
{{- include "manifest-service.labels" . | nindent 4 }}
{{- include "core-manifest-service.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
......
apiVersion: v1
kind: Pod
metadata:
name: "{{ include "manifest-service.fullname" . }}-test-connection"
name: "{{ include "core-manifest-service.fullname" . }}-test-connection"
labels:
{{- include "manifest-service.labels" . | nindent 4 }}
{{- include "core-manifest-service.labels" . | nindent 4 }}
annotations:
"helm.sh/hook": test
spec:
......@@ -11,5 +11,5 @@ spec:
- name: wget
image: busybox
command: ['wget']
args: ['{{ include "manifest-service.fullname" . }}:{{ .Values.service.port }}']
args: ['{{ include "core-manifest-service.fullname" . }}:{{ .Values.service.port }}']
restartPolicy: Never
# Default values for manifest-service.
# Default values for core-manifest-service.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
......@@ -7,7 +7,7 @@ replicaCount: 1
containerPort: 8080
image:
repository: gitlab.open-xchange.com:4567/frontend/infrastructure/manifest-service
repository: gitlab.open-xchange.com:4567/frontend/infrastructure/core-manifest-service
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: ""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment