本文主要是介绍yaml文件创建mysql_kubernetes 比较好的案例-创建tomcat-mysql集群 mysql.yaml + workpress.yaml...,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
安装部署一个tomcat+mysql应用
apiVersion: v1
kind: ReplicationController
metadata:
name: myweb
spec: //spec中是对RC对象的具体描述
replicas: 5
selector:
app: myweb
template:
metadata:
labels: //选择器,用来选择对象的
app: myweb //我选择了标签为app: myweb的pod
spec: //对pod模版的具体描述
containers:
- image: kubeguide/tomcat-app:v1
name: myweb
resources:
limits:
cpu: "2"
memory: 4Gi
ports: 22
- containerPort: 8080
env:
- name: MYSQL_SERVICE_HOST
value: 'mysql'
- name: MYSQL_SERVICE_PORT
value: '3306'
创建tomcat service
apiVersion: v1
kind: Service
metadata:
name: myweb
spec:
selector:
app: myweb
type: NodePort
ports:
- port: 8888
nodePort: 30008
targetPort: 8080
mysql rc
apiVersion: v1
kind: ReplicationController
metadata:
name: mysql
spec:
replicas: 1
selector:
app: mysql
template:
metadata:
labels:
app: mysql
spec:
containers:
- name: mysql
image: mysql:5.7
ports:
- containerPort: 3306
env:
- name: MYSQL_ROOT_PASSWORD
value: "123456"
mysql service
apiVersion: v1
kind: Service
metadata:
name: mysql
spec:
selector:
app: mysql
type: NodePort
ports:
- port: 3306
nodePort: 30006
targetPort: 3306
参考:
这篇关于yaml文件创建mysql_kubernetes 比较好的案例-创建tomcat-mysql集群 mysql.yaml + workpress.yaml...的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!