欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

k8s service

程序员文章站 2022-03-12 11:50:31
...

kubectl create service clusterip wfq-svc-cp --tcp=80:8080

kubectl create service nodeport wfq-svc-np --tcp=1234:80

kubectl create service clusterip wfq-svc-headless --clusterip="None"


[email protected]:~# kubectl create service clusterip wfq-svc-cp --tcp=80:8080
service "wfq-svc-cp" created
[email protected]:~#
[email protected]:~#
[email protected]:~# kubectl create service nodeport wfq-svc-np --tcp=1234:80
service "wfq-svc-np" created
[email protected]:~#
[email protected]:~#
[email protected]:~# kubectl create service clusterip wfq-svc-headless --clusterip="None"
service "wfq-svc-headless" created
[email protected]:~#
[email protected]:~#
[email protected]:~# kubectl get svc
NAME                  TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)          AGE
kubernetes            ClusterIP   10.68.0.1       <none>        443/TCP          226d
kubernetes-bootcamp   NodePort    10.68.70.33     <none>        80:34824/TCP     226d
my-nginx              ClusterIP   10.68.4.181     <none>        8090/TCP         22h
my-srv-cp             ClusterIP   10.68.45.143    <none>        80/TCP           23h
my-svc-headless       ClusterIP   None            <none>        <none>           23h
my-svc-np             NodePort    10.68.210.209   <none>        1234:24209/TCP   23h
nginx-service         NodePort    10.68.121.152   <none>        8080:20000/TCP   226d
wfq-svc-cp            ClusterIP   10.68.56.155    <none>        80/TCP           1m
wfq-svc-headless      ClusterIP   None            <none>        <none>           11s
wfq-svc-np            NodePort    10.68.108.6     <none>        1234:21388/TCP   40s
[email protected]:~#
[email protected]:~#
[email protected]:~# kubectl describe service wfq-svc-cp
Name:              wfq-svc-cp
Namespace:         default
Labels:            app=wfq-svc-cp
Annotations:       <none>
Selector:          app=wfq-svc-cp
Type:              ClusterIP
IP:                10.68.56.155
Port:              80-8080  80/TCP
TargetPort:        8080/TCP
Endpoints:         <none>
Session Affinity:  None
Events:            <none>
[email protected]:~#
[email protected]:~# kubectl describe service wfq-svc-np
Name:                     wfq-svc-np
Namespace:                default
Labels:                   app=wfq-svc-np
Annotations:              <none>
Selector:                 app=wfq-svc-np
Type:                     NodePort
IP:                       10.68.108.6
Port:                     1234-80  1234/TCP
TargetPort:               80/TCP
NodePort:                 1234-80  21388/TCP
Endpoints:                <none>
Session Affinity:         None
External Traffic Policy:  Cluster
Events:                   <none>
[email protected]:~#
[email protected]:~# kubectl describe service wfq-svc-headless
Name:              wfq-svc-headless
Namespace:         default
Labels:            app=wfq-svc-headless
Annotations:       <none>
Selector:          app=wfq-svc-headless
Type:              ClusterIP
IP:                None
Session Affinity:  None
Events:            <none>