Error auto deploy on Gitlab to Rancher Kubernetes
Hi,
I have config auto deploy my project (template chart: auto-deploy-aspnetcore) from Gitlab to Rancher Kubernetes
I get this error in pipelines
Running with gitlab-runner 13.7.0 (943fc252)
on gitlab-gitlab-runner-6d654d79bf-2br4d eoUoyzGF
Preparing the "kubernetes" executor
00:00
Using Kubernetes namespace: 3s-git-prod
WARNING: Pulling GitLab Runner helper image from Docker Hub. Helper image is migrating to registry.gitlab.com, for more information see https://docs.gitlab.com/runner/configuration/advanced-configuration.html#migrating-helper-image-to-registrygitlabcom
Using Kubernetes executor with image registry.gitlab.com/gitlab-org/cluster-integration/auto-deploy-image:v2.1.0 ...
Preparing environment
00:03
Waiting for pod 3s-git-prod/runner-eouoyzgf-project-495-concurrent-0q85hx to be running, status is Pending
Running on runner-eouoyzgf-project-495-concurrent-0q85hx via gitlab-gitlab-runner-6d654d79bf-2br4d...
Getting source from Git repository
00:02
Fetching changes with git depth set to 50...
Initialized empty Git repository in /builds/evn/20-exa/.git/
Created fresh repository.
Checking out cb0f3cab as develop...
Skipping Git submodules setup
Executing "step_script" stage of the job script
00:16
$ auto-deploy check_kube_domain
$ auto-deploy download_chart
"stable" has been added to your repositories
"bitnami" has been added to your repositories
Adding Helm chart repository '3s-charts'
"3s-charts" has been added to your repositories
Downloading remote chart '3s-charts/auto-deploy-aspnetcore'...
$ auto-deploy ensure_namespace
NAME STATUS AGE
20-exa-dev Active 16h
$ auto-deploy initialize_tiller
Deprecated: Helm 3 does not have Tiller.
$ auto-deploy create_secret
Create secret...
secret "gitlab-registry-evn-20-exa" deleted
secret/gitlab-registry-evn-20-exa replaced
$ auto-deploy deploy
Validating chart version...
Fetching the previously deployed chart version...
Fetching the deploying chart version...
secret "api-secret" deleted
secret/api-secret replaced
Using helm values file '.devops/2-deploy/values.yaml'
Deploying new stable release...
Release "api" does not exist. Installing it now.
Error: template: auto-deploy-aspnetcore/templates/deployment.yaml:82:7: executing "auto-deploy-aspnetcore/templates/deployment.yaml" at <eq .Values.livenessProbe.probeType "httpGet">: error calling eq: invalid type for comparison
Uploading artifacts for failed job
00:00
Uploading artifacts...
WARNING: environment_url.txt: no matching files
WARNING: tiller.log: no matching files
ERROR: No files to upload
Cleaning up file based variables
00:01
ERROR: Job failed: command terminated with exit code 1
This is content of gitlab-ci.yml
include:
- template: Auto-DevOps.gitlab-ci.yml
variables:
DOCKERFILE_PATH: .devops/1-build/Dockerfile
SRC_PATH: .
PROJECT_CPJ: EVN.API/EVN.API.csproj
# Config to use ASPNET Core from Helm Charts repo
AUTO_DEVOPS_CHART: 3s-charts/auto-deploy-aspnetcore
TEST_DISABLED: "true"
CODE_QUALITY_DISABLED: "true"
LICENSE_MANAGEMENT_DISABLED: "true"
PERFORMANCE_DISABLED: "true"
LOAD_PERFORMANCE_DISABLED: "true"
SAST_DISABLED: "true"
SECRET_DETECTION_DISABLED: "true"
DEPENDENCY_SCANNING_DISABLED: "true"
CONTAINER_SCANNING_DISABLED: "true"
DAST_DISABLED: "true"
POSTGRES_ENABLED: "false"
KUBE_INGRESS_BASE_DOMAIN: dev.abc.xyz
HELM_RELEASE_NAME: api
HELM_UPGRADE_VALUES_FILE: .devops/2-deploy/values.yaml
HELM_UPGRADE_EXTRA_ARGS: --set service.commonName=
.auto-deploy:
image: registry.gitlab.com/gitlab-org/cluster-integration/auto-deploy-image:v2.1.0
variables:
AUTO_DEVOPS_FORCE_DEPLOY_V2: 1
# Customize build job of Auto DevOps to trigger for only 'develop' or 'master' branch
build:
tags:
- kubernetes
rules:
- if: '$CI_COMMIT_BRANCH == "develop" || $CI_COMMIT_BRANCH == "master"'
review:
environment:
url: http://evn-be.$KUBE_INGRESS_BASE_DOMAIN
kubernetes:
namespace: 20-exa-dev
rules:
- if: '$CI_KUBERNETES_ACTIVE == null || $CI_KUBERNETES_ACTIVE == ""'
when: never
- if: '$CI_COMMIT_BRANCH == "develop"'
# Customize production job of Auto DevOps to use custom domain & custom kubernetes namespace
production_manual:
tags:
- kubernetes
environment:
url: http://evn-api-prod.$KUBE_INGRESS_BASE_DOMAIN
kubernetes:
namespace: production
rules:
- if: '$CI_KUBERNETES_ACTIVE == null || $CI_KUBERNETES_ACTIVE == ""'
when: never
- if: '$CI_COMMIT_BRANCH == "master" && $STAGING_ENABLED'
when: manual
# Disable incremental rollout
rollout 10%:
rules:
- when: never
rollout 25%:
rules:
- when: never
rollout 50%:
rules:
- when: never
rollout 100%:
rules:
- when: never
This is content of deployment.yamml in template chart
{{- if not .Values.application.initializeCommand -}}
apiVersion: {{ default "extensions/v1beta1" .Values.deploymentApiVersion }}
kind: Deployment
metadata:
name: {{ template "trackableappname" . }}
annotations:
{{ if .Values.gitlab.app }}app.gitlab.com/app: {{ .Values.gitlab.app | quote }}{{ end }}
{{ if .Values.gitlab.env }}app.gitlab.com/env: {{ .Values.gitlab.env | quote }}{{ end }}
labels:
app: {{ template "appname" . }}
track: "{{ .Values.application.track }}"
tier: "{{ .Values.application.tier }}"
chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
{{- if or .Values.enableSelector (eq (default "extensions/v1beta1" .Values.deploymentApiVersion) "apps/v1") }}
selector:
matchLabels:
app: {{ template "appname" . }}
track: "{{ .Values.application.track }}"
tier: "{{ .Values.application.tier }}"
release: {{ .Release.Name }}
{{- end }}
replicas: {{ .Values.replicaCount }}
{{- if .Values.strategyType }}
strategy:
type: {{ .Values.strategyType | quote }}
{{- end }}
template:
metadata:
annotations:
checksum/application-secrets: "{{ .Values.application.secretChecksum }}"
{{ if .Values.gitlab.app }}app.gitlab.com/app: {{ .Values.gitlab.app | quote }}{{ end }}
{{ if .Values.gitlab.env }}app.gitlab.com/env: {{ .Values.gitlab.env | quote }}{{ end }}
{{- if .Values.podAnnotations }}
{{ toYaml .Values.podAnnotations | indent 8 }}
{{- end }}
labels:
app: {{ template "appname" . }}
track: "{{ .Values.application.track }}"
tier: "{{ .Values.application.tier }}"
release: {{ .Release.Name }}
spec:
imagePullSecrets:
{{ toYaml .Values.image.secrets | indent 10 }}
containers:
- name: {{ .Chart.Name }}
image: {{ template "imagename" . }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
{{- if .Values.application.secretName }}
volumeMounts:
- name: appsettings
mountPath: {{ printf "/app/appsettings.%s.json" .Values.gitlab.env }}
subPath: {{ printf "appsettings.%s.json" .Values.gitlab.env }}
envFrom:
- secretRef:
name: {{ .Values.application.secretName }}
{{- end }}
env:
- name: ASPNETCORE_ENVIRONMENT
value: {{ .Values.gitlab.env | quote }}
- name: GITLAB_ENVIRONMENT_NAME
value: {{ .Values.gitlab.envName | quote }}
- name: GITLAB_ENVIRONMENT_URL
value: {{ .Values.gitlab.envURL | quote }}
{{ if .Values.podEnvironment }}{{ toYaml .Values.podEnvironment | indent 8 }}{{ end }}
ports:
- name: "{{ .Values.service.name }}"
containerPort: {{ .Values.service.internalPort }}
{{- if .Values.livenessProbe.enabled }}
livenessProbe:
tcpSocket:
port: http
initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
successThreshold: {{ .Values.livenessProbe.successThreshold }}
failureThreshold: {{ .Values.livenessProbe.failureThreshold }}
{{- else if .Values.customLivenessProbe }}
livenessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.customLivenessProbe "context" $) | nindent 12 }}
{{- end }}
{{- if .Values.readinessProbe.enabled }}
readinessProbe:
tcpSocket:
port: http
initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.readinessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
successThreshold: {{ .Values.readinessProbe.successThreshold }}
failureThreshold: {{ .Values.readinessProbe.failureThreshold }}
{{- else if .Values.customReadinessProbe }}
readinessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.customReadinessProbe "context" $) | nindent 12 }}
{{- end }}
resources:
{{ toYaml .Values.resources | indent 12 }}
{{- end -}}
{{- if .Values.application.secretName }}
volumes:
- name: appsettings
secret:
secretName: {{ .Values.application.secretName }}
items:
- key: APPSETTINGS
path: {{ printf "appsettings.%s.json" .Values.gitlab.env }}
{{- end }}
Please help me to fix error
Thanks!
Edited by Thai Tuan