namespace should be lowercased in kubernetes. This is also true for the...

namespace should be lowercased in kubernetes. This is also true for the scenario where the namespace is generated from the project group-name.
parent 4d5ea927
...@@ -153,7 +153,17 @@ class KubernetesService < DeploymentService ...@@ -153,7 +153,17 @@ class KubernetesService < DeploymentService
end end
def default_namespace def default_namespace
"#{project.path}-#{project.id}" if project.present? return unless project
# 1. lowercase
# 2. replace non kubernetes characters with dash
# 3. trim dash from the beginning and end
slugified = "#{project.path}-#{project.id}"
slugified.downcase!
slugified.gsub!(/[^a-z0-9]/, '-')
slugified.gsub!(/^-+|-+$/, '')
slugified
end end
def build_kubeclient!(api_path: 'api', api_version: 'v1') def build_kubeclient!(api_path: 'api', api_version: 'v1')
......
---
title: Auto Devops kubernetes default namespace is now correctly built out of gitlab
project group-name
merge_request: 14642
author: Mircea Danila Dumitrescu
type: fixed
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment