Skip to content

Commit

Permalink
#12 authentication
Browse files Browse the repository at this point in the history
- k8s config
  • Loading branch information
maciejgz committed Oct 8, 2023
1 parent 9c8252e commit 56bbcbd
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 6 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,13 @@ Linux:
### Kubernetes

K8S scripts should be run in the following order from the project root directory:
</br> Run all scripts from the root directory:

```docker
.\k8s\start.bat
```

Or run each scripts separately:
- [k8s](k8s) - directory with global configuration:
- special role and privileges
- ingress
Expand Down
8 changes: 8 additions & 0 deletions k8s/start.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@echo off
kubectl apply -f k8s
kubectl apply -f ms-admin/k8s
kubectl apply -f ms-api-gateway/k8s
kubectl apply -f ms-cms-service/k8s
kubectl apply -f ms-stock-service/k8s


5 changes: 5 additions & 0 deletions ms-api-gateway/src/main/resources/application-k8s.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ management:

## API Gateway routes
spring:
security:
oauth2:
resourceserver:
jwt:
jwk-set-uri: http://${DATA_REDIS_HOST}:8082/realms/ms/protocol/openid-connect/certs
cloud:
gateway:
routes:
Expand Down
1 change: 1 addition & 0 deletions ms-cms-service/k8s/configmap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ apiVersion: v1
metadata:
name: ms-cms-service
data:
DATA_REDIS_HOST: "192.168.0.129"
application-k8s.properties: |-
spring.datasource.url=jdbc:postgresql://localhost:5433/cms
spring.profiles.active=k8s
7 changes: 6 additions & 1 deletion ms-cms-service/k8s/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,9 @@ spec:
- name: SPRING_CLOUD_KUBERNETES_SECRETS_ENABLEAPI
value: "true"
- name: SPRING_PROFILES_ACTIVE
value: k8s
value: k8s
- name: DATA_REDIS_HOST
valueFrom:
configMapKeyRef:
name: ms-cms-service
key: DATA_REDIS_HOST
5 changes: 3 additions & 2 deletions ms-cms-service/src/main/resources/application-k8s.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
spring.datasource.url=jdbc:postgresql://192.168.0.129:5432/cms
spring.kafka.bootstrap-servers=192.168.0.129:9092
spring.datasource.url=jdbc:postgresql://${DATA_REDIS_HOST}:5432/cms
spring.kafka.bootstrap-servers=${DATA_REDIS_HOST}:9092
spring.security.oauth2.resourceserver.jwt.jwk-set-uri=http://${DATA_REDIS_HOST}:8082/realms/ms/protocol/openid-connect/certs
1 change: 1 addition & 0 deletions ms-stock-service/k8s/configmap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ apiVersion: v1
metadata:
name: ms-stock-service
data:
HOST_IP: "192.168.0.129"
application-k8s.properties: |-
spring.datasource.url=jdbc:postgresql://localhost:5433/stock
spring.profiles.active=k8s
7 changes: 6 additions & 1 deletion ms-stock-service/k8s/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,9 @@ spec:
- name: SPRING_CLOUD_KUBERNETES_SECRETS_ENABLEAPI
value: "true"
- name: SPRING_PROFILES_ACTIVE
value: k8s
value: k8s
- name: HOST_IP
valueFrom:
configMapKeyRef:
name: ms-stock-service
key: HOST_IP
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
spring.datasource.url=jdbc:postgresql://192.168.0.129:5432/stock
spring.kafka.bootstrap-servers=192.168.0.129:9092
spring.datasource.url=jdbc:postgresql://${HOST_IP}:5432/stock
spring.kafka.bootstrap-servers=${HOST_IP}:9092
spring.security.oauth2.resourceserver.jwt.jwk-set-uri=http://${HOST_IP}:8082/realms/ms/protocol/openid-connect/certs

0 comments on commit 56bbcbd

Please sign in to comment.