k8s-1.9.1-步骤七(测试)
----------------------------------------------------------------------------------------------------------------------------执行主机:192.168.1.15or16or18创建rc文件mkdir /root/tomcatcd /root/tomcatcat >
·
----------------------------------------------------------------------------------------------------------------------------
执行主机:192.168.1.15or16or18
创建rc文件
mkdir /root/tomcat
cd /root/tomcat
cat > /root/tomcat/tomcat.rc.yaml<<EOF
apiVersion: v1
kind: ReplicationController
metadata:
name: myweb
spec:
replicas: 2
selector:
app: myweb
template:
metadata:
labels:
app: myweb
spec:
containers:
- image: docker.io/tomcat
name: myweb
ports:
- containerPort: 8080
env:
- name: MYSQL_SERVICE_HOST
value: 'mysql'
- name: MYSQL_SERVICE_PORT
value: '3306'
EOF
创建svc文件
cat > /root/tomcat/tomcat.svc.yaml << EOF
> apiVersion: v1
> kind: Service
> metadata:
> name: myweb
> spec:
> ports:
> - name: myweb-svc
> port: 8080
> targetPort: 8080
> nodePort: 31111
> selector:
> app: myweb
> type: NodePort
> EOF
启动RC和SVC
kubectl create -f tomcat.rc.yaml
kubectl create -f tomcat.svc.yaml
更多推荐
已为社区贡献7条内容
所有评论(0)