Skip to content

Commit 4bbb2b8

Browse files
author
Adnane Miliari
committed
🚀add Kubernetes manifests with Skaffold configuration
1 parent 8b8b5a6 commit 4bbb2b8

File tree

38 files changed

+759
-256
lines changed

38 files changed

+759
-256
lines changed

apiKey-manager/src/main/java/dev/nano/ApiKeyManagerApplication.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
import org.springframework.boot.SpringApplication;
44
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
56

67
@SpringBootApplication
8+
@EnableDiscoveryClient
79
public class ApiKeyManagerApplication {
810
public static void main(String[] args) {
911
SpringApplication.run(ApiKeyManagerApplication.class, args);

apiKey-manager/src/main/resources/db/data.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
-- First insert API Keys and store their IDs
22
INSERT INTO api_keys (id, key, client, description, created_date, expiration_date, enabled, never_expires, approved,
33
revoked)
4-
SELECT nextval('api_key_sequence'), t.key_value, t.client, t.description, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP + INTERVAL '365 days', t.enabled, t.never_expires, t.approved, t.revoked
4+
SELECT nextval('api_key_sequence'), t.key, t.client, t.description, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP + INTERVAL '365 days', t.enabled, t.never_expires, t.approved, t.revoked
55
FROM (
66
VALUES
77
('ecom-frontend-key-2024', 'E-commerce Frontend', 'API Key for frontend application', true, false, true, false),
88
('mobile-app-key-2024', 'Mobile Application', 'API Key for mobile app', true, false, true, false),
99
('admin-dashboard-key-2024', 'Admin Dashboard', 'API Key for admin dashboard', true, true, true, false),
1010
-- Internal traffic key (never exposed publicly)
1111
('internal-service-key', 'Internal Service', 'API Key for inter-service calls', true, true, true, false)
12-
) AS t(key_value, client, description, enabled, never_expires, approved, revoked);
12+
) AS t(key, client, description, enabled, never_expires, approved, revoked);
1313

1414
-- Then insert Applications using the actual API key IDs by looking up the key value
1515
INSERT INTO applications (id, application_name, enabled, approved, revoked, api_key_id)

common/src/main/resources/shared-application-docker.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,28 @@ jwt:
4848
auth:
4949
converter:
5050
principle-attribute: preferred_username
51+
52+
resilience4j:
53+
circuitbreaker:
54+
instances:
55+
productService:
56+
sliding-window-type: count_based
57+
sliding-window-size: 5
58+
minimum-number-of-calls: 5
59+
failure-rate-threshold: 50
60+
wait-duration-in-open-state: 30s
61+
orderService:
62+
sliding-window-type: count_based
63+
sliding-window-size: 5
64+
minimum-number-of-calls: 5
65+
failure-rate-threshold: 50
66+
wait-duration-in-open-state: 30s
67+
retry:
68+
instances:
69+
orderService:
70+
max-attempts: 3
71+
wait-duration: 1000ms
72+
timelimiter:
73+
instances:
74+
orderService:
75+
timeout-duration: 3s

common/src/main/resources/shared-application-kube.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@ spring:
2020
oauth2:
2121
resourceserver:
2222
jwt:
23-
issuer-uri: http://keycloak:8080/realms/demo-realm
23+
issuer-uri: http://localhost/realms/demo-realm
24+
25+
eureka:
26+
client:
27+
enabled: false
2428

2529
jwt:
2630
auth:

customer/pom.xml

Lines changed: 5 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -105,106 +105,13 @@
105105
<version>${lombok.mapstruct.binding.version}</version>
106106
</path>
107107
</annotationProcessorPaths>
108-
<release>17</release>
108+
<release>17</release>
109109
</configuration>
110110
</plugin>
111+
<plugin>
112+
<groupId>com.google.cloud.tools</groupId>
113+
<artifactId>jib-maven-plugin</artifactId>
114+
</plugin>
111115
</plugins>
112116
</build>
113-
<profiles>
114-
<profile>
115-
<id>jib-build-push-image-to-local</id>
116-
<activation>
117-
<activeByDefault>false</activeByDefault>
118-
</activation>
119-
<build>
120-
<plugins>
121-
<plugin>
122-
<groupId>com.google.cloud.tools</groupId>
123-
<artifactId>jib-maven-plugin</artifactId>
124-
<version>${jib.maven.plugin.version}</version>
125-
<configuration>
126-
<from>
127-
<image>openjdk:17</image>
128-
<platforms>
129-
<platform>
130-
<architecture>arm64</architecture>
131-
<os>linux</os>
132-
</platform>
133-
</platforms>
134-
</from>
135-
<to>
136-
<image>${image}</image>
137-
<tags>
138-
<tag>latest</tag>
139-
</tags>
140-
</to>
141-
<container>
142-
<jvmFlags>
143-
<jvmFlag>-Dspring.profiles.active=docker</jvmFlag>
144-
</jvmFlags>
145-
</container>
146-
</configuration>
147-
<executions>
148-
<execution>
149-
<phase>package</phase>
150-
<goals>
151-
<goal>dockerBuild</goal>
152-
</goals>
153-
</execution>
154-
</executions>
155-
</plugin>
156-
</plugins>
157-
</build>
158-
</profile>
159-
<profile>
160-
<id>jib-build-push-image-to-dockerhub</id>
161-
<activation>
162-
<activeByDefault>false</activeByDefault>
163-
</activation>
164-
<build>
165-
<plugins>
166-
<plugin>
167-
<groupId>com.google.cloud.tools</groupId>
168-
<artifactId>jib-maven-plugin</artifactId>
169-
<version>${jib.maven.plugin.version}</version>
170-
<configuration>
171-
<from>
172-
<image>openjdk:17</image>
173-
<platforms>
174-
<platform>
175-
<architecture>amd64</architecture>
176-
<os>linux</os>
177-
</platform>
178-
<platform>
179-
<architecture>arm64</architecture>
180-
<os>linux</os>
181-
</platform>
182-
</platforms>
183-
</from>
184-
<to>
185-
<image>${image}</image>
186-
<tags>
187-
<tag>${image.custom.tag}</tag>
188-
<tag>latest</tag>
189-
</tags>
190-
</to>
191-
<container>
192-
<jvmFlags>
193-
<jvmFlag>-Dspring.profiles.active=docker</jvmFlag>
194-
</jvmFlags>
195-
</container>
196-
</configuration>
197-
<executions>
198-
<execution>
199-
<phase>package</phase>
200-
<goals>
201-
<goal>build</goal>
202-
</goals>
203-
</execution>
204-
</executions>
205-
</plugin>
206-
</plugins>
207-
</build>
208-
</profile>
209-
</profiles>
210117
</project>

customer/src/main/java/dev/nano/customer/CustomerApplication.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
@SpringBootApplication(
1010
scanBasePackages = {
1111
"dev.nano.customer",
12-
"dev.nano.amqp"
12+
"dev.nano.amqp",
13+
"dev.nano.clients"
1314
}
1415
)
1516
@EnableFeignClients(

docker/compose/docker-compose.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,24 @@ services:
265265
- zipkin
266266
- rabbitmq
267267
- keycloak
268+
apikey-manager:
269+
image: miliariadnane/apikey-manager:latest
270+
container_name: apikey-manager
271+
ports:
272+
- "8006:8006"
273+
environment:
274+
- SPRING_PROFILES_ACTIVE=docker
275+
networks:
276+
- spring
277+
- postgres
278+
- monitoring
279+
depends_on:
280+
- eureka-server
281+
- gateway
282+
- postgres
283+
- zipkin
284+
- rabbitmq
285+
- keycloak
268286

269287
networks:
270288
postgres:

docker/config/postgres/init.sql/init.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ CREATE DATABASE customer;
33
CREATE DATABASE product;
44
CREATE DATABASE "order";
55
CREATE DATABASE payment;
6-
CREATE DATABASE apikey_manager;
7-
CREATE DATABASE keycloak;
6+
CREATE DATABASE "apikey-manager";
7+
CREATE DATABASE keycloak;

feign-clients/src/main/resources/clients-docker.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ clients.product.url=http://product:8002
33
clients.order.url=http://order:8003
44
clients.notification.url=http://notification:8004
55
clients.payment.url=http://payment:8005
6-
clients.apiKey-manager.url=http://localhost:8006/api/v1/apiKey-manager/api-keys
6+
clients.apiKey-manager.url=http://apikey-manager:8006/api/v1/apiKey-manager/api-keys
77
internal.api-key=internal-service-key
Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# we don't need to specify the port in k8s because it listening on port 80
2-
clients.customer.url=http://customer
3-
clients.product.url=http://product
4-
clients.order.url=http://order
5-
clients.notification.url=http://notification
6-
clients.payment.url=http://payment
7-
clients.apiKey-manager.url=http://apiKey-manager
2+
clients.customer.url=http://localhost/api/v1/customer
3+
clients.product.url=http://localhost/api/v1/product
4+
clients.order.url=http://localhost/api/v1/order
5+
clients.notification.url=http://localhost/api/v1/notification
6+
clients.payment.url=http://localhost/api/v1/payment
7+
clients.apiKey-manager.url=http://localhost/api/v1/apiKey-manager/api-keys
8+
internal.api-key=internal-service-key

0 commit comments

Comments
 (0)