Add Redis-backed sessions for dev validation

This commit is contained in:
2026-06-01 10:48:43 +09:00
parent 1739d607ab
commit 898671cd4d
8 changed files with 163 additions and 4 deletions
Vendored
+4 -3
View File
@@ -81,8 +81,9 @@ spec:
def OTEL_ENV = (TARGET_ENV == 'dev') ? 'dev' : (TARGET_ENV == 'stage') ? 'stage' : 'prod' def OTEL_ENV = (TARGET_ENV == 'dev') ? 'dev' : (TARGET_ENV == 'stage') ? 'stage' : 'prod'
def OTEL_SERVICE_NAME = (TARGET_ENV == 'dev') ? 'sayit-helpdesk-dev' : (TARGET_ENV == 'stage') ? 'sayit-helpdesk-stage' : 'sayit-helpdesk' def OTEL_SERVICE_NAME = (TARGET_ENV == 'dev') ? 'sayit-helpdesk-dev' : (TARGET_ENV == 'stage') ? 'sayit-helpdesk-stage' : 'sayit-helpdesk'
def IMAGE_TAG = "${TARGET_ENV}-${env.BUILD_NUMBER}" // dev-123 / stage-123 / prod-123 def IMAGE_TAG_PREFIX = (env.JOB_NAME?.contains('session')) ? "${TARGET_ENV}-session" : TARGET_ENV
def LATEST_TAG = "latest-${TARGET_ENV}" // latest-dev / latest-stage / latest-prod def IMAGE_TAG = "${IMAGE_TAG_PREFIX}-${env.BUILD_NUMBER}" // dev-123 / dev-session-123
def LATEST_TAG = "latest-${IMAGE_TAG_PREFIX}" // latest-dev / latest-dev-session
timestamps { timestamps {
@@ -157,4 +158,4 @@ spec:
} }
} }
} }
} }
+67
View File
@@ -0,0 +1,67 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: sayit-helpdesk-session-redis
namespace: sayit-helpdesk-dev
labels:
app: sayit-helpdesk-session-redis
spec:
replicas: 1
selector:
matchLabels:
app: sayit-helpdesk-session-redis
template:
metadata:
labels:
app: sayit-helpdesk-session-redis
spec:
containers:
- name: redis
image: redis:7.2-alpine
imagePullPolicy: IfNotPresent
args:
- redis-server
- --save
- ""
- --appendonly
- "no"
ports:
- name: redis
containerPort: 6379
readinessProbe:
tcpSocket:
port: redis
initialDelaySeconds: 3
periodSeconds: 5
timeoutSeconds: 2
failureThreshold: 3
livenessProbe:
tcpSocket:
port: redis
initialDelaySeconds: 10
periodSeconds: 10
timeoutSeconds: 2
failureThreshold: 3
resources:
requests:
cpu: 50m
memory: 64Mi
limits:
cpu: 500m
memory: 256Mi
---
apiVersion: v1
kind: Service
metadata:
name: sayit-helpdesk-session-redis
namespace: sayit-helpdesk-dev
labels:
app: sayit-helpdesk-session-redis
spec:
type: ClusterIP
selector:
app: sayit-helpdesk-session-redis
ports:
- name: redis
port: 6379
targetPort: redis
+21 -1
View File
@@ -20,6 +20,7 @@
<log4j2.version>2.1</log4j2.version> <log4j2.version>2.1</log4j2.version>
<jackson.version>1.9.13</jackson.version> <jackson.version>1.9.13</jackson.version>
<httpcomponents.version>4.5.2</httpcomponents.version> <httpcomponents.version>4.5.2</httpcomponents.version>
<spring.session.version>1.3.5.RELEASE</spring.session.version>
</properties> </properties>
<!--<repositories>--> <!--<repositories>-->
@@ -130,6 +131,25 @@
<artifactId>egovframework.rte.fdl.property</artifactId> <artifactId>egovframework.rte.fdl.property</artifactId>
<version>${egovframework.rte.version}</version> <version>${egovframework.rte.version}</version>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session-data-redis</artifactId>
<version>${spring.session.version}</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-oxm</artifactId>
<version>${spring.maven.artifact.version}</version>
</dependency>
<!-- Spring Framework --> <!-- Spring Framework -->
<!-- <dependency>--> <!-- <dependency>-->
<!-- <groupId>org.springframework</groupId>--> <!-- <groupId>org.springframework</groupId>-->
@@ -801,4 +821,4 @@
</build> </build>
</profile> </profile>
</profiles> </profiles>
</project> </project>
@@ -152,3 +152,11 @@ ldap.url =ldap://localhost:10389
ldap.rootDn =c=kr ldap.rootDn =c=kr
ldap.username =uid=admin,ou=system ldap.username =uid=admin,ou=system
ldap.password =secret ldap.password =secret
# Spring Session Redis
Session.Redis.Host=sayit-helpdesk-session-redis
Session.Redis.Port=6379
Session.Redis.Database=0
Session.Redis.Timeout=2000
Session.Redis.Namespace=sayit-helpdesk-dev:session
Session.Redis.MaxInactiveIntervalInSeconds=36000
@@ -150,3 +150,11 @@ ldap.url =ldap://localhost:10389
ldap.rootDn =c=kr ldap.rootDn =c=kr
ldap.username =uid=admin,ou=system ldap.username =uid=admin,ou=system
ldap.password =secret ldap.password =secret
# Spring Session Redis
Session.Redis.Host=sayit-helpdesk-session-redis
Session.Redis.Port=6379
Session.Redis.Database=0
Session.Redis.Timeout=2000
Session.Redis.Namespace=sayit-helpdesk:session
Session.Redis.MaxInactiveIntervalInSeconds=36000
@@ -145,3 +145,11 @@ ldap.url =ldap://localhost:10389
ldap.rootDn =c=kr ldap.rootDn =c=kr
ldap.username =uid=admin,ou=system ldap.username =uid=admin,ou=system
ldap.password =secret ldap.password =secret
# Spring Session Redis
Session.Redis.Host=sayit-helpdesk-session-redis
Session.Redis.Port=6379
Session.Redis.Database=0
Session.Redis.Timeout=2000
Session.Redis.Namespace=sayit-helpdesk-stage:session
Session.Redis.MaxInactiveIntervalInSeconds=36000
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
<context:annotation-config/>
<util:constant id="redisFlushModeOnSave"
static-field="org.springframework.session.data.redis.RedisFlushMode.ON_SAVE"/>
<util:constant id="configureRedisActionNoOp"
static-field="org.springframework.session.data.redis.config.ConfigureRedisAction.NO_OP"/>
<bean class="org.springframework.session.data.redis.config.annotation.web.http.RedisHttpSessionConfiguration">
<property name="maxInactiveIntervalInSeconds" value="${Session.Redis.MaxInactiveIntervalInSeconds}"/>
<property name="redisNamespace" value="${Session.Redis.Namespace}"/>
<property name="redisFlushMode" ref="redisFlushModeOnSave"/>
<property name="configureRedisAction" ref="configureRedisActionNoOp"/>
</bean>
<bean id="redisConnectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory">
<property name="hostName" value="${Session.Redis.Host}"/>
<property name="port" value="${Session.Redis.Port}"/>
<property name="database" value="${Session.Redis.Database}"/>
<property name="timeout" value="${Session.Redis.Timeout}"/>
<property name="usePool" value="true"/>
</bean>
<bean id="cookieSerializer" class="org.springframework.session.web.http.DefaultCookieSerializer">
<property name="cookieName" value="JSESSIONID"/>
<property name="cookiePath" value="/"/>
<property name="useHttpOnlyCookie" value="true"/>
<property name="useBase64Encoding" value="false"/>
</bean>
</beans>
+8
View File
@@ -1,6 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:jsp="http://java.sun.com/xml/ns/javaee/jsp" xmlns:web="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:jsp="http://java.sun.com/xml/ns/javaee/jsp" xmlns:web="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>Default</display-name> <display-name>Default</display-name>
<filter>
<filter-name>springSessionRepositoryFilter</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSessionRepositoryFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter> <filter>
<filter-name>encodingFilter</filter-name> <filter-name>encodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>