Skip to content

Commit

Permalink
Merge pull request #33 from szymonpoltorak/kubernetes
Browse files Browse the repository at this point in the history
Kubernetes
  • Loading branch information
szymonpoltorak authored Jul 16, 2023
2 parents 69a20be + 08e97a0 commit 4958bea
Show file tree
Hide file tree
Showing 19 changed files with 158 additions and 14 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ I used various technologies which I will list below.

* makefile,
* docker,
* kubernetes,
* minikube,
* postman.

## Installation of docker
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: "3"
version: "3.1"

services:
maildev:
Expand Down
37 changes: 37 additions & 0 deletions kubernetes/backend-deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: backend-deployment
spec:
replicas: 1
selector:
matchLabels:
app: backend
template:
metadata:
labels:
app: backend
spec:
containers:
- name: backend
image: social-app-backend
ports:
- containerPort: 8080
env:
- name: SPRING_DATASOURCE_URL
value: jdbc:postgresql://postgres-service:5432/socialapp
- name: GOOGLE_CLIENT_ID
value: YourId
- name: GOOGLE_CLIENT_SECRET
value: YourSecret
- name: GITHUB_CLIENT_ID
value: YourID
- name: GITHUB_CLIENT_SECRET
value: YourSecret
- name: FRONTEND_URL
value: http://frontend-service:80
- name: MAIL_HOST
value: maildev-service
dependsOn:
- name: postgres-service
- name: maildev-service
11 changes: 11 additions & 0 deletions kubernetes/backend-service.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: Service
metadata:
name: backend-service
spec:
selector:
app: backend
ports:
- protocol: TCP
port: 8080
targetPort: 8080
19 changes: 19 additions & 0 deletions kubernetes/frontend-deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: frontend-deployment
spec:
replicas: 1
selector:
matchLabels:
app: frontend
template:
metadata:
labels:
app: frontend
spec:
containers:
- name: frontend
image: social-app-frontend
ports:
- containerPort: 80
11 changes: 11 additions & 0 deletions kubernetes/frontend-service.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: Service
metadata:
name: frontend-service
spec:
selector:
app: frontend
ports:
- protocol: TCP
port: 80
targetPort: 80
20 changes: 20 additions & 0 deletions kubernetes/maildev-deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: maildev-deployment
spec:
replicas: 1
selector:
matchLabels:
app: maildev
template:
metadata:
labels:
app: maildev
spec:
containers:
- name: maildev
image: maildev/maildev
ports:
- containerPort: 1080
- containerPort: 1025
14 changes: 14 additions & 0 deletions kubernetes/maildev-service.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
kind: Service
metadata:
name: maildev-service
spec:
selector:
app: maildev
ports:
- protocol: TCP
port: 1080
targetPort: 1080
- protocol: TCP
port: 1025
targetPort: 1025
26 changes: 26 additions & 0 deletions kubernetes/postgres-deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: postgres-deployment
spec:
replicas: 1
selector:
matchLabels:
app: postgres
template:
metadata:
labels:
app: postgres
spec:
containers:
- name: postgres
image: social-app-postgres
ports:
- containerPort: 5432
env:
- name: POSTGRES_DB
value: socialapp
- name: POSTGRES_USER
value: postgres
- name: POSTGRES_PASSWORD
value: none
11 changes: 11 additions & 0 deletions kubernetes/postgres-service.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: Service
metadata:
name: postgres-service
spec:
selector:
app: postgres
ports:
- protocol: TCP
port: 5432
targetPort: 5432
2 changes: 1 addition & 1 deletion social-app-backend/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: "3"
version: "3.1"

services:
maildev:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package razepl.dev.socialappbackend.admin;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;
import razepl.dev.socialappbackend.admin.interfaces.IAdminController;
Expand All @@ -16,7 +15,6 @@
import static razepl.dev.socialappbackend.admin.Constants.ADMIN_MAPPING;
import static razepl.dev.socialappbackend.admin.Constants.ENDPOINT_MATCHER;

@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping(value = ADMIN_MAPPING)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,18 @@
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;
import razepl.dev.socialappbackend.auth.apicalls.*;
import razepl.dev.socialappbackend.auth.interfaces.AuthInterface;
import razepl.dev.socialappbackend.auth.interfaces.AuthServiceInterface;
import razepl.dev.socialappbackend.config.oauth.constants.RedirectUrls;

import static razepl.dev.socialappbackend.auth.constants.AuthMappings.*;

/**
* Class to control auth endpoints.
* It implements {@link AuthInterface}.
*/
@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping(value = AUTH_MAPPING)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public final void onAuthenticationFailure(HttpServletRequest request,
AuthenticationException exception) throws IOException {
String redirectUrl = frontendUrl + RedirectUrls.FAILURE_URL;

log.error("OAuth failure login. Redirecting to : {}", redirectUrl);

getRedirectStrategy().sendRedirect(request, response, redirectUrl);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ public final void handle(HttpServletRequest request,
HttpServletResponse response,
Authentication authentication) throws IOException {
log.error("Principal : {}", authentication.getPrincipal());
log.error("Credentials : {}", authentication.getCredentials());

StringBuilder redirectBuilder = new StringBuilder(200);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public class OidcService extends OidcUserService {
public final OidcUser loadUser(OidcUserRequest userRequest) throws OAuth2AuthenticationException {
OidcUser oidcUser = super.loadUser(userRequest);

log.info("Loading OIDC user.");

return oauthUserProcessor.processOAuthUserRegistration(userRequest, oidcUser);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.*;
import razepl.dev.socialappbackend.entities.user.User;
Expand All @@ -17,7 +16,6 @@
/**
* Controller for /api/home endpoints.
*/
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping(value = HOME_MAPPING)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
Expand All @@ -21,7 +20,6 @@
/**
* Controller for /api/search endpoints
*/
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping(value = SEARCH_SITE_MAPPING)
Expand Down
2 changes: 1 addition & 1 deletion social-app-frontend/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: "3"
version: "3.1"

services:
frontend:
Expand Down

0 comments on commit 4958bea

Please sign in to comment.