创建部署问题时,请参考下面模板,你提供的信息越多,越容易及时获得解答。如果未按模板创建问题,管理员有权关闭问题。
确保帖子格式清晰易读,用 markdown code block 语法格式化代码块。
你只花一分钟创建的问题,不能指望别人花上半个小时给你解答。
已经解决,原因是Ingress缺少注解
//不光要加这个
nginx.ingress.kubernetes.io/service-upstream: 'true'
//还要加这个
nginx.ingress.kubernetes.io/upstream-vhost: mcp-demo-web.mcp-demo.svc.cluster.local
操作系统信息
虚拟机,Ubuntu 22.04.1 LTS, 8c16G
Kubernetes版本信息
Client Version: version.Info{Major:“1”, Minor:“23”, GitVersion:“v1.23.17”, GitCommit:“953be8927218ec8067e1af2641e540238ffd7576”, GitTreeState:“clean”, BuildDate:“2023-02-22T13:34:27Z”, GoVersion:“go1.19.6”, Compiler:“gc”, Platform:“linux/amd64”}
容器运行时
Version: 0.1.0
RuntimeName: containerd
RuntimeVersion: 1.6.21
RuntimeApiVersion: v1
KubeSphere版本信息
v3.3.2离线安装
问题是什么
金丝雀按比例流量分配,失效
金丝雀按请求头分配,失效(实际流量是v1)
流量镜像失效(56.28r/s)
VirtualService配置正常,符合策略配置,其他监控功能也正常,就是流量不受控
通过一下方式直接在创建自制应用,将服务纳入到应用,看起来没啥问题,然后测试出以上问题
#Application YAML模板
apiVersion: app.k8s.io/v1beta1
kind: Application
metadata:
name: 'mcp-demo'
namespace: mcp-demo
labels:
app.kubernetes.io/version: v1
app.kubernetes.io/name: 'mcp-demo'
annotations:
servicemesh.kubesphere.io/enabled: 'true'
spec:
selector:
matchLabels:
app.kubernetes.io/version: v1
app.kubernetes.io/name: 'mcp-demo'
addOwnerRef: true
#这里是重点
componentKinds:
- group: ''
kind: Service
- group: apps
kind: Deployment
- group: apps
kind: StatefulSet
- group: networking.k8s.io
kind: Ingress
- group: servicemesh.kubesphere.io
kind: Strategy
- group: servicemesh.kubesphere.io
kind: ServicePolicy
#其他模板
apiVersion: apps/v1
kind: Deployment
metadata:
namespace: mcp-demo
name: mcp-demo-gateway-v1
labels:
app: mcp-demo-gateway
version: v1
#---------start-----------
app.kubernetes.io/name: mcp-demo
app.kubernetes.io/version: v1
annotations:
servicemesh.kubesphere.io/enabled: 'true'
#---------end-----------
spec:
replicas: 2
selector:
matchLabels:
app: mcp-demo-gateway
version: v1
#---------start-----------
app.kubernetes.io/name: mcp-demo
app.kubernetes.io/version: v1
#---------end-----------
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 0%
type: RollingUpdate
template:
metadata:
labels:
app: mcp-demo-gateway
version: v1
#---------start-----------
app.kubernetes.io/name: mcp-demo
app.kubernetes.io/version: v1
annotations:
sidecar.istio.io/inject: 'true'
#---------end-----------
spec:
imagePullSecrets:
- name: harbor-secret
volumes:
- name: date-config
hostPath:
path: /etc/localtime
containers:
- image: harbor.qwe.com/caddy/mcp-demo-gateway:latest
imagePullPolicy: Always
name: mcp-demo-gateway
env:
- name: MEMBER_HOST
value: mcp-demo-member.mcp-demo.svc.cluster.local
- name: GOODS_HOST
value: mcp-demo-goods.mcp-demo.svc.cluster.local
- name: ORDER_HOST
value: mcp-demo-order.mcp-demo.svc.cluster.local
ports:
- containerPort: 8080
protocol: TCP
resources:
limits:
cpu: '2'
memory: 4Gi
requests:
cpu: '1'
memory: 2Gi
volumeMounts:
- name: date-config
mountPath: /etc/localtime
readinessProbe:
httpGet:
path: /actuator/health
port: 18080
scheme: HTTP
timeoutSeconds: 5
periodSeconds: 10
successThreshold: 1
failureThreshold: 3
---
apiVersion: v1
kind: Service
metadata:
namespace: mcp-demo
name: mcp-demo-gateway
labels:
app: mcp-demo-gateway
version: v1
#---------start-----------
app.kubernetes.io/name: mcp-demo
app.kubernetes.io/version: v1
annotations:
kubesphere.io/serviceType: statelessservice
servicemesh.kubesphere.io/enabled: 'true'
#---------end-----------
spec:
ports:
- name: http
protocol: TCP
port: 80
targetPort: 8080
selector:
app: mcp-demo-gateway
#---------start-----------
app.kubernetes.io/name: mcp-demo
app.kubernetes.io/version: v1
#---------end-----------
type: ClusterIP
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: mcp-demo-gateway
namespace: mcp-demo
labels:
#---------start-----------
app.kubernetes.io/name: mcp-demo
app.kubernetes.io/version: v1
annotations:
nginx.ingress.kubernetes.io/service-upstream: 'true'
#---------end-----------
spec:
rules:
- host: mcp-demo-gateway.qwe.com
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
service:
name: mcp-demo-gateway
port:
number: 80