Skip to content
Snippets Groups Projects
Commit 683d846bcd3e authored by Fabio Huser's avatar Fabio Huser
Browse files

Sync trailing slash usage for GitLab KAS routes

The GitLab Nginx templates uses the non-changeable routes `-/kubernetes-agent/`
and `-/kubernetes-agent/k8s-proxy/` for KAS/KAS K8s API proxy forwarding.
Both routes use trailing slashes while the GitLab rails configuration by default
generates routes without trailing slashes. This will cause GitLab to generate a
KAS configuration with invalid target URL, causing a connection failure as the
server returns a HTTP 301 instead of 101. This commit syncs the temples to
consistently using a trailing slash. Besides that, two other minor points
were addressed:

- The `gitlab_kas_external_k8s_proxy_url` example in `gitlab.rb.template`
  wrongly used the `wss://` schema but is in fact a reverse proxy for a K8s API.
  This was corrected to use `https://` instead.
- The inline comment in `gitlab_kas.rb` used a wrong path reference. This was
  corrected as well

Changelog: fixed
parent 63a6c1ceb91c
No related branches found
No related tags found
2 merge requests!65heptapod#658: intermediate release to test the shift,!64GitLab 14.8
......@@ -1735,5 +1735,5 @@
##! Settings used by the GitLab application
# gitlab_rails['gitlab_kas_enabled'] = true
# gitlab_rails['gitlab_kas_external_url'] = ws://gitlab.example.com/-/kubernetes-agent
# gitlab_rails['gitlab_kas_external_url'] = ws://gitlab.example.com/-/kubernetes-agent/
# gitlab_rails['gitlab_kas_internal_url'] = grpc://localhost:8153
......@@ -1739,5 +1739,5 @@
# gitlab_rails['gitlab_kas_internal_url'] = grpc://localhost:8153
# gitlab_rails['gitlab_kas_external_k8s_proxy_url'] = ws://gitlab.example.com/-/kubernetes-agent
# gitlab_rails['gitlab_kas_external_k8s_proxy_url'] = https://gitlab.example.com/-/kubernetes-agent/
##! Enable GitLab KAS
# gitlab_kas['enable'] = true
......
......@@ -48,7 +48,7 @@
return unless Gitlab['external_url']
# For now, the default external URL is on the subpath /-/kubernetes-agent
# For now, the default external URL is on the subpath /-/kubernetes-agent/
# so whether to use TLS is determined from the primary external_url.
# See https://gitlab.com/gitlab-org/omnibus-gitlab/-/issues/5784
gitlab_uri = URI(Gitlab['external_url'])
......@@ -63,7 +63,7 @@
raise "external_url scheme should be 'http' or 'https', got '#{gitlab_uri.scheme}"
end
Gitlab['gitlab_rails'][key] = "#{scheme}://#{gitlab_uri.host}#{port}/#{gitlab_uri.path}-/kubernetes-agent"
Gitlab['gitlab_rails'][key] = "#{scheme}://#{gitlab_uri.host}#{port}/#{gitlab_uri.path}-/kubernetes-agent/"
end
def parse_gitlab_kas_internal_url
......@@ -93,5 +93,5 @@
gitlab_external_url = Gitlab['external_url']
return unless gitlab_external_url
# For now, the default external proxy URL is on the subpath /-/kubernetes-agent/proxy
# For now, the default external proxy URL is on the subpath /-/kubernetes-agent/k8s-proxy/
# See https://gitlab.com/gitlab-org/omnibus-gitlab/-/issues/5784
......@@ -97,5 +97,5 @@
# See https://gitlab.com/gitlab-org/omnibus-gitlab/-/issues/5784
Gitlab['gitlab_rails'][key] = "#{gitlab_external_url}/-/kubernetes-agent/k8s-proxy"
Gitlab['gitlab_rails'][key] = "#{gitlab_external_url}/-/kubernetes-agent/k8s-proxy/"
end
def parse_secrets
......
......@@ -141,5 +141,5 @@
it 'renders gitlab_kas enabled with default URLs in config/gitlab.yml' do
expect(gitlab_yml[:production][:gitlab_kas]).to include(
enabled: true,
external_url: 'wss://gitlab.example.com/-/kubernetes-agent',
external_url: 'wss://gitlab.example.com/-/kubernetes-agent/',
internal_url: 'grpc://localhost:8153',
......@@ -145,5 +145,5 @@
internal_url: 'grpc://localhost:8153',
external_k8s_proxy_url: 'https://gitlab.example.com/-/kubernetes-agent/k8s-proxy'
external_k8s_proxy_url: 'https://gitlab.example.com/-/kubernetes-agent/k8s-proxy/'
)
end
end
......@@ -160,7 +160,7 @@
it 'has exernal URL with scheme `ws` instead of `wss`' do
expect(gitlab_yml[:production][:gitlab_kas]).to include(
external_url: 'ws://gitlab.example.com/-/kubernetes-agent'
external_url: 'ws://gitlab.example.com/-/kubernetes-agent/'
)
end
end
......@@ -180,5 +180,5 @@
it 'derives the external URLs from the top level external URL, and the internal URL from the listen address' do
expect(gitlab_yml[:production][:gitlab_kas]).to include(
enabled: true,
external_url: 'wss://gitlab.example.com/-/kubernetes-agent',
external_url: 'wss://gitlab.example.com/-/kubernetes-agent/',
internal_url: 'grpc://custom-api-address:9999',
......@@ -184,5 +184,5 @@
internal_url: 'grpc://custom-api-address:9999',
external_k8s_proxy_url: 'https://gitlab.example.com/-/kubernetes-agent/k8s-proxy'
external_k8s_proxy_url: 'https://gitlab.example.com/-/kubernetes-agent/k8s-proxy/'
)
end
end
......
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