Service的几种发布方式
作者:互联网
Service的发布方式主要有三种:
Cluster IP, NodePort, LoadBalancer
1. 先来看看Cluster IP,
1)cluster_ip.yaml, 在此yaml文件中,service的yaml里没有定义任何type,那么就用默认的cluster ip type
apiVersion: v1 kind: Service metadata: name: webapp1-clusterip-svc labels: app: webapp1-clusterip spec: ports: - port: 80 selector: app: webapp1-clusterip --- apiVersion: extensions/v1beta1 kind: Deployment metadata: name: webapp1-clusterip-deployment spec: replicas: 2 template: metadata: labels: app: webapp1-clusterip spec: containers: - name: webapp1-clusterip-pod image: katacoda/docker-http-server:latest ports: - containerPort: 80 ---
2)设置环境变量
export CLUSTER_IP=$(kubectl get services/webapp1-clusterip-svc -o go-template='{{(index .spec.clusterIP)}}')
echo CLUSTER_IP=$CLUSTER_IP
curl $CLUSTER_IP:80
3)由上一步可显示k8s自动分配给service的cluster ip
标签:Service,IP,webapp1,几种,CLUSTER,发布,clusterip,spec 来源: https://www.cnblogs.com/summershan/p/15670881.html