赞
踩
1 )概述
2 )基于NodePort来实践
apiVersion: v1 kind: Service metadata: name: svc-node-port-nginx labels: app: nginx name: nginx-deployment spec: type: NodePort selector: app: nginx ports: - port: 80 name: svc-nginx-30001 protocol: TCP targetPort: 80 nodePort: 30001 --- apiVersion: apps/v1 kind: Deployment metadata: name: dep-node-port-nginx spec: replicas: 1 selector: matchLabels: app: nginx template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx resources: limits: memory: "64Mi" cpu: "500m" ports: - containerPort: 80
kubectl apply -f node-port-nginx.yaml
service/svc-node-port-nginx created
deployment.apps/dep-node-port-nginx created
kubectl get all
NAME READY STATUS RESTARTS AGE
pod/dep-node-port-nginx-854c74b9f4-96cmt 1/1 Running 0 51s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/svc-node-port-nginx NodePort 10.1.135.122 <none> 80:30001/TCP 51s
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/dep-node-port-nginx 1/1 1 1 51s
NAME DESIRED CURRENT READY AGE
replicaset.apps/dep-node-port-nginx-854c74b9f4 1 1 1 51s
kubectl describe pod dep-node-port-nginx-854c74b9f4-96cmt | grep Node
查看部署到了哪台机器上Node: node2.k8s/10.211.55.12
Node-Selectors: <none>
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。