当前位置:网站首页>kubernate部署服务
kubernate部署服务
2022-07-30 13:34:00 【青春不流名】
系统环境
1. 创建 nameSpace和 configMap
vim demo-ns.yaml
apiVersion: v1
kind: Namespace
metadata:
name: demo
labels:
name: demo
---
apiVersion: v1
kind: ConfigMap
metadata:
name: demo-cm
namespace: demo
data:
application-local.yml: |
server:
port: 9195
address: 0.0.0.0
spring:
main:
allow-bean-definition-overriding: true
application:
name: shenyu-bootstrap
management:
health:
defaults:
enabled: false
shenyu:
local:
enabled: true
file:
enabled: true
cross:
enabled: true
dubbo:
parameter: multi
sync:
websocket:
urls: ws://shenyu-admin-svc.shenyu.svc.cluster.local:9095/websocket
exclude:
enabled: false
paths:
- /favicon.ico
extPlugin:
enabled: true
threads: 1
scheduleTime: 300
scheduleDelay: 30
scheduler:
enabled: false
type: fixed
threads: 16
logging:
level:
root: info
org.springframework.boot: info
org.apache.ibatis: info
org.apache.shenyu.bonuspoint: info
org.apache.shenyu.lottery: info
org.apache.shenyu: info
application-mysql.yml: |
spring.datasource.url: jdbc:mysql://mysql.shenyu.svc.cluster.local:3306/shenyu?useUnicode=true&characterEncoding=utf-8&useSSL=false
spring.datasource.username: root
spring.datasource.password: 123456
2. 创建 endpoint 代理外部 mysql
demo-mysql-service
kind: Service
apiVersion: v1
metadata:
name: mysql
namespace: shenyu
spec:
ports:
- port: 3306
name: mysql
targetPort: 3306
---
kind: Endpoints
apiVersion: v1
metadata:
name: mysql
namespace: shenyu
subsets:
- addresses:
- ip: 10.10.10.88
ports:
- port: 3306
name: mysql
3.创建 pv和pvc 存储
vim demo-store.yaml
# 示例使用 pvc、pv、storageClass 来存储文件
apiVersion: v1
kind: PersistentVolume
metadata:
name: demo-pv
spec:
capacity:
storage: 1Gi
volumeMode: Filesystem
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Delete
storageClassName: local-storage
local:
path: /home/demo/k8s-pv # 指定节点上的目录,该目录下面需要包含 mysql-connector.jar
nodeAffinity:
required:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- node1 # 指定节点
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: demo-pvc
namespace: demo
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
storageClassName: local-storage
---
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: local-storage
provisioner: kubernetes.io/no-provisioner
volumeBindingMode: WaitForFirstConsumer
4. 部署 应用程序boot-demo
# 示例使用 nodeport 方式暴露端口
apiVersion: v1
kind: Service
metadata:
namespace: demo
name: demo-svc
spec:
selector:
app: boot-bootstrap
type: NodePort
ports:
- protocol: TCP
port: 9195
targetPort: 9195
nodePort: 31195
---
# shenyu-bootstrap
apiVersion: apps/v1
kind: Deployment
metadata:
namespace: shenyu
name: shenyu-bootstrap
spec:
selector:
matchLabels:
app: shenyu-bootstrap
replicas: 1
template:
metadata:
labels:
app: shenyu-bootstrap
spec:
volumes:
- name: shenyu-bootstrap-config
configMap:
name: shenyu-cm
items:
- key: application-local.yml
path: application-local.yml
containers:
- name: shenyu-bootstrap
image: apache/shenyu-bootstrap:latest
ports:
- containerPort: 9195
env:
- name: TZ
value: Asia/Beijing
volumeMounts:
- name: shenyu-bootstrap-config
mountPath: /opt/shenyu-bootstrap/conf/application-local.yml
subPath: application-local.yml
边栏推荐
- “12306” 的架构到底有多牛逼
- What are the hard-core upgrades and applications that cannot be missed in Greenplum 6.0?
- UPC2022暑期个人训练赛第19场(B,P)
- 深度操作系统DeepinOS安装步骤和MySQL安装测试
- CF1677E Tokitsukaze and Beautiful Subsegments
- R语言使用方差分析ANOVA比较回归模型的差异、anova函数比较两个模型并报告它们是否存在显著差异(两个模型的数据相同,一个模型使用的预测特征包含另外一个模型的特征)
- 简单理解精确率(Precision),召回率(Recall),准确率(Accuracy),TP,TN,FP,FN
- 元宇宙的六大支撑技术
- 永州动力电池实验室建设合理布局方案
- Jenkins自动化部署项目
猜你喜欢
随机推荐
ML之PDP:基于FIFA 2018 Statistics(2018年俄罗斯世界杯足球赛)球队比赛之星分类预测数据集利用DT决策树&RF随机森林+PDP部分依赖图可视化实现模型可解释性之详细攻略
Data Middle Office Construction (5): Breaking Enterprise Data Silos and Extracting Data Value
canvas彩虹桥动画js特效
Learning notes - 7 weeks as data analyst "in the first week: data analysis of thinking"
Apache Log4j2漏洞
No-code development platform all application settings introductory tutorial
ARC117E零和范围2
Logic Vulnerability----Permission Vulnerability
逻辑漏洞----权限类漏洞
永州动力电池实验室建设合理布局方案
SyntaxError: EOL while scanning string literal
cpu/CS and IP
SQL 改写系列七:谓词移动
R语言ggplot2可视化:使用ggpubr包的ggboxplot函数可视化分组箱图、使用ggpar函数改变图形化参数(xlab、ylab、改变可视化图像的坐标轴标签内容)
C语言学习练习题:汉诺塔(函数与递归)
58. 最后一个单词的长度
js背景切换时钟js特效代码
树形dp小总结(换根,基环树,杂七杂八的dp)
【软考软件评测师】自动化测试章节下篇
05 | login background: based on the password login mode (below)









