From f89ff8ce54681403e8184c08fd396c15ed5db5ee Mon Sep 17 00:00:00 2001 From: Thomas GRUSON Date: Fri, 16 Jul 2021 16:49:37 +0200 Subject: [PATCH] feat: expose swagger ui --- charts/candidate/Chart.yaml | 2 +- charts/candidate/templates/config.yaml | 4 +++- charts/candidate/templates/deploy-api.yaml | 22 +++++++++++++++---- charts/candidate/templates/deploy-ui.yaml | 14 ++++++++++-- charts/candidate/templates/ingress.yaml | 6 ++--- charts/candidate/values.yaml | 6 +++-- code/api/api/pom.xml | 10 +++++++-- .../security/SecurityConfigurer.java | 12 +--------- .../api/src/main/resources/application.yaml | 5 ++++- code/api/database/pom.xml | 2 +- code/api/generated-cucumber-report/pom.xml | 2 +- code/api/jacoco-aggregation/pom.xml | 4 ++-- code/api/lib/pom.xml | 2 +- code/api/pom.xml | 2 +- code/docker-compose-mysql.yaml | 4 +++- code/docker-compose.yaml | 4 +++- code/web-ui/Dockerfile | 4 +++- code/web-ui/config/default.conf.template | 6 ++--- code/web-ui/config/index.js | 4 +++- code/web-ui/package-lock.json | 2 +- code/web-ui/package.json | 2 +- 21 files changed, 77 insertions(+), 42 deletions(-) diff --git a/charts/candidate/Chart.yaml b/charts/candidate/Chart.yaml index 16e48fa86..a339bd05b 100644 --- a/charts/candidate/Chart.yaml +++ b/charts/candidate/Chart.yaml @@ -1,6 +1,6 @@ apiVersion: v2 name: ara -version: 9.1.1-rc.1 +version: 9.2.0-rc.1 home: https://github.com/Decathlon/ara description: | ARA helps you to fight against regressions by letting it preanalyze your non-regression tests runs, diff --git a/charts/candidate/templates/config.yaml b/charts/candidate/templates/config.yaml index 33bab65cd..1eff0858b 100644 --- a/charts/candidate/templates/config.yaml +++ b/charts/candidate/templates/config.yaml @@ -14,7 +14,9 @@ data: database_type: {{ .Values.database.type }} liquibase_active: {{ .Values.database.liquibaseActive | quote }} app_url: {{ .Values.api.appUrl }} - api_url: {{ printf "%s-%s-api.%s.svc.cluster.local:%.0f" .Release.Name .Chart.Name .Release.Namespace .Values.api.port }} + api_host: {{ printf "%s-%s-api.%s.svc.cluster.local" .Release.Name .Chart.Name .Release.Namespace }} + api_port: {{ printf "%.0f" .Values.api.port | quote }} + api_management_port: {{ printf "%.0f" .Values.api.management.port | quote }} {{- if not .Values.api.configExistingSecret.enabled }} --- diff --git a/charts/candidate/templates/deploy-api.yaml b/charts/candidate/templates/deploy-api.yaml index ebeecd0df..a0da56125 100644 --- a/charts/candidate/templates/deploy-api.yaml +++ b/charts/candidate/templates/deploy-api.yaml @@ -35,7 +35,15 @@ spec: imagePullPolicy: {{ .Values.api.image.imagePullPolicy }} env: - name: SERVER_PORT - value: "{{ .Values.api.port }}" + valueFrom: + configMapKeyRef: + name: {{ include "ara.configmap.name" . }} + key: api_port + - name: MANAGEMENT_SERVER_PORT + valueFrom: + configMapKeyRef: + name: {{ include "ara.configmap.name" . }} + key: api_management_port - name: ARA_DATABASE_TARGET valueFrom: configMapKeyRef: @@ -82,10 +90,12 @@ spec: ports: - containerPort: {{ .Values.api.port }} name: http-port + - containerPort: {{ .Values.api.management.port }} + name: management-port readinessProbe: httpGet: path: /actuator/health/readiness - port: {{ .Values.api.port }} + port: {{ .Values.api.management.port }} initialDelaySeconds: 40 timeoutSeconds: 2 periodSeconds: 3 @@ -93,7 +103,7 @@ spec: livenessProbe: httpGet: path: /actuator/health/liveness - port: {{ .Values.api.port }} + port: {{ .Values.api.management.port }} initialDelaySeconds: 100 timeoutSeconds: 2 periodSeconds: 8 @@ -125,8 +135,12 @@ metadata: spec: type: ClusterIP ports: - - port: {{ .Values.api.port }} + - name: http + port: {{ .Values.api.port }} targetPort: http-port + - name: management + port: {{ .Values.api.management.port }} + targetPort: management-port selector: app.kubernetes.io/name: {{ include "ara.name" . }} app.kubernetes.io/instance: {{ .Release.Name }} diff --git a/charts/candidate/templates/deploy-ui.yaml b/charts/candidate/templates/deploy-ui.yaml index 7aa4479a2..d8b754de3 100644 --- a/charts/candidate/templates/deploy-ui.yaml +++ b/charts/candidate/templates/deploy-ui.yaml @@ -33,11 +33,21 @@ spec: image: "{{ .Values.ui.image.registry }}/{{ .Values.ui.image.repository }}:{{ default .Chart.Version .Values.ui.image.tag }}" imagePullPolicy: {{ .Values.ui.image.imagePullPolicy }} env: - - name: API_URL + - name: ARA_API_HOST valueFrom: configMapKeyRef: name: {{ include "ara.configmap.name" . }} - key: api_url + key: api_host + - name: ARA_API_PORT + valueFrom: + configMapKeyRef: + name: {{ include "ara.configmap.name" . }} + key: api_port + - name: ARA_MANAGEMENT_PORT + valueFrom: + configMapKeyRef: + name: {{ include "ara.configmap.name" . }} + key: api_management_port ports: - containerPort: {{ .Values.ui.port }} name: http-port diff --git a/charts/candidate/templates/ingress.yaml b/charts/candidate/templates/ingress.yaml index 2b359af27..706fb3379 100644 --- a/charts/candidate/templates/ingress.yaml +++ b/charts/candidate/templates/ingress.yaml @@ -26,15 +26,15 @@ spec: path: / - backend: serviceName: {{ printf "%s-%s-%s" .Release.Name .Chart.Name "api" }} - servicePort: http-port + servicePort: http path: /api - backend: serviceName: {{ printf "%s-%s-%s" .Release.Name .Chart.Name "api" }} - servicePort: http-port + servicePort: management path: /actuator - backend: serviceName: {{ printf "%s-%s-%s" .Release.Name .Chart.Name "api" }} - servicePort: http-port + servicePort: http path: /auth {{- if .Values.ingress.tls }} tls: diff --git a/charts/candidate/values.yaml b/charts/candidate/values.yaml index fda34dd1d..d77687ddf 100644 --- a/charts/candidate/values.yaml +++ b/charts/candidate/values.yaml @@ -8,7 +8,7 @@ api: image: registry: docker.io repository: decathlon/ara-api - tag: 9.0.9 + tag: 10.0.0 imagePullPolicy: IfNotPresent replicas: 1 annotations: {} @@ -24,6 +24,8 @@ api: # cpu: 100m # memory: 128Mi port: 8080 + management: + port: 9090 # Base url used to redirect on the app by email service among others appUrl: ara.test authConfig: "" @@ -44,7 +46,7 @@ ui: image: registry: docker.io repository: decathlon/ara-web-ui - tag: 8.7.0 + tag: 9.0.0 imagePullPolicy: IfNotPresent replicas: 1 annotations: {} diff --git a/code/api/api/pom.xml b/code/api/api/pom.xml index 254181bc8..0464daad6 100644 --- a/code/api/api/pom.xml +++ b/code/api/api/pom.xml @@ -28,7 +28,7 @@ com.decathlon.ara ara-api - 9.0.9 + 10.0.0 ARA API @@ -41,6 +41,7 @@ h2 1.4.2.Final + 1.5.9 UTF-8 initialize @@ -176,8 +177,13 @@ org.springdoc springdoc-openapi-ui - 1.4.5 + ${springdoc.version} + + org.springdoc + springdoc-openapi-security + ${springdoc.version} + diff --git a/code/api/api/src/main/java/com/decathlon/ara/configuration/security/SecurityConfigurer.java b/code/api/api/src/main/java/com/decathlon/ara/configuration/security/SecurityConfigurer.java index d55acafb0..0eb7aa3a4 100644 --- a/code/api/api/src/main/java/com/decathlon/ara/configuration/security/SecurityConfigurer.java +++ b/code/api/api/src/main/java/com/decathlon/ara/configuration/security/SecurityConfigurer.java @@ -37,16 +37,6 @@ @RequiredArgsConstructor(onConstructor = @__(@Autowired)) public class SecurityConfigurer extends WebSecurityConfigurerAdapter { - private final String[] swaggerResources = { - "/v3/api-docs/**", - "/configuration/ui", - "/swagger-resources/**", - "/configuration/security", - "/swagger-ui.html", - "/swagger-ui/**", - "/webjars/**" - }; - @NonNull private AuthenticationConfiguration authenticationConfiguration; @@ -69,8 +59,8 @@ protected void configure(HttpSecurity http) throws Exception { .and() .authorizeRequests()//NOSONAR .antMatchers("/actuator/info", "/actuator/health/**").permitAll() + .antMatchers("/actuator/swaggerui/**", "/actuator/swagger-ui/**", "/actuator/openapi/**").permitAll() .antMatchers("/auth/**").permitAll() - .antMatchers(swaggerResources).permitAll() .anyRequest().authenticated() .and() .addFilterBefore(jwtRequestFilter, UsernamePasswordAuthenticationFilter.class); diff --git a/code/api/api/src/main/resources/application.yaml b/code/api/api/src/main/resources/application.yaml index d47cce0d6..70b262533 100644 --- a/code/api/api/src/main/resources/application.yaml +++ b/code/api/api/src/main/resources/application.yaml @@ -44,6 +44,7 @@ spring: springdoc: packagesToScan: com.decathlon.ara pathsToMatch: /api/** + use-management-port: true # # Sensible default values, optionally customizable by clients @@ -81,10 +82,12 @@ ara: clientBaseUrl: http://localhost:8081/ management: + server: + port: 9090 endpoints: web: exposure: - include: health,info + include: health, info, openapi, swaggerui # Metrics metrics: export: diff --git a/code/api/database/pom.xml b/code/api/database/pom.xml index 5f7f13f5f..8492c288b 100644 --- a/code/api/database/pom.xml +++ b/code/api/database/pom.xml @@ -28,7 +28,7 @@ com.decathlon.ara ara-database - 9.0.9 + 10.0.0 ARA Database diff --git a/code/api/generated-cucumber-report/pom.xml b/code/api/generated-cucumber-report/pom.xml index 14afeda8a..0335dd8f1 100644 --- a/code/api/generated-cucumber-report/pom.xml +++ b/code/api/generated-cucumber-report/pom.xml @@ -27,7 +27,7 @@ com.decathlon.ara ara-generated-cucumber-report - 9.0.9 + 10.0.0 ARA Cucumber diff --git a/code/api/jacoco-aggregation/pom.xml b/code/api/jacoco-aggregation/pom.xml index 2c9d0dc82..c88031a6d 100644 --- a/code/api/jacoco-aggregation/pom.xml +++ b/code/api/jacoco-aggregation/pom.xml @@ -3,14 +3,14 @@ ara-parent com.decathlon.ara - 9.0.9 + 10.0.0 4.0.0 com.decathlon.ara jacoco-aggregation pom - 9.0.9 + 10.0.0 Jacoco Report Aggregation diff --git a/code/api/lib/pom.xml b/code/api/lib/pom.xml index 3d79f4312..b957b5ff9 100644 --- a/code/api/lib/pom.xml +++ b/code/api/lib/pom.xml @@ -27,7 +27,7 @@ com.decathlon.ara ara-lib - 9.0.9 + 10.0.0 16 diff --git a/code/api/pom.xml b/code/api/pom.xml index 80c06a286..eca9b1da4 100644 --- a/code/api/pom.xml +++ b/code/api/pom.xml @@ -28,7 +28,7 @@ com.decathlon.ara ara-parent pom - 9.0.9 + 10.0.0 ARA Parent diff --git a/code/docker-compose-mysql.yaml b/code/docker-compose-mysql.yaml index 0aa18cd15..907cebb9e 100644 --- a/code/docker-compose-mysql.yaml +++ b/code/docker-compose-mysql.yaml @@ -34,7 +34,9 @@ services: image: "decathlon/ara-web-ui:${WEB_UI_VERSION:-latest}" restart: always environment: - - API_URL=ara-mysql-api:8080 + - ARA_API_HOST=ara-mysql-api + - ARA_API_PORT=8080 + - ARA_MANAGEMENT_PORT=9090 ports: - 8081:80 networks: diff --git a/code/docker-compose.yaml b/code/docker-compose.yaml index bcb928cf6..f4d8bb510 100644 --- a/code/docker-compose.yaml +++ b/code/docker-compose.yaml @@ -33,7 +33,9 @@ services: image: "decathlon/ara-web-ui:${WEB_UI_VERSION:-latest}" restart: always environment: - - API_URL=ara-api:8080 + - ARA_API_HOST=ara-api + - ARA_API_PORT=8080 + - ARA_MANAGEMENT_PORT=9090 ports: - 8081:80 networks: diff --git a/code/web-ui/Dockerfile b/code/web-ui/Dockerfile index 13ba26569..babf5834d 100644 --- a/code/web-ui/Dockerfile +++ b/code/web-ui/Dockerfile @@ -13,7 +13,9 @@ RUN npm run build FROM nginx:1.19 -ENV API_URL localhost +ENV ARA_API_HOST localhost +ENV ARA_API_PORT 8080 +ENV ARA_MANAGEMENT_PORT 9090 COPY --from=builder /usr/src/app/dist /usr/share/nginx/html COPY config/default.conf.template /etc/nginx/templates/default.conf.template diff --git a/code/web-ui/config/default.conf.template b/code/web-ui/config/default.conf.template index 5a199c38d..3a45f72a1 100644 --- a/code/web-ui/config/default.conf.template +++ b/code/web-ui/config/default.conf.template @@ -6,15 +6,15 @@ server { #access_log /var/log/nginx/host.access.log main; location /auth { - proxy_pass http://${API_URL}/auth; + proxy_pass http://${ARA_API_HOST}:${ARA_API_PORT}/auth; } location /api { - proxy_pass http://${API_URL}/api; + proxy_pass http://${ARA_API_HOST}:${ARA_API_PORT}/api; } location /actuator { - proxy_pass http://${API_URL}/actuator; + proxy_pass http://${ARA_API_HOST}:${ARA_MANAGEMENT_PORT}/actuator; } location / { diff --git a/code/web-ui/config/index.js b/code/web-ui/config/index.js index 0eeceb67f..e13911c87 100644 --- a/code/web-ui/config/index.js +++ b/code/web-ui/config/index.js @@ -3,8 +3,10 @@ var path = require('path') var araAPIHost = process.env.ARA_API_HOST || 'localhost' var araAPIPort = process.env.ARA_API_PORT || 8080 +var araManagementPort = process.env.ARA_MANAGEMENT_PORT || 9090 var araAPIURL = 'http://' + araAPIHost + ':' + araAPIPort +var araManagementURL = 'http://' + araAPIHost + ':' + araManagementPort var PACKAGE = require('../package.json') var version = PACKAGE.version @@ -60,7 +62,7 @@ module.exports = { changeOrigin: true }, '/actuator': { - target: araAPIURL, + target: araManagementURL, changeOrigin: true }, '/demo-files': { diff --git a/code/web-ui/package-lock.json b/code/web-ui/package-lock.json index f5f8c33f7..d936f553d 100644 --- a/code/web-ui/package-lock.json +++ b/code/web-ui/package-lock.json @@ -1,6 +1,6 @@ { "name": "ara-client", - "version": "8.7.0", + "version": "9.0.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/code/web-ui/package.json b/code/web-ui/package.json index 4d0d654fa..15e4aa76f 100644 --- a/code/web-ui/package.json +++ b/code/web-ui/package.json @@ -1,6 +1,6 @@ { "name": "ara-client", - "version": "8.7.0", + "version": "9.0.0", "description": "Agile Regression Analyzer front app", "author": "Decathlon ", "private": true,