elastic-job-lite-console 部署到k8s集群

[elastic-job-lite-console 部署到k8s]

1.准备构建镜像的文件

[root@jenkins elastic-job]# ls
Configurations.xml      Dockerfile     elastic-job-lite-console-2.1.5.tar.gz       run.sh

[root@jenkins elastic-job]# cat Dockerfile
FROM harbor.reg/library/centos7-jdk:8u221

#构建参数

#环境变量
ENV WORK_PATH /data/work/
ENV LANG=zh_CN.UTF-8 
LANGUAGE=zh_CN:zh 
LC_ALL=zh_CN.UTF-8

#设置时区
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && 
echo "Asia/Shanghai" > /etc/timezone && 
localedef -c -f UTF-8 -i zh_CN zh_CN.UTF-8
ADD elastic-job-lite-console-2.1.5.tar.gz $WORK_PATH
COPY run.sh /
WORKDIR $WORK_PATH
RUN chmod +x /run.sh
CMD ["sh","/run.sh"]

[root@jenkins elastic-job]# cat run.sh
sh +x elastic-job-lite-console-2.1.5/bin/start.sh -p 8899

##  2.构建镜像并上传 

> docker build -t harbor.reg/library/elastic-job-lite:2.1.5 .

> docker push harbor.reg/library/elastic-job-lite:2.1.5

##  3.创建k8s  yaml 文件
 deploy.yaml

cat deploy.yaml
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: dev-elastic-job-lite-profile-a
spec:
replicas: 1
minReadySeconds: 30 #滚动升级时120s后认为该pod就绪
strategy:
rollingUpdate: ##由于replicas为3,则整个升级,pod个数在2-4个之间
maxSurge: 1 #滚动升级时会先启动1个pod
maxUnavailable: 0 #滚动升级时允许的最大Unavailable的pod个数
template:
metadata:
labels:
app: dev-elastic-job-lite
profile: profile-a
spec:
terminationGracePeriodSeconds: 40 ##k8s将会给应用发送SIGTERM信号,可以用来正确、优雅地关闭应用,默认为30秒
volumes:
- name: "dev-configurations"
hostPath:
path: "/home/elastic-job-console/dev/" # 本地host目录,即挂载目录
#- name: "mfs"
# hostPath:
# path: "/home/nfs"
containers:
- name: dev-elastic-job-lite-profile-a
image: harbor.reg/library/elastic-job-lite:2.1.5
imagePullPolicy: IfNotPresent
volumeMounts:
- name: dev-configurations
mountPath: /root/.elastic-job-console
#- name: mfs
# mountPath: /home/nfs
resources:
limits:
memory: 2000Mi
requests:
memory: 1500Mi
ports:
- containerPort: 8899
env:
- name: app_name
value: dev-elastic-job-lite-profile-a
- name: project_name
value: dev-elastic-job-lite
svc.yaml

apiVersion: v1
kind: Service
metadata:
name: dev-elastic-job-lite-profile-a
labels:
app: dev-elastic-job-lite
profile: profile-a
spec:
selector:
app: dev-elastic-job-lite
profile: profile-a
type: NodePort
ports:
- port: 8899
targetPort: 8899
nodePort: 32222

4.nginx配置文件


[root@bogon vhost]# cat ss.conf
upstream elastic-lite.dev.xx.com {
server 172.16.167.10:32222 weight=1 max_fails=0 fail_timeout=0;
server 172.16.167.11:32222 weight=1 max_fails=0 fail_timeout=0;
server 172.16.167.12:32222 weight=1 max_fails=0 fail_timeout=0;
}

server {
listen 80;
server_name elastic-lite.dev.xx.com;
rewrite ^(.*) https://$server_name$1 permanent;
}
server {
listen 443;
server_name elastic-lite.dev.xx.com;
charset UTF-8;
access_log /var/logs/ss/access/elastic-lite.dev.xx.com_access.log main;
ssl on;
ssl_certificate /usr/local/nginx/conf/CA/ss.crt;
ssl_certificate_key /usr/local/nginx/conf/CA/ss.key;
send_timeout 10;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-RC4-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:RC4-SHA:!aNULL:!eNULL:!EXPORT:!DES:!3DES:!MD5:!DSS:!PKS;
#include drop_sql.conf;
include favicon.conf;


location / {
proxy_pass http://elastic-lite.dev.xx.com;
}
}

默认密码  root root

image.png

你可能感兴趣的:(k8s,docker,yaml)