spring-boot项目简单测试…
项目地址
https://github.com/451817970-qq-com/coffee.git
镜像
vim sources.list
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
vim Dockerfile
FROM ubuntu:18.04
ENV LANG C.UTF-8
COPY sources.list /etc/apt/sources.list
RUN apt update && apt install -y \
iputils-ping \
net-tools \
openjdk-8-jre-headless \
&& rm -rf /var/lib/apt/lists/*
COPY coffee-web.jar /opt
docker build -t coffee-web:v1.0 .
coffee-web.yaml
apiVersion: v1
kind: Pod
metadata:
name: coffee-web
spec:
containers:
- name: coffee-web-c
image: coffee-web:v1.0
resources:
limits:
memory: "200Mi"
requests:
memory: "100Mi"
command: ['sh', '-c', 'java -jar /opt/coffee-web.jar']
volumeMounts:
- name: log
mountPath: /var/log/apps
volumes:
- name: log
hostPath:
path: /var/log/apps
coffee-web2.yaml
使用环境变量,使用uid作为路径,收集非json log,但是没成功!
apiVersion: v1
kind: Pod
metadata:
name: coffee-web
spec:
containers:
- name: coffee-web-c
image: 192.168.56.104/xfuzz/coffee-web:v1.0
env:
- name: NAMESPACE
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.namespace
- name: POD_NAME
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.name
- name: POD_UID
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.uid
resources:
limits:
memory: "200Mi"
requests:
memory: "100Mi"
command: ['sh', '-c', 'java -jar /opt/coffee-web.jar']
volumeMounts:
- name: app-json-log
mountPath: /var/log/apps
subPathExpr: $(POD_UID)
- name: app-nonjson-log
mountPath: /var/log/apps2
subPathExpr: $(POD_UID)
volumes:
- name: app-json-log
hostPath:
path: /var/log/apps
type: DirectoryOrCreate
- name: app-nonjson-log
hostPath:
path: /var/log/apps2
type: DirectoryOrCreate