Skip to content

Commit c668f7c

Browse files
committed
CH-184 aliases implementation
1 parent d955a7b commit c668f7c

File tree

4 files changed

+61
-28
lines changed

4 files changed

+61
-28
lines changed

deployment-configuration/helm/templates/auto-gatekeepers.yaml

Lines changed: 36 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
apiVersion: v1
1515
kind: ConfigMap
1616
metadata:
17-
name: "{{ .app.harness.service.name }}-gk"
17+
name: "{{ .subdomain }}-gk"
1818
labels:
19-
app: "{{ .app.harness.service.name }}-gk"
19+
app: "{{ .subdomain }}-gk"
2020
data:
2121
proxy.yml: |-
2222
verbose: {{ .root.Values.debug }}
@@ -37,7 +37,7 @@ data:
3737
http-only-cookie: false
3838
tls-cert:
3939
tls-private-key:
40-
redirection-url: {{ ternary "https" "http" $tls }}://{{ .app.harness.subdomain }}.{{ .root.Values.domain }}
40+
redirection-url: {{ ternary "https" "http" $tls }}://{{ .subdomain }}.{{ .root.Values.domain }}
4141
encryption-key: AgXa7xRcoClDEU0ZDSH4X0XhL5Qy2Z2j
4242
upstream-url: http://{{ .app.harness.service.name }}.{{ .app.namespace | default .root.Release.Namespace }}:{{ .app.harness.service.port | default 80}}
4343
{{ if .app.harness.secured }}
@@ -50,6 +50,18 @@ data:
5050
skip-openid-provider-tls-verify: true
5151
skip-upstream-tls-verify: true
5252
{{- end }}
53+
cors-origins:
54+
- {{ (printf "*.%s" .root.Values.domain) | quote }}
55+
cors-methods:
56+
- GET
57+
- POST
58+
- PUT
59+
- DELETE
60+
- PATCH
61+
cors-headers:
62+
- Authorization
63+
- Content-Type
64+
- Origin
5365
cacert.crt: {{ .files.Get "resources/certs/cacert.crt" | quote }}
5466
access-denied.html.tmpl: |-
5567
<!DOCTYPE html>
@@ -79,47 +91,46 @@ data:
7991
<h2 class="message">403 Permission Denied</h2>
8092
<div class="error-details">
8193
Sorry, you do not have access to this page, please contact your administrator.
82-
If you have been assigned new authorizations, try to refresh the page or to <a href="/oauth/logout?redirect=/">login again</a>.
94+
If you are authorized to see this page, please try <a href="/">reload</a> or <a href="/oauth/logout?redirect=/">login again</a>.
8395
</div>
8496
</div>
8597
</div>
8698
</div>
8799
</div>
88-
89100
</body>
90101
</html>
91102
---
92103
apiVersion: v1
93104
kind: Service
94105
metadata:
95-
name: "{{ .app.harness.service.name }}-gk"
106+
name: "{{ .subdomain }}-gk"
96107
labels:
97-
app: "{{ .app.harness.service.name }}-gk"
108+
app: "{{ .subdomain }}-gk"
98109
spec:
99110
ports:
100111
- name: http
101112
port: 8080
102113
selector:
103-
app: "{{ .app.harness.service.name }}-gk"
114+
app: "{{ .subdomain }}-gk"
104115
type: ClusterIP
105116
---
106117
apiVersion: apps/v1
107118
kind: Deployment
108119
metadata:
109-
name: "{{ .app.harness.service.name }}-gk"
120+
name: "{{ .subdomain }}-gk"
110121
labels:
111-
app: "{{ .app.harness.service.name }}-gk"
122+
app: "{{ .subdomain }}-gk"
112123
spec:
113124
replicas: 1
114125
selector:
115126
matchLabels:
116-
app: "{{ .app.harness.service.name }}-gk"
127+
app: "{{ .subdomain }}-gk"
117128
template:
118129
metadata:
119130
annotations:
120131
checksum/config: {{ .app.harness.uri_role_mapping | toString | sha256sum }}
121132
labels:
122-
app: "{{ .app.harness.service.name }}-gk"
133+
app: "{{ .subdomain }}-gk"
123134
spec:
124135
{{ include "deploy_utils.etcHosts" .root | indent 6 }}
125136
containers:
@@ -135,13 +146,13 @@ spec:
135146
- name: PROXY_CONFIG_FILE
136147
value: /opt/proxy.yml
137148
volumeMounts:
138-
- name: "{{ .app.harness.service.name }}-gk-proxy-config"
149+
- name: "{{ .subdomain }}-gk-proxy-config"
139150
mountPath: /opt/proxy.yml
140151
subPath: proxy.yml
141-
- name: "{{ .app.harness.service.name }}-gk-proxy-config"
152+
- name: "{{ .subdomain }}-gk-proxy-config"
142153
mountPath: /etc/pki/ca-trust/source/anchors/cacert.crt
143154
subPath: cacert.crt
144-
- name: "{{ .app.harness.service.name }}-gk-proxy-config"
155+
- name: "{{ .subdomain }}-gk-proxy-config"
145156
mountPath: /templates/access-denied.html.tmpl
146157
subPath: access-denied.html.tmpl
147158
ports:
@@ -152,23 +163,28 @@ spec:
152163
resources:
153164
requests:
154165
memory: "32Mi"
155-
cpu: "50m"
166+
cpu: "5m"
156167
limits:
157168
memory: "64Mi"
158169
cpu: "100m"
159170
volumes:
160-
- name: "{{ .app.harness.service.name }}-gk-proxy-config"
171+
- name: "{{ .subdomain }}-gk-proxy-config"
161172
configMap:
162-
name: "{{ .app.harness.service.name }}-gk"
173+
name: "{{ .subdomain }}-gk"
163174
---
164175
{{- end }}
165176
{{- if .Values.secured_gatekeepers }}
166177
{{ $files := .Files }}
167178
{{- range $app := .Values.apps }}
168179
{{- if and (hasKey $app "port") ($app.harness.secured) }}
169180
---
170-
{{ include "deploy_utils.securedservice" (dict "root" $ "app" $app "files" $files) }}
181+
{{ include "deploy_utils.securedservice" (dict "root" $ "app" $app "files" $files "subdomain" $app.harness.subdomain) }}
182+
{{- end }}
183+
{{- if $app.harness.aliases }}
184+
{{- range $subdomain := $app.harness.aliases }}
185+
{{ include "deploy_utils.securedservice" (dict "root" $ "app" $app "files" $files "subdomain" $subdomain ) }}
171186
{{- end }}
187+
{{- end }}
172188
{{- range $subapp := $app }}
173189
{{- if contains "map" (typeOf $subapp) }}
174190
{{- if and (hasKey $subapp "harness.port") (hasKey $subapp "harness.secured") }}
@@ -180,4 +196,4 @@ spec:
180196
{{- end }}
181197
{{- end }}
182198
{{- end }}
183-
{{- end }}
199+
{{- end }}

deployment-configuration/helm/templates/ingress.yaml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
pathType: ImplementationSpecific
88
backend:
99
service:
10-
name: {{ .app.harness.service.name }}{{- if (and .app.harness.secured $secured_gatekeepers) }}-gk{{- end }}
10+
name: {{ if (and .app.harness.secured $secured_gatekeepers) }}{{ printf "%s-gk" .subdomain }}{{ else }}{{ .app.harness.service.name | quote }}{{ end }}
1111
port:
1212
number: {{- if (and .app.harness.secured $secured_gatekeepers) }} 8080 {{- else }} {{ .app.harness.service.port | default 80 }}{{- end }}
1313
{{- end }}
@@ -52,32 +52,32 @@ spec:
5252
{{- range $app := .Values.apps }}
5353
{{- if (and $mainapp (and $app.harness.name (eq $app.harness.name $mainapp))) }}
5454
- host: {{ $domain | quote }}
55-
{{ include "deploy_utils.ingress.http" (dict "root" $ "app" $app) }}
55+
{{ include "deploy_utils.ingress.http" (dict "root" $ "app" $app "subdomain" $app.harness.subdomain) }}
5656
{{- range $service := $app.harness.use_services }}
5757
{{ include "deploy_utils.ingress.service" (dict "root" $ "service_name" $service.name) }}
5858
{{- end }}
5959
{{- end }}
6060
{{- if $app.harness.domain }}
6161
- host: {{ $app.harness.domain | quote }}
62-
{{ include "deploy_utils.ingress.http" (dict "root" $ "app" $app) }}
62+
{{ include "deploy_utils.ingress.http" (dict "root" $ "app" $app "subdomain" $app.harness.subdomain ) }}
6363
{{- end }}
6464
{{- if $app.harness.aliases }}
6565
{{- range $alias := $app.harness.aliases }}
6666
- host: {{ printf "%s.%s" $alias $domain | quote }}
67-
{{ include "deploy_utils.ingress.http" (dict "root" $ "app" $app) }}
67+
{{ include "deploy_utils.ingress.http" (dict "root" $ "app" $app "subdomain" $alias) }}
6868
{{- end }}
6969
{{- end }}
7070
{{- if $app.harness.subdomain }}
7171
- host: {{ printf "%s.%s" $app.harness.subdomain $domain | quote }}
72-
{{ include "deploy_utils.ingress.http" (dict "root" $ "app" $app) }}
72+
{{ include "deploy_utils.ingress.http" (dict "root" $ "app" $app "subdomain" $app.harness.subdomain) }}
7373
{{- range $service := $app.harness.use_services }}
7474
{{ include "deploy_utils.ingress.service" (dict "root" $ "service_name" $service.name) }}
7575
{{- end }}
7676
{{- range $subapp := $app }}
7777
{{- if contains "map" (typeOf $subapp) }}
7878
{{- if and $subapp (hasKey $subapp "harness.subdomain") }}
7979
- host: {{ printf "%s.%s.%s" $subapp.harness.subdomain $app.harness.subdomain $domain | quote }}
80-
{{ include "deploy_utils.ingress.http" (dict "root" $ "app" $subapp) }}
80+
{{ include "deploy_utils.ingress.http" (dict "root" $ "app" $subapp "subdomain" (printf "%s.%s" $subapp.harness.subdomain $app.harness.subdomain)) }}
8181
{{- end }}
8282
{{- end }}
8383
{{- end }}
@@ -96,6 +96,11 @@ spec:
9696
- {{ $app.harness.domain | quote }}
9797
{{- end }}
9898
{{- end }}
99+
{{- if $app.harness.aliases }}
100+
{{- range $subdomain := $app.harness.aliases }}
101+
- {{ printf "%s.%s" $subdomain $domain | quote }}
102+
{{- end }}
103+
{{- end }}
99104
{{- end }}
100105
{{- if $mainapp }}
101106
- {{ $domain | quote }}

deployment/codefresh-test.yaml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ steps:
470470
- kubectl config set-context --current --namespace=test-${{NAMESPACE_BASENAME}}
471471
- kubectl rollout status deployment/accounts
472472
- kubectl rollout status deployment/volumemanager
473-
- kubectl rollout status deployment/argo-server-gk
473+
- kubectl rollout status deployment/argo-gk
474474
- kubectl rollout status deployment/samples
475475
- kubectl rollout status deployment/samples-gk
476476
- kubectl rollout status deployment/common
@@ -485,6 +485,18 @@ steps:
485485
commands:
486486
- echo $APP_NAME
487487
scale:
488+
volumemanager_api_test:
489+
title: volumemanager api test
490+
volumes:
491+
- '${{CF_REPO_NAME}}/applications/volumemanager:/home/test'
492+
- '${{CF_REPO_NAME}}/deployment/helm/values.yaml:/opt/cloudharness/resources/allvalues.yaml'
493+
environment:
494+
- APP_URL=https://volumemanager.${{DOMAIN}}/api
495+
- USERNAME=volumes@testuser.com
496+
- PASSWORD=test
497+
commands:
498+
- st --pre-run cloudharness_test.apitest_init run api/openapi.yaml --base-url
499+
https://volumemanager.${{DOMAIN}}/api -c all
488500
samples_api_test:
489501
title: samples api test
490502
volumes:

tools/deployment-cli-tools/ch_cli_tools/codefresh.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ def add_unit_test_step(app_config: ApplicationHarnessConfig):
342342
ROLLOUT_CMD_TPL % app.deployment.name)
343343
if app.secured and helm_values.secured_gatekeepers:
344344
rollout_commands.append(
345-
ROLLOUT_CMD_TPL % app.service.name + "-gk")
345+
ROLLOUT_CMD_TPL % app.subdomain + "-gk")
346346
# some time to the certificates to settle
347347
rollout_commands.append("sleep 60")
348348

0 commit comments

Comments
 (0)