k8s-1.9.1-步骤七(测试)

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/weixin_35494719/article/details/79967479
----------------------------------------------------------------------------------------------------------------------------
执行主机: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



阅读更多
博主设置当前文章不允许评论。

博主推荐

换一批

没有更多推荐了,返回首页