日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

记录java应用部署到k8s中

發(fā)布時(shí)間:2024/4/18 编程问答 36 豆豆
生活随笔 收集整理的這篇文章主要介紹了 记录java应用部署到k8s中 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

最近任務(wù)是把之前運(yùn)行在docker里的自己寫的java鏡像部署到k8
s中,踩了一些坑,記錄如下:
1.在寫yaml文件時(shí)指定非shell命令而是一些命令行的時(shí)候要加上bash -c否則會(huì)報(bào)錯(cuò):exec:“bash”:executable file not found in $PATH
2.如果要操作容器里/etc/hosts這樣的文件,會(huì)報(bào)錯(cuò): can’t move ‘/etc/resolv.conf73UqmG’ to ‘/etc/resolv.conf’: Device or resource busy,一定要記著操作方式,如果用sed命令會(huì)報(bào)錯(cuò),因?yàn)閟ed命令會(huì)重新拷貝一份,具體參考:https://www.cnblogs.com/xuxinkun/p/7116737.html
最后通過bash -c的方式往hosts文件里加域名:(因?yàn)閛penjdk:8-jdk-alpine只有sh沒有bash,所以使用sh)

apiVersion: apps/v1 kind: Deployment metadata:name: java-data-storelabels:app: java-data-store spec:replicas: 1selector:matchLabels:app: java-data-storetemplate:metadata:labels:app: java-data-storespec:containers:- name: java-data-storeimage: harbor:9501/library/openjdk:8-jdk-alpineimagePullPolicy: IfNotPresentports:- name: data-storecontainerPort: 40502command: ["java", "-jar","jars/data-store.jar"]lifecycle:postStart:exec:command: ["sh","-c","echo 'xx.xx.xx.xx xxxx' >> /etc/hosts"]env:volumeMounts:- name: jar-volmountPath: /jars- name: log-volmountPath: app/logsrestartPolicy: Alwaysvolumes:- name: jar-volglusterfs:endpoints: glusterfs-clusterpath: gv0/userapp/java-apps/jarsreadOnly: false- name: log-volglusterfs:endpoints: glusterfs-clusterpath: gv0/userapp/java-apps/logs/data-storereadOnly: false --- apiVersion: v1 kind: Service metadata:name: java-data-store spec:selector:app: java-data-storeports:- port: 40502targetPort: 40502nodePort: 30203type: NodePort

總結(jié)

以上是生活随笔為你收集整理的记录java应用部署到k8s中的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。