From dbd679d4eab35473c43112e2307911b9dfb5ecc5 Mon Sep 17 00:00:00 2001 From: Thong Kuah Date: Thu, 11 Feb 2021 16:03:40 +1300 Subject: [PATCH] Revert "Merge branch 'feature/add-redis-support-to-kas' into 'master'" This reverts commit 0133630b3257568f70463ed374cd7dbad80aeb06, reversing changes made to 3a6404c521519a0f12ee5e10e618bb6705123fec. --- .../charts/kas/templates/_default-config.yaml | 2 - .../gitlab/charts/kas/templates/_helpers.tpl | 22 ----- .../charts/kas/templates/deployment.yaml | 1 - charts/gitlab/charts/kas/values.yaml | 10 -- charts/gitlab/templates/_redis.tpl | 15 +-- spec/configuration/kas_spec.rb | 94 +------------------ 6 files changed, 7 insertions(+), 137 deletions(-) diff --git a/charts/gitlab/charts/kas/templates/_default-config.yaml b/charts/gitlab/charts/kas/templates/_default-config.yaml index f6cecbce97..e0a989a162 100644 --- a/charts/gitlab/charts/kas/templates/_default-config.yaml +++ b/charts/gitlab/charts/kas/templates/_default-config.yaml @@ -8,5 +8,3 @@ gitlab: observability: listen: address: ":{{ .Values.metrics.port }}" -redis: - {{- include "kas.redis" . | nindent 2 }} diff --git a/charts/gitlab/charts/kas/templates/_helpers.tpl b/charts/gitlab/charts/kas/templates/_helpers.tpl index 48aeff9573..4c758fcdf4 100644 --- a/charts/gitlab/charts/kas/templates/_helpers.tpl +++ b/charts/gitlab/charts/kas/templates/_helpers.tpl @@ -12,25 +12,3 @@ if there is a shared tls secret for all ingresses. {{- end -}} {{- pluck "secretName" .Values.ingress.tls .Values.global.ingress.tls $defaultName | first -}} {{- end -}} - -{{/* -Build Redis config for KAS -*/}} -{{- define "kas.redis" -}} -{{- if .Values.global.redis.sharedState -}} -{{- $_ := set $ "redisConfigName" "sharedState" -}} -{{- end -}} -{{- include "gitlab.redis.selectedMergedConfig" . -}} -password_file: /etc/kas/redis/{{ printf "%s-password" (default "redis" .redisConfigName) }} -{{- if not .redisMergedConfig.sentinels }} -server: - address: {{ template "gitlab.redis.host" . }}:{{ template "gitlab.redis.port" . }} -{{- else }} -sentinel: - addresses: - {{- range $i, $entry := .redisMergedConfig.sentinels }} - - {{ quote (print (trim $entry.host) ":" ( default 26379 $entry.port | int ) ) -}} - {{ end }} - master_name: {{ template "gitlab.redis.host" . }} -{{- end -}} -{{- end -}} \ No newline at end of file diff --git a/charts/gitlab/charts/kas/templates/deployment.yaml b/charts/gitlab/charts/kas/templates/deployment.yaml index b165b84cd4..a605bc75c1 100644 --- a/charts/gitlab/charts/kas/templates/deployment.yaml +++ b/charts/gitlab/charts/kas/templates/deployment.yaml @@ -88,5 +88,4 @@ spec: items: - key: {{ template "gitlab.kas.key" . }} path: .gitlab_kas_secret - {{- include "gitlab.redis.secrets" . | nindent 12 }} {{- end }} diff --git a/charts/gitlab/charts/kas/values.yaml b/charts/gitlab/charts/kas/values.yaml index 9ad54ea805..937f71138d 100644 --- a/charts/gitlab/charts/kas/values.yaml +++ b/charts/gitlab/charts/kas/values.yaml @@ -6,9 +6,6 @@ annotations: {} global: kas: enabled: false - redis: - # host: '0.0.0.0' - password: {} # hosts: # kas: # name: kas.example.com @@ -60,10 +57,3 @@ securityContext: runAsUser: 65532 runAsGroup: 65532 fsGroup: 65532 -redis: -# sentinel: -# addresses: - # - localhost:6661 # required -# server: -# address: "localhost:6379" - password: {} \ No newline at end of file diff --git a/charts/gitlab/templates/_redis.tpl b/charts/gitlab/templates/_redis.tpl index 5c6c7e37fd..6fc3a89bd6 100644 --- a/charts/gitlab/templates/_redis.tpl +++ b/charts/gitlab/templates/_redis.tpl @@ -64,7 +64,11 @@ Return the password section of the Redis URI, if needed. Build the structure describing sentinels */}} {{- define "gitlab.redis.sentinels" -}} -{{- include "gitlab.redis.selectedMergedConfig" . -}} +{{- if .redisConfigName }} +{{- $_ := set . "redisMergedConfig" ( index .Values.global.redis .redisConfigName ) -}} +{{- else -}} +{{- $_ := set . "redisMergedConfig" .Values.global.redis -}} +{{- end -}} {{- if .redisMergedConfig.sentinels -}} sentinels: {{- range $i, $entry := .redisMergedConfig.sentinels }} @@ -74,15 +78,6 @@ sentinels: {{- end -}} {{- end -}} -{{/*Set redisMergedConfig*/}} -{{- define "gitlab.redis.selectedMergedConfig" -}} -{{- if .redisConfigName }} -{{- $_ := set . "redisMergedConfig" ( index .Values.global.redis .redisConfigName ) -}} -{{- else -}} -{{- $_ := set . "redisMergedConfig" .Values.global.redis -}} -{{- end -}} -{{- end -}} - {{/* Return Sentinel list in format for Workhorse Note: Workhorse only uses the primary Redis (global.redis) diff --git a/spec/configuration/kas_spec.rb b/spec/configuration/kas_spec.rb index d10e293e39..0d8f7f250c 100644 --- a/spec/configuration/kas_spec.rb +++ b/spec/configuration/kas_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true + require 'spec_helper' -require 'hash_deep_merge' require 'helm_template_helper' require 'yaml' @@ -15,7 +15,7 @@ describe 'kas configuration' do let(:custom_secret_name) { 'kas_custom_secret_name' } let(:custom_config) { {} } - let(:default_kas_values) do + let(:kas_values) do { 'gitlab' => { 'kas' => { @@ -34,8 +34,6 @@ describe 'kas configuration' do } end - let(:kas_values) { default_kas_values } - let(:required_resources) do %w[Deployment ConfigMap Ingress Service HorizontalPodAutoscaler PodDisruptionBudget] end @@ -200,94 +198,6 @@ describe 'kas configuration' do expect(config_yaml_data['agent']['listen']['websocket']).to eq(false) end end - - describe 'redis config' do - let(:sentinels) do - { - 'redis' => { - 'host' => 'global.host', - 'sentinels' => [ - { 'host' => 'sentinel1.example.com', 'port' => 26379 }, - { 'host' => 'sentinel2.example.com', 'port' => 26379 } - ] - } - } - end - - context 'when redisConfigName is empty' do - context 'when no sentinel is setup' do - it 'takes the global redis config' do - expect(config_yaml_data['redis']).to include( - "password_file" => "/etc/kas/redis/redis-password", - "server" => { "address" => "test-redis-master.default.svc:6379" }) - end - end - - context 'when sentinel is setup' do - let(:kas_values) do - vals = default_kas_values - vals['global'].deep_merge!(sentinels) - vals.deep_merge!('redis' => { 'install' => false }) - end - - it 'takes the global sentinel redis config' do - expect(config_yaml_data['redis']).to include( - { "sentinel" => { "addresses" => ["sentinel1.example.com:26379", "sentinel2.example.com:26379"], - "master_name" => "global.host" } }) - end - end - end - - context 'when a redis sharedState is setup' do - let(:kas_values) do - vals = default_kas_values - vals['global'].deep_merge!(redis_shared_state_config) - vals.deep_merge!('redis' => { 'install' => false }) - end - let(:redis_shared_state_config) do - { - 'redis' => { - 'host' => "global.host", - 'sharedState' => { - 'host' => "shared.redis", - 'port' => "6378", - 'password' => { - 'enabled' => true, - 'secret' => "shared-secret", - 'key' => "shared-key", - }, - 'sentinels' => sentinels - } - } - } - end - context 'when no sharedState sentinel is setup' do - context 'with no sentinels' do - let(:sentinels) { {} } - it 'configures a sharedState server config' do - expect(config_yaml_data['redis']).to include( - "password_file" => "/etc/kas/redis/sharedState-password", - "server" => { "address" => "shared.redis:6378" }) - end - end - end - - context 'when sharedState sentinel is setup' do - let(:sentinels) do - [ - { 'host' => 'sentinel1.shared.com', 'port' => 26379 }, - { 'host' => 'sentinel2.shared.com', 'port' => 26379 } - ] - end - - it 'configures a sharedState sentinel config' do - expect(config_yaml_data['redis']).to include( - "password_file" => "/etc/kas/redis/sharedState-password", - "sentinel" => { "addresses" => ["sentinel1.shared.com:26379", "sentinel2.shared.com:26379"], "master_name" => "shared.redis" }) - end - end - end - end end end end -- GitLab