----------------------------------------------------------------------------------------------------------------------------
执行主机: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



Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐