Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
04d9f75d17 |
22
apps/iam/uralkal/spicedb-schema.yaml
Normal file
22
apps/iam/uralkal/spicedb-schema.yaml
Normal file
@ -0,0 +1,22 @@
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: iam-spicedb-schema
|
||||
namespace: iam
|
||||
data:
|
||||
schema.json: '{"schema": "definition auth_group {\n\trelation grants: django_permission\n}\n\n// Org structure.
|
||||
department \u0431\u0435\u0437 parent \u043c\u0435\u0436\u0434\u0443 department.\ndefinition department {\n\trelation
|
||||
tenant: tenant\n\trelation member: user\n\trelation service_account: service_account\n\trelation groups: auth_group\n\tpermission
|
||||
group_grants = groups->grants\n}\n\ndefinition django_permission {}\n\ndefinition position {\n\trelation tenant:
|
||||
tenant\n\trelation department: department\n\trelation holder: user\n\trelation service_account: service_account\n\trelation
|
||||
groups: auth_group\n\trelation scoped_resource: resource\n\tpermission group_grants = groups->grants\n}\n\ndefinition
|
||||
resource {\n\trelation tenant: tenant\n\trelation parent: resource\n\n\trelation read: service_account | service_account#member\n\trelation
|
||||
write: service_account | service_account#member\n\trelation admin: service_account | service_account#member\n\trelation
|
||||
view: service_account | service_account#member\n\n\tpermission inherited_read = read + write + admin + parent->inherited_read\n\tpermission
|
||||
inherited_write = write + admin + parent->inherited_write\n\tpermission inherited_admin = admin + parent->inherited_admin\n\n\tpermission
|
||||
allow_read = inherited_read + view + tenant->unrestricted\n\tpermission allow_write = inherited_write\n\tpermission
|
||||
allow_admin = inherited_admin\n}\n\ndefinition service_account {\n\trelation direct_member: user\n\tpermission
|
||||
member = direct_member\n}\n\ndefinition tenant {\n\trelation unrestricted: service_account | service_account#member\n}\n\ndefinition
|
||||
user {\n\trelation direct: django_permission\n\trelation member: auth_group\n\trelation holder: position\n\trelation
|
||||
department_member: department\n\tpermission global_grant = direct + member->grants + holder->group_grants +
|
||||
department_member->group_grants\n\tpermission resource_position_grant = holder->group_grants\n}\n"}'
|
||||
153
apps/iam/uralkal/spicedb.yaml
Normal file
153
apps/iam/uralkal/spicedb.yaml
Normal file
@ -0,0 +1,153 @@
|
||||
apiVersion: helm.toolkit.fluxcd.io/v2
|
||||
kind: HelmRelease
|
||||
metadata:
|
||||
name: iam-backend
|
||||
namespace: iam
|
||||
spec:
|
||||
values:
|
||||
services:
|
||||
backend:
|
||||
image:
|
||||
name:
|
||||
_default: cr.yandex/crp3ccidau046kdj8g9q/iams:production_beb901c6
|
||||
deployment:
|
||||
args:
|
||||
_default:
|
||||
- |
|
||||
set -a
|
||||
[ -f /vault/secrets/iam-db ] && . /vault/secrets/iam-db
|
||||
[ -f /vault/secrets/iam-zitadel ] && . /vault/secrets/iam-zitadel
|
||||
[ -f /vault/secrets/iam-kafka ] && . /vault/secrets/iam-kafka
|
||||
[ -f /vault/secrets/iam-s3 ] && . /vault/secrets/iam-s3
|
||||
[ -f /vault/secrets/iam-spicedb ] && . /vault/secrets/iam-spicedb
|
||||
set +a
|
||||
exec ./server
|
||||
strategy:
|
||||
type: RollingUpdate
|
||||
rollingUpdate:
|
||||
maxUnavailable: 0
|
||||
maxSurge: 1
|
||||
probes:
|
||||
readiness:
|
||||
enabled: true
|
||||
httpGet:
|
||||
path:
|
||||
_default: /api/health
|
||||
port:
|
||||
_default: 8080
|
||||
periodSeconds:
|
||||
_default: 5
|
||||
timeoutSeconds:
|
||||
_default: 3
|
||||
envs:
|
||||
- name: ENVIRONMENT
|
||||
value:
|
||||
_default: prod
|
||||
- name: LOG_LEVEL
|
||||
value:
|
||||
_default: debug
|
||||
- name: AUTH_ENABLED
|
||||
value:
|
||||
_default: 'true'
|
||||
- name: HTTP_PORT
|
||||
value:
|
||||
_default: '8080'
|
||||
- name: HTTP_READ_BUFFER_SIZE
|
||||
value:
|
||||
_default: '131072'
|
||||
- name: DB_MIGRATIONS_PATH
|
||||
value:
|
||||
_default: migrations
|
||||
- name: ZITADEL_ENABLED
|
||||
value:
|
||||
_default: 'true'
|
||||
- name: ZITADEL_HOST
|
||||
value:
|
||||
_default: https://login.sarex.local.uralkali.com
|
||||
- name: ZITADEL_ORG_RULES_FILE
|
||||
value:
|
||||
_default: config/zitadel/org-rules-prod.json
|
||||
- name: S3_ENABLED
|
||||
value:
|
||||
_default: 'true'
|
||||
- name: S3_ENDPOINT_URL
|
||||
value:
|
||||
_default: http://s3-proxy.s3-proxy.svc.cluster.local
|
||||
- name: S3_BUCKET_NAME
|
||||
value:
|
||||
_default: iam
|
||||
- name: ZITADEL_TLS_INSECURE_SKIP_VERIFY
|
||||
value:
|
||||
_default: 'true'
|
||||
- name: S3_REGION
|
||||
value:
|
||||
_default: ru-central1
|
||||
- name: S3_PRESIGN_EXPIRES
|
||||
value:
|
||||
_default: 1h
|
||||
- name: KAFKA_ENABLED
|
||||
value:
|
||||
_default: 'false'
|
||||
- name: KAFKA_SSL_CAFILE
|
||||
value:
|
||||
_default: /etc/ca-certificates/Yandex/ca-cert
|
||||
- name: KAFKA_TOPIC_LEGACY_AMS_SYNC
|
||||
value:
|
||||
_default: ams-sync
|
||||
- name: SPICEDB_ENDPOINT
|
||||
value:
|
||||
_default: spicedb.spicedb.svc.cluster.local:50051
|
||||
- name: SPICEDB_INSECURE
|
||||
value:
|
||||
_default: 'true'
|
||||
podAnnotations:
|
||||
_default:
|
||||
vault.hashicorp.com/agent-inject-secret-iam-spicedb: secrets/data/apps/spicedb/auth
|
||||
vault.hashicorp.com/agent-inject-template-iam-spicedb: |-
|
||||
{{- with secret "secrets/data/apps/spicedb/auth" -}}
|
||||
SPICEDB_TOKEN='{{ index .Data.data "preshared_key" }}'
|
||||
{{- end -}}
|
||||
traffic.sidecar.istio.io/excludeOutboundPorts: 4317,4318,9411,8200,8443,50051
|
||||
vault.hashicorp.com/agent-image: cr.yandex/crp3ccidau046kdj8g9q/vault/vault:1.21.2
|
||||
postRenderers:
|
||||
- kustomize:
|
||||
patches:
|
||||
- target:
|
||||
kind: Deployment
|
||||
name: iam-backend
|
||||
patch: |
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: iam-backend
|
||||
spec:
|
||||
template:
|
||||
metadata:
|
||||
annotations:
|
||||
checksum/spicedb-schema: 72606779239bef9fe18170545d8fb3d70581581048aeea55a390d414197f1ce6
|
||||
spec:
|
||||
initContainers:
|
||||
- name: spicedb-schema
|
||||
image: cr.yandex/crp3ccidau046kdj8g9q/vault/vault:1.21.2
|
||||
command:
|
||||
- /bin/sh
|
||||
- -ec
|
||||
args:
|
||||
- ". /vault/secrets/iam-spicedb\nfor attempt in $(seq 1 60); do\n if wget\
|
||||
\ -qO /tmp/schema-result.json --header=\"Authorization: Bearer $SPICEDB_TOKEN\"\
|
||||
\ --header=\"Content-Type: application/json\" --post-file=/schema/schema.json\
|
||||
\ http://spicedb.spicedb.svc.cluster.local:8443/v1/schema/write; then\n\
|
||||
\ echo \"SpiceDB schema loaded\"\n exit 0\n fi\n sleep 2\ndone\n\
|
||||
exit 1\n"
|
||||
resources:
|
||||
requests:
|
||||
cpu: 25m
|
||||
memory: 32Mi
|
||||
volumeMounts:
|
||||
- name: spicedb-schema
|
||||
mountPath: /schema
|
||||
readOnly: true
|
||||
volumes:
|
||||
- name: spicedb-schema
|
||||
configMap:
|
||||
name: iam-spicedb-schema
|
||||
@ -11,6 +11,7 @@ resources:
|
||||
- ../../infrastructure/rabbitmq/uralkal
|
||||
- ../../infrastructure/kafka/uralkal
|
||||
- ../../infrastructure/postgresql/uralkal
|
||||
- ../../infrastructure/spicedb/uralkal
|
||||
- ../../infrastructure/zitadel/uralkal
|
||||
- ../../infrastructure/camunda/uralkal
|
||||
- ../../infrastructure/superset/uralkal
|
||||
|
||||
4
infrastructure/spicedb/uralkal/kustomization.yaml
Normal file
4
infrastructure/spicedb/uralkal/kustomization.yaml
Normal file
@ -0,0 +1,4 @@
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
resources:
|
||||
- spicedb.yaml
|
||||
153
infrastructure/spicedb/uralkal/spicedb.yaml
Normal file
153
infrastructure/spicedb/uralkal/spicedb.yaml
Normal file
@ -0,0 +1,153 @@
|
||||
apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
name: spicedb
|
||||
labels:
|
||||
istio-injection: disabled
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: spicedb-vault
|
||||
namespace: spicedb
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: spicedb
|
||||
namespace: spicedb
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: spicedb
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: spicedb
|
||||
annotations:
|
||||
vault.hashicorp.com/agent-inject: 'true'
|
||||
vault.hashicorp.com/agent-init-first: 'true'
|
||||
vault.hashicorp.com/agent-pre-populate-only: 'true'
|
||||
vault.hashicorp.com/agent-requests-cpu: 25m
|
||||
vault.hashicorp.com/auth-path: auth/kubernetes
|
||||
vault.hashicorp.com/role: spicedb
|
||||
vault.hashicorp.com/agent-inject-secret-spicedb-db: secrets/data/apps/spicedb/postgres
|
||||
vault.hashicorp.com/agent-inject-template-spicedb-db: |-
|
||||
{{- with secret "secrets/data/apps/spicedb/postgres" -}}
|
||||
SPICEDB_DATASTORE_CONN_URI='postgres://{{ index .Data.data "username" }}:{{ index .Data.data "password" }}@{{ index .Data.data "host" }}:{{ index .Data.data "port" }}/{{ index .Data.data "database" }}?sslmode=disable'
|
||||
{{- end -}}
|
||||
vault.hashicorp.com/agent-inject-secret-spicedb-auth: secrets/data/apps/spicedb/auth
|
||||
vault.hashicorp.com/agent-inject-template-spicedb-auth: |-
|
||||
{{- with secret "secrets/data/apps/spicedb/auth" -}}
|
||||
SPICEDB_GRPC_PRESHARED_KEY='{{ index .Data.data "preshared_key" }}'
|
||||
{{- end -}}
|
||||
vault.hashicorp.com/agent-image: cr.yandex/crp3ccidau046kdj8g9q/vault/vault:1.21.2
|
||||
spec:
|
||||
serviceAccountName: spicedb-vault
|
||||
initContainers:
|
||||
- name: vault-runtime
|
||||
image: cr.yandex/crp3ccidau046kdj8g9q/vault/vault:1.21.2
|
||||
command:
|
||||
- /bin/sh
|
||||
- -ec
|
||||
args:
|
||||
- cp /bin/busybox /lib/ld-musl-x86_64.so.1 /vault-runtime/
|
||||
resources:
|
||||
requests:
|
||||
cpu: 25m
|
||||
memory: 16Mi
|
||||
volumeMounts:
|
||||
- name: vault-runtime
|
||||
mountPath: /vault-runtime
|
||||
- name: spicedb-migrate
|
||||
image: cr.yandex/crp3ccidau046kdj8g9q/spicedb-prod:v1.54.0
|
||||
command:
|
||||
- /vault-runtime/ld-musl-x86_64.so.1
|
||||
- /vault-runtime/busybox
|
||||
- sh
|
||||
- -ec
|
||||
args:
|
||||
- |
|
||||
set -a
|
||||
. /vault/secrets/spicedb-db
|
||||
. /vault/secrets/spicedb-auth
|
||||
set +a
|
||||
exec spicedb datastore migrate head --datastore-engine postgres
|
||||
volumeMounts:
|
||||
- name: vault-runtime
|
||||
mountPath: /vault-runtime
|
||||
readOnly: true
|
||||
resources:
|
||||
requests:
|
||||
cpu: 100m
|
||||
memory: 256Mi
|
||||
limits:
|
||||
memory: 1Gi
|
||||
containers:
|
||||
- name: spicedb
|
||||
image: cr.yandex/crp3ccidau046kdj8g9q/spicedb-prod:v1.54.0
|
||||
command:
|
||||
- /vault-runtime/ld-musl-x86_64.so.1
|
||||
- /vault-runtime/busybox
|
||||
- sh
|
||||
- -ec
|
||||
args:
|
||||
- |
|
||||
set -a
|
||||
. /vault/secrets/spicedb-db
|
||||
. /vault/secrets/spicedb-auth
|
||||
set +a
|
||||
exec spicedb serve --datastore-engine postgres --http-enabled --datastore-conn-pool-read-max-open 10 --datastore-conn-pool-read-min-open 1 --datastore-conn-pool-write-max-open 5 --datastore-conn-pool-write-min-open 1
|
||||
ports:
|
||||
- name: grpc
|
||||
containerPort: 50051
|
||||
- name: http
|
||||
containerPort: 8443
|
||||
resources:
|
||||
requests:
|
||||
cpu: 100m
|
||||
memory: 256Mi
|
||||
limits:
|
||||
memory: 1Gi
|
||||
volumeMounts:
|
||||
- name: vault-runtime
|
||||
mountPath: /vault-runtime
|
||||
readOnly: true
|
||||
startupProbe:
|
||||
grpc:
|
||||
port: 50051
|
||||
periodSeconds: 5
|
||||
failureThreshold: 60
|
||||
readinessProbe:
|
||||
grpc:
|
||||
port: 50051
|
||||
periodSeconds: 5
|
||||
volumes:
|
||||
- name: vault-runtime
|
||||
emptyDir: {}
|
||||
nodeSelector:
|
||||
dedicated: generic
|
||||
imagePullSecrets:
|
||||
- name: regcred
|
||||
strategy:
|
||||
type: RollingUpdate
|
||||
rollingUpdate:
|
||||
maxUnavailable: 0
|
||||
maxSurge: 1
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: spicedb
|
||||
namespace: spicedb
|
||||
spec:
|
||||
selector:
|
||||
app: spicedb
|
||||
ports:
|
||||
- name: grpc
|
||||
port: 50051
|
||||
targetPort: grpc
|
||||
- name: http
|
||||
port: 8443
|
||||
targetPort: http
|
||||
Loading…
Reference in New Issue
Block a user