当前位置:网站首页>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
边栏推荐
猜你喜欢
随机推荐
重保特辑|拦截99%恶意流量,揭秘WAF攻防演练最佳实践
shell 编程规范与变量
【23考研】408代码题参考模板——顺序表
js人均寿命和GDP散点图统计样式
ARC117E零和范围2
selenium4+pyetsst+allure+pom进行自动化测试框架的最新设计
腾讯称电竞人才缺口200万;华为鸿蒙3.0正式发布;乐视推行每周工作4天半?...丨黑马头条...
Logic Vulnerability----Permission Vulnerability
svg波浪动画js特效代码
58. 最后一个单词的长度
R语言ggplot2可视化:使用ggpubr包的ggboxplot函数可视化分组箱图、使用ggpar函数改变图形化参数(xlab、ylab、改变可视化图像的坐标轴标签内容)
深度操作系统DeepinOS安装步骤和MySQL安装测试
经典测试面试题集—逻辑推理题
一文读懂Elephant Swap,为何为ePLATO带来如此高的溢价?
【ROS进阶篇】第十一讲 基于Gazebo和Rviz的机器人联合仿真(运动控制与传感器)
永州动力电池实验室建设合理布局方案
第十五天笔记
正确处理页面控制器woopagecontroller.php,当提交表单时是否跳转正确的页面
电池包托盘有进水风险,存在安全隐患,紧急召回52928辆唐DM
05 | login background: based on the password login mode (below)









