Home > Archives > Service示例

Service示例

Publish:


# my-service.yaml

apiVersion: v1
kind: Service
metadata:
  name: hello-service
spec:
  type: NodePort
  ports:
  - port: 3000
    nodePort: 30390
	protocol: TCP
	targetPort: 3000
  selector:
    app: my-deployment

kubectl create -f my-service.yaml
kubectl get svc

kubectl run -i --tty alpine --image=alpine --restart=Never -- sh
apk add --no-cache curl
curl <ClusterIP>:<ClusterPort>

kubectl exec -it hello-deployment-6db6b6cbdf-6bfr8  sh
curl <ClusterIP>:<ClusterPort>

参考

声明: 本文采用 BY-NC-SA 授权。转载请注明转自: Ding Bao Guo