我正在尝试部署statefulsets(启用了HPA)。我不想发送任何流量到pod 0(由于某些限制)。在服务中有没有什么方法可以让我使用正则表达式,比如-
selector:
statefulset.kubernetes.io/pod-name': pod-name-'regrex_starts _from-1-to-n'
或者有比这更好的办法吗?
入口:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
kubernetes.io/ingress.class: "nginx"
name: broker-ingress
labels:
name: broker-ingress
spec:
tls:
- hosts:
- activemq.artemis.com
rules:
- host: activemq.artemis.com
http:
paths:
- pathType: ImplementationSpecific
path: "/"
backend:
service:
name: artemis-service
port:
name: http-console
服务内容:
apiVersion: v1
kind: Service
metadata:
name: artemis-service
spec:
clusterIP: None
ports:
- port: 8161
name: http-console
protocol: TCP
targetPort: 8161
- port: 61616
name: netty-connector
protocol: TCP
targetPort: 61616
selector:
app: artemis
状态设置-
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: artemis-deployment
spec:
replicas: 5
selector:
matchLabels:
app: artemis
serviceName: artemis-service
template:
metadata:
labels:
app: artemis
spec:
containers:
- env:
- name: ARTEMIS_HOST
valueFrom:
fieldRef:
fieldPath: status.podIP
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: SVC_NAME
value: "artemis-service"
- name: NS_NAME
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: HA_POLICY
value: "LIVE"
name: artemis
image: activemq/artemis:latest
imagePullPolicy: Never
resources:
requests:
memory: "1G"
cpu: "250m"
limits:
memory: "2G"
cpu: "500m"
ports:
- containerPort: 8161
name: console
protocol: TCP
- containerPort: 61616
name: netty-connector
protocol: TCP
现在,当有5个副本时,入口将以循环方式0-1-2-3-4路由流量。但我不希望ingress将流量转发到statefulset-0(statefulset-0在内部有一些其他statefulset没有的参数)。所以我不希望有任何负载/交通)。
1条答案
按热度按时间t8e9dugd1#
为此,我在Python中实现了Leader Election