Skip to content

Commit 24b45e9

Browse files
merllj-zimnowoda
andauthored
feat: api endpoint (#1982)
Co-authored-by: Jehoszafat Zimnowoda <[email protected]>
1 parent d3f8a2f commit 24b45e9

File tree

5 files changed

+55
-5
lines changed

5 files changed

+55
-5
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
apiVersion: security.istio.io/v1
2+
kind: AuthorizationPolicy
3+
metadata:
4+
name: {{ include "otomi-api.fullname" . }}
5+
labels:
6+
{{ include "otomi-api.labels" . | indent 4 }}
7+
spec:
8+
selector:
9+
matchLabels:
10+
app.kubernetes.io/name: {{ include "otomi-api.name" . }}
11+
app.kubernetes.io/instance: {{ .Release.Name }}
12+
action: ALLOW
13+
rules:
14+
- from:
15+
- source:
16+
requestPrincipals: ["*"]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
apiVersion: security.istio.io/v1
2+
kind: RequestAuthentication
3+
metadata:
4+
name: {{ include "otomi-api.fullname" . }}
5+
labels:
6+
{{ include "otomi-api.labels" . | indent 4 }}
7+
spec:
8+
jwtRules:
9+
- issuer: {{ .Values.sso.issuer | quote }}
10+
jwksUri: {{ .Values.sso.jwksUri | quote }}
11+
forwardOriginalToken: true
12+
selector:
13+
matchLabels:
14+
app.kubernetes.io/name: {{ include "otomi-api.name" . }}
15+
app.kubernetes.io/instance: {{ .Release.Name }}

core.yaml

+11
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,17 @@ adminApps:
324324
namespace: otomi
325325
type: public
326326
auth: true
327+
- name: api # Used by any client that do not support cookies
328+
hide: true
329+
isShared: true
330+
ownHost: true
331+
ingress:
332+
- svc: otomi-api
333+
namespace: otomi
334+
type: public
335+
# RequestAuthentication and AuthorizationPolicy ensure Authorization header validation
336+
auth: false
337+
327338
- name: prometheus
328339
tags: [metrics, observability]
329340
ownHost: true

src/cmd/validate-templates.ts

+9-5
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,6 @@ export const validateTemplates = async (): Promise<void> => {
157157
',',
158158
)} ${skipPatterns} -schema-location ${schemaOutputPath}/${vk8sVersion}-standalone/{{.ResourceKind}}{{.KindSuffix}}.json -summary -output json ${verbose} ${k8sResourcesPath}`.nothrow()
159159

160-
if (kubeconformOutput.exitCode !== 0) {
161-
d.info('Kubeconform output: %s', kubeconformOutput.toString())
162-
throw new Error(`Template validation FAILED: ${kubeconformOutput.exitCode}`)
163-
}
164-
165160
const parsedOutput = JSON.parse(kubeconformOutput.stdout)
166161
const { valid, invalid, errors, skipped } = parsedOutput.summary
167162

@@ -170,6 +165,15 @@ export const validateTemplates = async (): Promise<void> => {
170165
d.info(`${chalk.yellowBright('TOTAL WARN')}: %s`, `${invalid} files`)
171166
d.info(`${chalk.redBright('TOTAL ERR')}: %s`, `${errors} files`)
172167

168+
if (kubeconformOutput.exitCode !== 0) {
169+
const failedResources = parsedOutput.resources.filter((res) => res.status === 'statusInvalid')
170+
d.error('Kubeconform failed resources:')
171+
for (const resource of failedResources) {
172+
d.error(resource.msg)
173+
}
174+
throw new Error(`Template validation FAILED: ${kubeconformOutput.exitCode}`)
175+
}
176+
173177
d.log('Template validation SUCCESS')
174178
}
175179

values/otomi-api/otomi-api.gotmpl

+4
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,7 @@ podSecurityContext:
6161
imagePullSecrets:
6262
- name: otomi-pullsecret-global
6363
{{- end }}
64+
65+
sso:
66+
issuer: {{ $v._derived.oidcBaseUrl }}
67+
jwksUri: {{ $v._derived.oidcBaseUrl }}/protocol/openid-connect/certs

0 commit comments

Comments
 (0)