-
Notifications
You must be signed in to change notification settings - Fork 0
/
arch-istio-dev-all-in-one.yaml
1138 lines (1077 loc) · 43.5 KB
/
arch-istio-dev-all-in-one.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
apiVersion: v1
kind: Namespace
metadata:
name: arch-namespace
labels:
istio-injection: disabled
spec: {}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: arch-admin-role
namespace: arch-namespace
rules:
- apiGroups: [""]
resources: ["endpoints", "services", "configmaps", "pods", "secrets"]
verbs: ["get", "list", "watch"]
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: arch-admin
namespace: arch-namespace
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: arch-admin-binding
namespace: arch-namespace
subjects:
- kind: ServiceAccount
apiGroup: ""
name: arch-admin
namespace: arch-namespace
- kind: ServiceAccount
apiGroup: ""
name: default
namespace: arch-namespace
roleRef:
kind: Role
apiGroup: ""
name: arch-admin-role
---
apiVersion: apps/v1
kind: Deployment
metadata:
namespace: arch-namespace
name: arch-jaeger-deployment
labels:
app: arch-jaeger-deployment
spec:
replicas: 1
selector:
matchLabels:
app: arch-jaeger
strategy: {}
template:
metadata:
labels:
app: arch-jaeger
spec:
serviceAccountName: arch-admin
containers:
- image: jaegertracing/all-in-one:1.51.0
name: jaeger-all-in-one
env:
- name: spring.cloud.kubernetes.discovery.primary-port-name
value: otlp-http
ports:
- containerPort: 4318
name: otlp-http
- containerPort: 4317
name: otlp-grpc
- containerPort: 16686
name: frontend
---
apiVersion: v1
kind: Service
metadata:
name: arch-jaeger
namespace: arch-namespace
labels:
app: arch-jaeger
primary-port-name: otlp-http
spec:
ports:
- port: 4317
name: otlp-grpc
targetPort: 4317
- port: 4318
name: otlp-http
targetPort: 4318
- port: 16686
name: frontend
targetPort: 16686
nodePort: 30001
selector:
app: arch-jaeger
type: NodePort
sessionAffinity: None
---
apiVersion: v1
kind: ConfigMap
metadata:
name: arch-otel-col-configmap
namespace: arch-namespace
labels:
spring.cloud.kubernetes.config: "true"
annotations:
spring.cloud.kubernetes.configmap.apps: "arch-otel-col"
data:
collector-config.yaml: |
receivers:
otlp:
protocols:
http:
processors:
batch:
exporters:
logging:
# basic | normal | detailed
verbosity: basic
otlp/jaeger:
endpoint: "http://arch-jaeger:4317"
tls:
insecure: true
service:
pipelines:
metrics:
receivers: [otlp]
processors: [batch]
exporters: [logging]
traces:
receivers: [otlp]
processors: [batch]
exporters: [otlp/jaeger]
#exporters: [logging, otlp/jaeger]
logs:
receivers: [otlp]
processors: [batch]
exporters: [logging]
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: arch-otel-col-deployment
name: arch-otel-col-deployment
namespace: arch-namespace
spec:
replicas: 1
selector:
matchLabels:
app: arch-otel-col
strategy: {}
template:
metadata:
labels:
app: arch-otel-col
spec:
serviceAccountName: arch-admin
containers:
- image: otel/opentelemetry-collector-contrib:0.101.0
name: otel-collector
command:
- "/otelcol-contrib"
- "--config=/conf/otel-collector-config.yaml"
ports:
- containerPort: 4318
name: otlp-http
volumeMounts:
- name: otel-collector-config-vol
mountPath: /conf
env:
- name: spring.cloud.kubernetes.discovery.primary-port-name
value: otlp-http
volumes:
- name: otel-collector-config-vol
configMap:
name: arch-otel-col-configmap
items:
- key: collector-config.yaml
path: otel-collector-config.yaml
---
apiVersion: v1
kind: Service
metadata:
name: arch-otel-col
namespace: arch-namespace
labels:
app: arch-otel-col
primary-port-name: otlp-http
spec:
ports:
- port: 4318
name: otlp-http
targetPort: 4318
- port: 4317
name: otlp-grpc
targetPort: 4317
selector:
app: arch-otel-col
type: ClusterIP
sessionAffinity: None
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: arch-config-watcher-deployment
namespace: arch-namespace
spec:
selector:
matchLabels:
app: arch-config-watcher
template:
metadata:
labels:
app: arch-config-watcher
spec:
serviceAccountName: arch-admin
containers:
- name: arch-config-watcher
image: springcloud/spring-cloud-kubernetes-configuration-watcher:3.1.1
imagePullPolicy: IfNotPresent
readinessProbe:
httpGet:
port: 8888
path: /actuator/health/readiness
initialDelaySeconds: 90
livenessProbe:
httpGet:
port: 8888
path: /actuator/health/liveness
initialDelaySeconds: 60
ports:
- containerPort: 8888
env:
- name: LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_CLOUD_KUBERNETES_CONFIGURATION_WATCHER
value: DEBUG
- name: LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_CLOUD_KUBERNETES_CLIENT_CONFIG_RELOAD
value: DEBUG
- name: LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_CLOUD_KUBERNETES_COMMONS_CONFIG_RELOAD
value: DEBUG
- name: SPRING_CLOUD_KUBERNETES_RELOAD_NAMESPACES_0
value: "arch-namespace"
- name: SPRING_CLOUD_KUBERNETES_CONFIGURATION_WATCHER_REFRESHDELAY
value: "10000"
- name: spring.cloud.kubernetes.discovery.primary-port-name
value: http
- name: user.timezone
value: "GMT+08"
- name: file.encoding
value: "UTF-8"
---
apiVersion: v1
kind: Service
metadata:
name: arch-config-watcher
namespace: arch-namespace
labels:
app: arch-config-watcher
primary-port-name: http
spec:
ports:
- name: http
port: 8888
targetPort: 8888
selector:
app: arch-config-watcher
type: ClusterIP
---
apiVersion: v1
kind: ConfigMap
metadata:
name: arch-app-common-env-configmap
namespace: arch-namespace
labels:
spring.cloud.kubernetes.config: "true"
annotations:
spring.cloud.kubernetes.configmap.apps: "arch-iam, arch-users, arch-app"
data:
spring.output.ansi.enabled: "always"
ARCH_VERSION: "1.0_istio"
PROFILES: "kubernetes"
# JAVA_OPTS: "-Duser.timezone=GMT+08 -Dfile.encoding=UTF-8 -javaagent:/opentelemetry-javaagent.jar"
JAVA_OPTS: "-Duser.timezone=GMT+08 -Dfile.encoding=UTF-8"
ARCH_USERS_ADDR: "http://arch-users:8081"
ISSUE_ADDR: "http://arch-gateway-istio:9000/arch-iam"
# OTEL_EXPORTER_OTLP_ENDPOINT: "http://arch-otel-col:4318"
# OTEL_LOGS_EXPORTER: "otlp"
# OTEL_CONFIG_FILE: ""
# management.otlp.metrics.export.enabled: "true"
# management.tracing.enabled: "true"
---
apiVersion: v1
kind: Secret
metadata:
name: arch-iam
namespace: arch-namespace
labels:
spring.cloud.kubernetes.secret: "true"
annotations:
spring.cloud.kubernetes.configmap.apps: "arch-iam"
data:
OAUTH2_CLIENT_SECRET: c2VjcmV0aWFt
---
apiVersion: v1
kind: ConfigMap
metadata:
name: arch-iam
namespace: arch-namespace
labels:
spring.cloud.kubernetes.config: "true"
annotations:
spring.cloud.kubernetes.configmap.apps: "arch-iam"
data:
application-kubernetes.yaml: |-
server:
port: 9090
shutdown: graceful
spring:
jackson:
date-format: yyyy-MM-dd HH:mm:ss
time-zone: GMT+8
default-property-inclusion: NON_NULL
cache:
type: caffeine
caffeine:
spec: initialCapacity=128,maximumSize=10000,expireAfterWrite=30s
task:
scheduling:
thread-name-prefix: "arch-scheduling-"
pool:
size: 3
security:
oauth2:
authorizationserver:
issuer: ${ISSUE_ADDR:http://localhost:9000/arch-iam}
client:
arch-web:
token:
refresh-token-time-to-live: P1D
registration:
client-id: arch-web
client-name: arch-web
# secretweb
client-secret: $2a$10$ueyW3xrcU4fV05A0t3lC0.KWmYYEAnQknz3A64vfBr0Rwyc/etHsW
client-authentication-methods: [ client_secret_post, client_secret_basic ]
authorization-grant-types: [ client_credentials, password, refresh_token]
scopes: [ WEB ]
arch-app:
token:
access-token-time-to-live: P1D
registration:
client-id: arch-app
client-name: arch-app
# secret
client-secret: $2a$10$XWY/JeWE1SpNQus1mCCJqeh93jrj.hjGDHqJwKLuEEBwv/s5Xylm2
client-authentication-methods: [client_secret_post, client_secret_basic]
authorization-grant-types: [client_credentials]
scopes: [SERVICE]
arch-users:
token:
access-token-time-to-live: P1D
registration:
client-id: arch-users
client-name: arch-users
# secretusers
client-secret: $2a$10$2mbgP421pk.kLvbEeyZNKOFhIewdVfg/9dSkIl34ROkfXu./xi0/O
client-authentication-methods: [ client_secret_post, client_secret_basic ]
authorization-grant-types: [ client_credentials ]
scopes: [ SERVICE ]
arch-iam:
token:
access-token-time-to-live: P1D
registration:
client-id: ${spring.application.name}
client-name: ${spring.application.name}
# secretiam
client-secret: $2a$10$b7VN/WDZLSiZKmQKwVJBweiOVaJDiT52Jm35KXoVSouFEbtTg7tIe
client-authentication-methods: [ client_secret_post, client_secret_basic ]
authorization-grant-types: [ client_credentials ]
scopes: [ SERVICE ]
client:
registration:
ArchIAM:
provider: ArchIAM
client-id: ${spring.application.name}
client-name: ${spring.application.name}
authorization-grant-type: client_credentials
client-authentication-method: client_secret_basic
scope: [ SERVICE ]
provider:
ArchIAM:
# 设置 issuer-uri,让客户端启动时像此授权中心动态获取 OAuth2 和 OIDC 周知端点 URL
#issuer-uri: ${ISSUE_ADDR:http://localhost:9000/arch-iam}
# 不使用签发地址进行解析时,手动指定如下四个周知端点 URL
authorizationUri: ${ISSUE_ADDR:http://localhost:9000/arch-iam}/oauth2/authorize
token-uri: ${ISSUE_ADDR:http://localhost:9000/arch-iam}/oauth2/token
jwk-set-uri: ${ISSUE_ADDR:http://localhost:9000/arch-iam}/oauth2/jwks
user-info-uri: ${ISSUE_ADDR:http://localhost:9000/arch-iam}/userinfo
resourceserver:
jwt:
public-key-location: classpath:arch-iam/public.pem
logging:
pattern:
console: "%clr(%d{HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(-){faint} %clr([%t]){faint} %clr(%-40logger{39}){cyan}[%line]%clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:%wEx}"
level:
org.springframework: info
feign: debug
springdoc:
version: "${ARCH_VERSION}"
api-docs:
version: openapi_3_1
path: /v3/api-docs/arch-iam
show-oauth2-endpoints: true
swagger-ui:
urls:
- name: arch-users
url: /v3/api-docs/arch-users
- name: arch-iam
url: /v3/api-docs/arch-iam
- name: arch-app
url: /v3/api-docs/arch-app
display-request-duration: true
groups-order: DESC
operationsSorter: method
disable-swagger-default-url: true
use-root-path: true
oauth:
client-id: arch-web
client-secret: secretweb
oAuthFlow:
authorizationUrl: ${ISSUE_ADDR:http://localhost:9000/arch-iam}/oauth2/authorize
tokenUrl: ${ISSUE_ADDR:http://localhost:9000/arch-iam}/oauth2/token
show-actuator: false
cache:
disabled: true
management:
endpoints:
web:
exposure:
include: "*"
endpoint:
health:
probes:
enabled: true
refresh:
enabled: true
health:
livenessstate:
enabled: true
readinessstate:
enabled: true
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: arch-iam-deployment
name: arch-iam-deployment
namespace: arch-namespace
spec:
replicas: 1
selector:
matchLabels:
app: arch-iam
strategy: {}
template:
metadata:
labels:
app: arch-iam
spec:
serviceAccountName: arch-admin
containers:
- image: docker.io/reion78/arch-iam:1.0_istio
name: arch-iam
ports:
- containerPort: 9090
name: http
readinessProbe:
httpGet:
port: 9090
path: /actuator/health/readiness
initialDelaySeconds: 90
livenessProbe:
httpGet:
port: 9090
path: /actuator/health/liveness
initialDelaySeconds: 60
# 优雅停机
lifecycle:
preStop:
exec:
command: [ "sh", "-c", "sleep 10" ]
# 外部配置
volumeMounts:
- name: config-volume
mountPath: /config
env:
- name: OTEL_SERVICE_NAME
value: arch-iam
- name: spring.security.oauth2.client.registration.ArchIAM.client-secret
valueFrom:
secretKeyRef:
name: arch-iam
key: OAUTH2_CLIENT_SECRET
envFrom:
- configMapRef:
name: arch-app-common-env-configmap
volumes:
- name: config-volume
configMap:
name: arch-iam
---
apiVersion: v1
kind: Service
metadata:
name: arch-iam
namespace: arch-namespace
labels:
app: arch-iam
primary-port-name: http
spec:
ports:
- port: 9090
name: http
targetPort: 9090
selector:
app: arch-iam
type: ClusterIP
sessionAffinity: None
---
apiVersion: v1
kind: Secret
metadata:
name: arch-users
namespace: arch-namespace
labels:
spring.cloud.kubernetes.secret: "true"
annotations:
spring.cloud.kubernetes.configmap.apps: "arch-users"
data:
OAUTH2_CLIENT_SECRET: c2VjcmV0dXNlcnM=
---
apiVersion: v1
kind: ConfigMap
metadata:
name: arch-users
namespace: arch-namespace
labels:
spring.cloud.kubernetes.config: "true"
annotations:
spring.cloud.kubernetes.configmap.apps: "arch-users"
data:
application-kubernetes.yml: |-
server:
port: 8081
shutdown: graceful
spring:
jackson:
# 日期格式
date-format: yyyy-MM-dd HH:mm:ss
# 时区
time-zone: GMT+8
# 忽略 null 的属性值
default-property-inclusion: NON_NULL
# 缓存配置
cache:
# 启用自动化装配的 caffeine 本地缓存
type: caffeine
caffeine:
# 默认容量为 128 最大 10000 且缓存过期时间 30s 的本地缓存
spec: initialCapacity=128,maximumSize=10000,expireAfterWrite=30s
# 调度器线程池
task:
scheduling:
thread-name-prefix: "arch-scheduling-"
pool:
size: 3
# 数据源配置
datasource:
# 使用 hikari 连接池的数据源配置
hikari:
jdbc-url: jdbc:h2:mem:test
username: sa
password: sa
driver-class-name: org.h2.Driver
# 设置使用内嵌数据库时,执行表结构创建及数据插入
sql:
init:
# 指定使用嵌入式数据库时,才执行 DDL DML
mode: EMBEDDED
# 指定 DDL 路径
schemaLocations: classpath:/META-INF/sql/schema.sql
# 指定 DML 路径
dataLocations: classpath:/META-INF/sql/data.sql
# 打开 H2 数据库网页版管理页面,登录地址 localhost:8081/h2
# 注意:需要将此配置的路径从 Security 权限验证中排除
h2:
console:
enabled: true
path: /h2
settings:
# 是否允许其他主机访问
webAllowOthers: false
# 密码如设置需 128 位
#web-admin-password: admin
# JPA 设置
jpa:
# 设置数据平台方言
database-platform: org.hibernate.dialect.H2Dialect
show-sql: true
hibernate:
ddl-auto: none
security:
oauth2:
# 客户端
client:
registration:
ArchIAM:
provider: ArchIAM
client-id: ${spring.application.name}
client-name: ${spring.application.name}
authorization-grant-type: client_credentials
client-authentication-method: client_secret_basic
scope: [ SERVICE ]
provider:
ArchIAM:
# 设置 issuer-uri,让客户端启动时像此授权中心动态获取 OAuth2 和 OIDC 周知端点 URL
#issuer-uri: ${ISSUE_ADDR:http://localhost:9000/arch-iam}
# 不使用签发地址进行解析时,手动指定如下四个周知端点 URL
authorizationUri: ${ISSUE_ADDR:http://localhost:9000/arch-iam}/oauth2/authorize
token-uri: ${ISSUE_ADDR:http://localhost:9000/arch-iam}/oauth2/token
jwk-set-uri: ${ISSUE_ADDR:http://localhost:9000/arch-iam}/oauth2/jwks
user-info-uri: ${ISSUE_ADDR:http://localhost:9000/arch-iam}/userinfo
# 资源服务器
resourceserver:
jwt:
public-key-location: classpath:arch-iam/public.pem
# 日志配置
logging:
pattern:
console: "%clr(%d{HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(-){faint} %clr([%t]){faint} %clr(%-40logger{39}){cyan}[%line]%clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:%wEx}"
level:
org.springframework.security: info
io.github.reionchan.rpc.feign: debug
# API 文档
springdoc:
version: "${ARCH_VERSION}"
api-docs:
version: openapi_3_1
path: /v3/api-docs/arch-users
swagger-ui:
urls:
- name: arch-users
url: /v3/api-docs/arch-users
- name: arch-iam
url: /v3/api-docs/arch-iam
- name: arch-app
url: /v3/api-docs/arch-app
display-request-duration: true
groups-order: DESC
operationsSorter: method
disable-swagger-default-url: true
use-root-path: true
oauth:
client-id: arch-web
client-secret: secretweb
oAuthFlow:
authorizationUrl: ${ISSUE_ADDR:http://localhost:9000/arch-iam}/oauth2/authorize
tokenUrl: ${ISSUE_ADDR:http://localhost:9000/arch-iam}/oauth2/token
show-actuator: false
cache:
disabled: true
# 展示指标端点
management:
endpoints:
web:
exposure:
include: "*"
endpoint:
health:
probes:
enabled: true
refresh:
enabled: true
health:
livenessstate:
enabled: true
readinessstate:
enabled: true
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: arch-users-deployment
name: arch-users-deployment
namespace: arch-namespace
spec:
replicas: 1
selector:
matchLabels:
app: arch-users
strategy: {}
template:
metadata:
labels:
app: arch-users
spec:
serviceAccountName: arch-admin
containers:
- image: docker.io/reion78/arch-users:1.0_istio
name: arch-users
ports:
- containerPort: 8081
name: http
readinessProbe:
httpGet:
port: 8081
path: /actuator/health/readiness
initialDelaySeconds: 90
livenessProbe:
httpGet:
port: 8081
path: /actuator/health/liveness
initialDelaySeconds: 60
# 优雅停机
lifecycle:
preStop:
exec:
command: [ "sh", "-c", "sleep 10" ]
volumeMounts:
- name: config-volume
mountPath: /config
env:
- name: OTEL_SERVICE_NAME
value: arch-users
- name: spring.security.oauth2.client.registration.ArchIAM.client-secret
valueFrom:
secretKeyRef:
name: arch-users
key: OAUTH2_CLIENT_SECRET
envFrom:
- configMapRef:
name: arch-app-common-env-configmap
volumes:
- name: config-volume
configMap:
name: arch-users
---
apiVersion: v1
kind: Service
metadata:
name: arch-users
namespace: arch-namespace
labels:
app: arch-users
primary-port-name: http
spec:
ports:
- port: 8081
name: http
targetPort: 8081
selector:
app: arch-users
type: ClusterIP
sessionAffinity: None
---
apiVersion: v1
kind: Secret
metadata:
name: arch-app
namespace: arch-namespace
labels:
spring.cloud.kubernetes.secret: "true"
annotations:
spring.cloud.kubernetes.configmap.apps: "arch-app"
data:
OAUTH2_CLIENT_SECRET: c2VjcmV0
---
apiVersion: v1
kind: ConfigMap
metadata:
name: arch-app
namespace: arch-namespace
labels:
spring.cloud.kubernetes.config: "true"
annotations:
spring.cloud.kubernetes.configmap.apps: "arch-app"
data:
application-kubernetes.yml: |-
server:
port: 8080
shutdown: graceful
spring:
jackson:
# 日期格式
date-format: yyyy-MM-dd HH:mm:ss
# 时区
time-zone: GMT+8
# 忽略 null 的属性值
default-property-inclusion: NON_NULL
# 缓存配置
cache:
# 启用自动化装配的 caffeine 本地缓存
type: caffeine
caffeine:
# 默认容量为 128 最大 10000 且缓存过期时间 30s 的本地缓存
spec: initialCapacity=128,maximumSize=10000,expireAfterWrite=30s
# 调度器线程池
task:
scheduling:
thread-name-prefix: "arch-scheduling-"
pool:
size: 3
security:
oauth2:
# 客户端
client:
registration:
ArchIAM:
provider: ArchIAM
client-id: ${spring.application.name}
client-name: ${spring.application.name}
authorization-grant-type: client_credentials
client-authentication-method: client_secret_basic
scope: [ SERVICE ]
provider:
ArchIAM:
# 不使用签发地址进行解析时,手动指定如下四个周知端点 URL
authorizationUri: ${ISSUE_ADDR:http://localhost:9000/arch-iam}/oauth2/authorize
token-uri: ${ISSUE_ADDR:http://localhost:9000/arch-iam}/oauth2/token
jwk-set-uri: ${ISSUE_ADDR:http://localhost:9000/arch-iam}/oauth2/jwks
user-info-uri: ${ISSUE_ADDR:http://localhost:9000/arch-iam}/userinfo
# 资源服务器
resourceserver:
jwt:
public-key-location: classpath:arch-iam/public.pem
# 日志配置
logging:
pattern:
console: "%clr(%d{HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(-){faint} %clr([%t]){faint} %clr(%-40logger{39}){cyan}[%line]%clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:%wEx}"
level:
org.springframework.security: info
io.github.reionchan.rpc.feign: debug
# API 文档
springdoc:
version: "${ARCH_VERSION}"
api-docs:
version: openapi_3_1
path: /v3/api-docs/arch-app
swagger-ui:
urls:
- name: arch-users
url: /v3/api-docs/arch-users
- name: arch-iam
url: /v3/api-docs/arch-iam
- name: arch-app
url: /v3/api-docs/arch-app
display-request-duration: true
groups-order: DESC
operationsSorter: method
disable-swagger-default-url: true
use-root-path: true
oauth:
client-id: arch-web
client-secret: secretweb
oAuthFlow:
authorizationUrl: ${ISSUE_ADDR:http://localhost:9000/arch-iam}/oauth2/authorize
tokenUrl: ${ISSUE_ADDR:http://localhost:9000/arch-iam}/oauth2/token
show-actuator: false
cache:
disabled: true
# 展示指标端点
management:
endpoints:
web:
exposure:
include: "*"
endpoint:
health:
probes:
enabled: true
refresh:
enabled: true
health:
livenessstate:
enabled: true
readinessstate:
enabled: true
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: arch-app-deployment
name: arch-app-deployment
namespace: arch-namespace
spec:
replicas: 1
selector:
matchLabels:
app: arch-app
strategy: {}
template:
metadata:
labels:
app: arch-app
spec:
serviceAccountName: arch-admin
containers:
- image: docker.io/reion78/arch-app:1.0_istio
name: arch-app
ports:
- containerPort: 8080
name: http
# 保活探针
readinessProbe:
httpGet:
port: 8080
path: /actuator/health/readiness
initialDelaySeconds: 90
livenessProbe:
httpGet:
port: 8080
path: /actuator/health/liveness
initialDelaySeconds: 60
# 优雅停机
lifecycle:
preStop:
exec:
command: ["sh", "-c", "sleep 10"]
volumeMounts:
- name: config-volume
mountPath: /config
env:
- name: OTEL_SERVICE_NAME
value: arch-app
- name: spring.security.oauth2.client.registration.ArchIAM.client-secret
valueFrom:
secretKeyRef:
name: arch-app
key: OAUTH2_CLIENT_SECRET
envFrom:
- configMapRef:
name: arch-app-common-env-configmap