#응용문제
서버 설정파일이 파드가 실행될때 넘어올수 있게 하라.
##### WAS 쪽 도커파일######
FROM tomcat:9.0
RUN rm -rf /usr/local/tomcat/conf/server.xml
ADD ./server.xml /usr/local/tomcat/conf/server.xml
ADD ./connent.sh /usr/local/tomcat/connent.sh
ADD ./mysql-connector-java-8.0.19.jar /usr/local/tomcat/lib/mysql-connector-java-8.0.19.jar
EXPOSE 8080
EXPOSE 8009
ENV TYPE=0.0.0.0
CMD /usr/local/tomcat/connent.sh $TYPE && catalina.sh run
connent.sh
#!/bin/bash
if [ $1 != "" ]
then
sed -i "s/address=\"0.0.0.0\"/address=\"$1\"/g" /usr/local/tomcat/conf/server.xml
fi
yml 파일
---
apiVersion: v1
kind: ConfigMap
metadata:
name: cm-tomcat-dev
data:
TYPE: '0.0.0.0'
---
#파드
apiVersion: v1
kind: Pod
metadata:
name: was-server
labels:
app: pod-was
spec:
nodeSelecter:
kubernetes.io/hostname: node1
containers:
- name: was
image: yoskr/tomcat:1.1
envFrom:
- configMapRef:
name: cm-tomcat-dev #cm-dev 설정파일을 불러오자
ports:
- containerPort: 8009
volumeMounts:
- mountPath: /usr/local/tomcat/webapps
name: was-pvc-pv
volumes:
- name : was-pvc-pv
persistentVolumeClaim:
claimName: pvc-was
######WEB쪽 도커파일
FROM httpd:2.4
RUN apt update
RUN apt install -y libapache2-mod-jk
RUN cp /usr/lib/apache2/modules/mod_jk.so /usr/local/apache2/modules/mod_jk.so
RUN sed -i 's/localhost/tomcat-svc/g' /etc/libapache2-mod-jk/workers.properties
ADD ./connent.sh /usr/local/apache2/connent.sh
RUN rm -rf /usr/local/apache2/conf/httpd.conf
ADD ./httpd.conf /usr/local/apache2/conf/httpd.conf
EXPOSE 80
ENV TYPE=tomcat-svc
CMD /usr/local/apache2/connent.sh $TYPE && httpd-foreground
connent.sh 파일생성
#!/bin/bash
if [ $1 != "" ]
then
sed -i "s/tomcat-svc/$1/g" /etc/libapache2-mod-jk/workers.properties
fi
yml 파일
apiVersion: v1
kind: ConfigMap
metadata:
name: cm-httpd-dev
data:
TYPE: 'svc-was'
---
apiVersion: v1
kind: Pod
metadata:
name: web-server
labels:
app: pod-web
spec:
nodeSelecter:
kubernetes.io/hostname: node1
containers:
- name: web
image: yoskr/httpd:0.4
envFrom:
- configMapRef:
name: cm-httpd-dev #cm-httpd 설정파일을 불러오자
ports:
- containerPort: 80
volumeMounts:
- mountPath: /usr/local/apache2/htdocs
name: web-pvc-pv
volumes:
- name : web-pvc-pv
persistentVolumeClaim:
claimName: pvc-web
강사님 풀이..
WAS서버부분 도커 파일 수정
#CMD부분에 아래와 같이 설정파일을 받아오게한다.
CMD wget http://100.100.100.100:8888/test.jsp -O /usr/local/tomcat/webapps/sjb/test.jsp && wget http://100.100.100.100:8888/server.xml -O /usr/local/tomcat/conf/server.xml && catalina.sh run
728x90
반응형