wb: manage existing IAM with Flux and initialize SpiceDB schema
This commit is contained in:
parent
69c0340cb4
commit
78a123b55b
@ -1,95 +0,0 @@
|
||||
---
|
||||
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_527610b8
|
||||
|
||||
deployment:
|
||||
resources:
|
||||
limits:
|
||||
cpu:
|
||||
_default: 20m
|
||||
memory:
|
||||
_default: 89Mi
|
||||
requests:
|
||||
cpu:
|
||||
_default: 10m
|
||||
memory:
|
||||
_default: 64Mi
|
||||
|
||||
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://sarex-login.uralmine.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://10.49.10.90:9000"
|
||||
|
||||
- name: S3_BUCKET_NAME
|
||||
value:
|
||||
_default: "sarex-media-storage"
|
||||
|
||||
- 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"
|
||||
211
apps/iam/wb/iams.yaml
Normal file
211
apps/iam/wb/iams.yaml
Normal file
@ -0,0 +1,211 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: iams
|
||||
namespace: iam
|
||||
labels:
|
||||
app: iams
|
||||
app.kubernetes.io/managed-by: kustomize
|
||||
service: iams
|
||||
spec:
|
||||
progressDeadlineSeconds: 600
|
||||
replicas: 1
|
||||
revisionHistoryLimit: 10
|
||||
selector:
|
||||
matchLabels:
|
||||
app: iams
|
||||
strategy:
|
||||
rollingUpdate:
|
||||
maxSurge: 25%
|
||||
maxUnavailable: 25%
|
||||
type: RollingUpdate
|
||||
template:
|
||||
metadata:
|
||||
annotations:
|
||||
proxy.istio.io/config: "tracing:\n sampling: 100\n zipkin:\n address:\
|
||||
\ signoz-otel-collector-external.signoz.svc.cluster.local:9411\n custom_tags:\n\
|
||||
\ k8s.pod.name:\n environment:\n name: POD_NAME\n k8s.namespace.name:\n\
|
||||
\ environment:\n name: POD_NAMESPACE\n k8s.pod.ip:\n \
|
||||
\ environment:\n name: INSTANCE_IP\n"
|
||||
traffic.sidecar.istio.io/excludeOutboundPorts: 4317,4318,9411
|
||||
checksum/spicedb-schema: 72606779239bef9fe18170545d8fb3d70581581048aeea55a390d414197f1ce6
|
||||
labels:
|
||||
app: iams
|
||||
service: iams
|
||||
spec:
|
||||
containers:
|
||||
- env:
|
||||
- name: SPICEDB_ENDPOINT
|
||||
value: spicedb.spicedb.svc.cluster.local:50051
|
||||
- name: SPICEDB_INSECURE
|
||||
value: 'true'
|
||||
- name: SPICEDB_TOKEN
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
key: grpc-preshared-key
|
||||
name: spicedb-secret
|
||||
- name: K8S_POD_UID
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
apiVersion: v1
|
||||
fieldPath: metadata.uid
|
||||
- name: K8S_POD_NAME
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
apiVersion: v1
|
||||
fieldPath: metadata.name
|
||||
- name: K8S_NAMESPACE
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
apiVersion: v1
|
||||
fieldPath: metadata.namespace
|
||||
- name: OTEL_RESOURCE_ATTRIBUTES
|
||||
value: k8s.pod.uid=$(K8S_POD_UID),k8s.pod.name=$(K8S_POD_NAME),k8s.namespace.name=$(K8S_NAMESPACE)
|
||||
- name: ENVIRONMENT
|
||||
value: prod
|
||||
- name: LOG_LEVEL
|
||||
value: debug
|
||||
- name: AUTH_ENABLED
|
||||
value: 'true'
|
||||
- name: HTTP_PORT
|
||||
value: '8080'
|
||||
- name: HTTP_READ_BUFFER_SIZE
|
||||
value: '131072'
|
||||
- name: DB_MIGRATIONS_PATH
|
||||
value: migrations
|
||||
- name: ZITADEL_ENABLED
|
||||
value: 'true'
|
||||
- name: ZITADEL_HOST
|
||||
value: https://zitadel-srx.wb.ru
|
||||
- name: ZITADEL_ORG_RULES_FILE
|
||||
value: config/zitadel/org-rules-prod.json
|
||||
- name: S3_ENABLED
|
||||
value: 'true'
|
||||
- name: S3_ENDPOINT_URL
|
||||
value: https://storage.yandoud.net
|
||||
- name: S3_BUCKET_NAME
|
||||
value: sarex-media-storage
|
||||
- name: S3_REGION
|
||||
value: ru-central1
|
||||
- name: S3_PRESIGN_EXPIRES
|
||||
value: 1h
|
||||
- name: KAFKA_ENABLED
|
||||
value: 'false'
|
||||
- name: KAFKA_SECURITY_PROTOCOL
|
||||
value: SASL_SSL
|
||||
- name: KAFKA_SASL_MECHANISM
|
||||
value: SCRAM-SHA-512
|
||||
- name: KAFKA_BROKERS
|
||||
value: rc1d-s0a1ujcbj6fdk26b.mdb.yandexcloud.net:9091
|
||||
- name: KAFKA_SSL_CAFILE
|
||||
value: /etc/ca-certificates/Yandex/ca-cert
|
||||
- name: KAFKA_TOPIC_LEGACY_AMS_SYNC
|
||||
value: ams-sync
|
||||
- name: DB_DSN
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
key: db-dsn
|
||||
name: iams-secret
|
||||
- name: ZITADEL_ACCESS_TOKEN
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
key: zitadel-access-token
|
||||
name: iams-secret
|
||||
- name: KAFKA_SASL_PLAIN_USERNAME
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
key: kafka-sasl-plain-username
|
||||
name: iams-secret
|
||||
- name: KAFKA_SASL_PLAIN_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
key: kafka-sasl-plain-password
|
||||
name: iams-secret
|
||||
- name: S3_ACCESS_KEY_ID
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
key: key_id
|
||||
name: yc-s3-secret
|
||||
- name: S3_SECRET_ACCESS_KEY
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
key: access_key
|
||||
name: yc-s3-secret
|
||||
image: cr.yandex/crp3ccidau046kdj8g9q/iams:production_527610b8
|
||||
imagePullPolicy: IfNotPresent
|
||||
name: iams
|
||||
ports:
|
||||
- containerPort: 8080
|
||||
name: http
|
||||
protocol: TCP
|
||||
resources: {}
|
||||
terminationMessagePath: /dev/termination-log
|
||||
terminationMessagePolicy: File
|
||||
volumeMounts:
|
||||
- mountPath: /etc/ca-certificates/Yandex
|
||||
name: kafka-ca
|
||||
readOnly: true
|
||||
- mountPath: /config/zitadel/org-rules-prod.json
|
||||
name: zitadel-rules
|
||||
readOnly: true
|
||||
subPath: org-rules-prod.json
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /api/health
|
||||
port: http
|
||||
initialDelaySeconds: 5
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 8
|
||||
failureThreshold: 3
|
||||
dnsPolicy: ClusterFirst
|
||||
imagePullSecrets:
|
||||
- name: dockerhub
|
||||
restartPolicy: Always
|
||||
schedulerName: default-scheduler
|
||||
securityContext: {}
|
||||
terminationGracePeriodSeconds: 30
|
||||
volumes:
|
||||
- name: kafka-ca
|
||||
secret:
|
||||
defaultMode: 420
|
||||
secretName: ya-ca-secret
|
||||
- configMap:
|
||||
defaultMode: 420
|
||||
name: iam-zitadel-org-rules
|
||||
name: zitadel-rules
|
||||
- name: spicedb-schema
|
||||
configMap:
|
||||
name: iam-spicedb-schema
|
||||
initContainers:
|
||||
- name: spicedb-schema
|
||||
image: cr.yandex/crp3ccidau046kdj8g9q/authzed/zed:v1.2.0
|
||||
imagePullPolicy: IfNotPresent
|
||||
command:
|
||||
- /usr/local/bin/zed
|
||||
args:
|
||||
- --insecure
|
||||
- --skip-version-check
|
||||
- --max-retries
|
||||
- '60'
|
||||
- schema
|
||||
- write
|
||||
- /schema/iam.zed
|
||||
env:
|
||||
- name: ZED_ENDPOINT
|
||||
value: spicedb.spicedb.svc.cluster.local:50051
|
||||
- name: ZED_TOKEN
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: spicedb-secret
|
||||
key: grpc-preshared-key
|
||||
volumeMounts:
|
||||
- name: spicedb-schema
|
||||
mountPath: /schema
|
||||
readOnly: true
|
||||
resources:
|
||||
requests:
|
||||
cpu: 25m
|
||||
memory: 32Mi
|
||||
limits:
|
||||
cpu: 250m
|
||||
memory: 128Mi
|
||||
@ -1,11 +1,8 @@
|
||||
---
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
namespace: iam
|
||||
resources:
|
||||
- ../base
|
||||
patches:
|
||||
- path: backend-s3.yaml
|
||||
target:
|
||||
kind: HelmRelease
|
||||
name: iam-backend
|
||||
- org-rules.yaml
|
||||
- spicedb-schema.yaml
|
||||
- service.yaml
|
||||
- iams.yaml
|
||||
|
||||
13
apps/iam/wb/org-rules.yaml
Normal file
13
apps/iam/wb/org-rules.yaml
Normal file
@ -0,0 +1,13 @@
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: iam-zitadel-org-rules
|
||||
namespace: iam
|
||||
labels:
|
||||
app.kubernetes.io/managed-by: kustomize
|
||||
data:
|
||||
org-rules-prod.json: |
|
||||
{
|
||||
"default_org_id": "362899668818023622",
|
||||
"rules": []
|
||||
}
|
||||
17
apps/iam/wb/service.yaml
Normal file
17
apps/iam/wb/service.yaml
Normal file
@ -0,0 +1,17 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: iams
|
||||
namespace: iam
|
||||
labels:
|
||||
app.kubernetes.io/managed-by: kustomize
|
||||
spec:
|
||||
ports:
|
||||
- name: http
|
||||
port: 8080
|
||||
protocol: TCP
|
||||
targetPort: 8080
|
||||
selector:
|
||||
app: iams
|
||||
sessionAffinity: None
|
||||
type: ClusterIP
|
||||
23
apps/iam/wb/spicedb-schema.yaml
Normal file
23
apps/iam/wb/spicedb-schema.yaml
Normal file
@ -0,0 +1,23 @@
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: iam-spicedb-schema
|
||||
namespace: iam
|
||||
data:
|
||||
iam.zed: "definition auth_group {\n\trelation grants: django_permission\n}\n\n// Org structure. department без\
|
||||
\ parent между department.\ndefinition department {\n\trelation tenant: tenant\n\trelation member: user\n\t\
|
||||
relation 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"
|
||||
@ -6,7 +6,7 @@ resources:
|
||||
- ./infrastructure
|
||||
|
||||
# apps
|
||||
#- ../../apps/iam/wb
|
||||
- ../../apps/iam/wb
|
||||
- ../../apps/notes/wb
|
||||
- ../../apps/rfi/wb
|
||||
- ../../apps/eav/wb
|
||||
|
||||
Loading…
Reference in New Issue
Block a user