如何解决Kubernetes-在Pod之间分配负载
我正在尝试评估用golang编写的应用程序之一的性能。
为部署创建副本集,并且我的Pod已准备就绪并且正在运行。
NAME READY STATUS RESTARTS AGE
go-ppu-6c5fdc985f-9vjlg 1/1 Running 0 11m
go-ppu-6c5fdc985f-g8bhp 1/1 Running 0 10d
为了公开访问该应用程序,我还完成了端口转发(应用程序托管在ec2中)。
kubectl port-forward service/go-ppu-service 8081 --address 0.0.0.0
但是当我检查Pod的日志时,只有一个Pod正在收到我的请求go-ppu-6c5fdc985f-9vjlg。有什么我想念的吗?我想分配负载。
---
apiVersion: apps/v1
kind: Deployment # Type of Kubernetes resource
metadata:
name: go-ppu # Name of the Kubernetes resource
spec:
replicas: 2 # Number of pods to run at any given time
selector:
matchLabels:
app: go-ppu # This deployment applies to any Pods matching the specified label
template: # This deployment will create a set of pods using the configurations in this template
metadata:
labels: # The labels that will be applied to all of the pods in this deployment
app: go-ppu
spec: # Spec for the container which will run in the Pod
containers:
- name: go-ppu
image: ppu_test:latest
imagePullPolicy: Never
ports:
- containerPort: 8081 # Should match the port number that the Go application listens on
livenessProbe: # To check t$(minikube docker-env)he health of the Pod
httpGet:
path: /health
port: 8081
scheme: HTTP
initialDelaySeconds: 35
periodSeconds: 30
timeoutSeconds: 20
readinessProbe: # To check if the Pod is ready to serve traffic or not
httpGet:
path: /readiness
port: 8081
scheme: HTTP
initialDelaySeconds: 35
timeoutSeconds: 20
---
apiVersion: v1
kind: Service # Type of kubernetes resource
metadata:
name: go-ppu-service # Name of the resource
spec:
type: NodePort # A port is opened on each node in your cluster via Kube proxy.
hostNetwork: true
ports: # Take incoming HTTP requests on port 9090 and forward them to the targetPort of 8080
- name: http
protocol: TCP
port: 8081
targetPort: 8081
selector:
app: go-ppu
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。